|
55 | 55 | 'foo' => 'bar', |
56 | 56 | ]); |
57 | 57 | }); |
| 58 | + |
| 59 | +it('can handle a single Authorization entry', function () { |
| 60 | + $masker = new FieldMasker( |
| 61 | + fields: ['password', 'api_key', 'cc'], |
| 62 | + ); |
| 63 | + |
| 64 | + expect($masker->mask( |
| 65 | + data: [ |
| 66 | + 'form' => [ |
| 67 | + 'password' => 'password', |
| 68 | + 'api_key' => 'test', |
| 69 | + ], |
| 70 | + 'Authorization' => '123123123123123', |
| 71 | + 'X-API-KEY' => '1234-1234-4321', |
| 72 | + 'cc' => '1234-1234-1234-1234', |
| 73 | + 'foo' => 'bar', |
| 74 | + ], |
| 75 | + ))->toBeArray()->toEqual([ |
| 76 | + 'form' => [ |
| 77 | + 'password' => '********', |
| 78 | + 'api_key' => '****', |
| 79 | + ], |
| 80 | + 'Authorization' => '***************', |
| 81 | + 'X-API-KEY' => '**************', |
| 82 | + 'cc' => '*******************', |
| 83 | + 'foo' => 'bar', |
| 84 | + ]); |
| 85 | +}); |
| 86 | + |
| 87 | +it('can handle a two Authorization entries', function () { |
| 88 | + $masker = new FieldMasker( |
| 89 | + fields: ['password', 'api_key', 'cc'], |
| 90 | + ); |
| 91 | + |
| 92 | + expect($masker->mask( |
| 93 | + data: [ |
| 94 | + 'form' => [ |
| 95 | + 'password' => 'password', |
| 96 | + 'api_key' => 'test', |
| 97 | + ], |
| 98 | + 'Authorization' => 'Bearer 123123123123123', |
| 99 | + 'X-API-KEY' => '1234-1234-4321', |
| 100 | + 'cc' => '1234-1234-1234-1234', |
| 101 | + 'foo' => 'bar', |
| 102 | + ], |
| 103 | + ))->toBeArray()->toEqual([ |
| 104 | + 'form' => [ |
| 105 | + 'password' => '********', |
| 106 | + 'api_key' => '****', |
| 107 | + ], |
| 108 | + 'Authorization' => 'Bearer ***************', |
| 109 | + 'X-API-KEY' => '**************', |
| 110 | + 'cc' => '*******************', |
| 111 | + 'foo' => 'bar', |
| 112 | + ]); |
| 113 | +}); |
| 114 | + |
| 115 | + |
| 116 | +it('can handle a multiple Authorization entries', function () { |
| 117 | + $masker = new FieldMasker( |
| 118 | + fields: ['password', 'api_key', 'cc'], |
| 119 | + ); |
| 120 | + |
| 121 | + expect($masker->mask( |
| 122 | + data: [ |
| 123 | + 'form' => [ |
| 124 | + 'password' => 'password', |
| 125 | + 'api_key' => 'test', |
| 126 | + ], |
| 127 | + 'Authorization' => 'Bearer 123123123123123 123', |
| 128 | + 'X-API-KEY' => '1234-1234-4321', |
| 129 | + 'cc' => '1234-1234-1234-1234', |
| 130 | + 'foo' => 'bar', |
| 131 | + ], |
| 132 | + ))->toBeArray()->toEqual([ |
| 133 | + 'form' => [ |
| 134 | + 'password' => '********', |
| 135 | + 'api_key' => '****', |
| 136 | + ], |
| 137 | + 'Authorization' => 'Bearer *************** ***', |
| 138 | + 'X-API-KEY' => '**************', |
| 139 | + 'cc' => '*******************', |
| 140 | + 'foo' => 'bar', |
| 141 | + ]); |
| 142 | +}); |
| 143 | + |
| 144 | +it('can handle a malformed Authorization entry', function () { |
| 145 | + $masker = new FieldMasker( |
| 146 | + fields: ['password', 'api_key', 'cc'], |
| 147 | + ); |
| 148 | + |
| 149 | + expect($masker->mask( |
| 150 | + data: [ |
| 151 | + 'form' => [ |
| 152 | + 'password' => 'password', |
| 153 | + 'api_key' => 'test', |
| 154 | + ], |
| 155 | + 'Authorization' => 'Alien', |
| 156 | + 'X-API-KEY' => '1234-1234-4321', |
| 157 | + 'cc' => '1234-1234-1234-1234', |
| 158 | + 'foo' => 'bar', |
| 159 | + ], |
| 160 | + ))->toBeArray()->toEqual([ |
| 161 | + 'form' => [ |
| 162 | + 'password' => '********', |
| 163 | + 'api_key' => '****', |
| 164 | + ], |
| 165 | + 'Authorization' => '*****', |
| 166 | + 'X-API-KEY' => '**************', |
| 167 | + 'cc' => '*******************', |
| 168 | + 'foo' => 'bar', |
| 169 | + ]); |
| 170 | +}); |
0 commit comments