1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Fixed issue where SAML login not notifiy on existing user

Added testing to cover

Fixes #2263
This commit is contained in:
Dan Brown
2020-09-26 16:43:06 +01:00
parent 328d2514c4
commit 53ec794e53
2 changed files with 28 additions and 1 deletions

View File

@ -319,6 +319,33 @@ class Saml2Test extends TestCase
$homeGet->assertRedirect('/register/confirm/awaiting');
}
public function test_login_where_existing_non_saml_user_shows_warning()
{
$this->post('/saml2/login');
config()->set(['saml2.onelogin.strict' => false]);
// Make the user pre-existing in DB with different auth_id
User::query()->forceCreate([
'email' => 'user@example.com',
'external_auth_id' => 'old_system_user_id',
'email_confirmed' => false,
'name' => 'Barry Scott'
]);
$this->withPost(['SAMLResponse' => $this->acsPostData], function () {
$acsPost = $this->post('/saml2/acs');
$acsPost->assertRedirect('/login');
$this->assertFalse($this->isAuthenticated());
$this->assertDatabaseHas('users', [
'email' => 'user@example.com',
'external_auth_id' => 'old_system_user_id',
]);
$loginGet = $this->get('/login');
$loginGet->assertSee("A user with the email user@example.com already exists but with different credentials");
});
}
protected function withGet(array $options, callable $callback)
{
return $this->withGlobal($_GET, $options, $callback);