diff --git a/tests/Feature/Http/Middlewares/AuthenticateMiddlewareTest.php b/tests/Feature/Http/Middlewares/AuthenticateMiddlewareTest.php index 6aaa1257..193114e3 100644 --- a/tests/Feature/Http/Middlewares/AuthenticateMiddlewareTest.php +++ b/tests/Feature/Http/Middlewares/AuthenticateMiddlewareTest.php @@ -49,6 +49,25 @@ public function test_user_is_set_from_reverse_proxy_info() } + /** + * @test + */ + public function test_user_is_set_from_reverse_proxy_without_email() + { + Config::set('auth.auth_proxy_headers.user', 'HTTP_REMOTE_USER'); + + $this->app['auth']->shouldUse('reverse-proxy-guard'); + + $this->json('GET', '/api/v1/groups', [], [ + 'HTTP_REMOTE_USER' => self::USER_NAME + ]); + $this->assertAuthenticated('reverse-proxy-guard'); + + $user = $this->app->make('auth')->guard('reverse-proxy-guard')->user(); + $this->assertEquals('fake.email@do.not.use', $user->email); + } + + /** * @test */ @@ -62,7 +81,7 @@ public function test_it_does_not_authenticate_with_empty_header() $this->json('GET', '/api/v1/groups', [], [ 'HTTP_REMOTE_USER' => '', 'HTTP_REMOTE_EMAIL' => '' - ])->assertUnauthorized(); + ])->assertStatus(407); } @@ -74,7 +93,7 @@ public function test_it_does_not_authenticate_with_missing_header() $this->app['auth']->shouldUse('reverse-proxy-guard'); $this->json('GET', '/api/v1/groups', [], []) - ->assertUnauthorized(); + ->assertStatus(407); } } \ No newline at end of file