Fix and complete auth proxy tests

This commit is contained in:
Bubka 2022-05-23 11:39:10 +02:00
parent 990fca3912
commit 37c1f475c2

View File

@ -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);
}
}