|
55 | 55 | expect($response->getContent())->toEqual(config('very_basic_auth.error_message')); |
56 | 56 | }); |
57 | 57 |
|
| 58 | +test('request with incorrect credentials fails - hashed password', function () { |
| 59 | + |
| 60 | + config()->set('very_basic_auth.user', 'test'); |
| 61 | + config()->set('very_basic_auth.password', app()->make('hash')->make('test')); |
| 62 | + |
| 63 | + $response = withHeaders([ |
| 64 | + 'PHP_AUTH_USER' => str_random(20), |
| 65 | + 'PHP_AUTH_PW' => str_random(20), |
| 66 | + ])->get('/'); |
| 67 | + |
| 68 | + expect($response->getStatusCode())->toEqual(401); |
| 69 | +}); |
| 70 | + |
58 | 71 | test('request with incorrect credentials fails - json', function () { |
59 | 72 | $response = withHeaders([ |
60 | 73 | 'PHP_AUTH_USER' => str_random(20), |
|
96 | 109 | expect($response->getContent())->toEqual('ok'); |
97 | 110 | }); |
98 | 111 |
|
| 112 | +test('request with correct credentials passes - hashed password', function () { |
| 113 | + config()->set('very_basic_auth.user', 'test'); |
| 114 | + config()->set('very_basic_auth.password', app()->make('hash')->make('test')); |
| 115 | + |
| 116 | + $response = withHeaders([ |
| 117 | + 'PHP_AUTH_USER' => 'test', |
| 118 | + 'PHP_AUTH_PW' => 'test', |
| 119 | + ])->get('/'); |
| 120 | + |
| 121 | + expect($response->getStatusCode())->toEqual(200); |
| 122 | + expect($response->getContent())->toEqual('ok'); |
| 123 | +}); |
| 124 | + |
99 | 125 | test('environments', function () { |
100 | 126 | config()->set('very_basic_auth.envs', ['production']); |
101 | 127 | get('/')->assertStatus(200); |
|
0 commit comments