1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2026-01-03 23:42:28 +03:00

Checked over and aligned registration option behavior across all auth options

- Added tests to cover
This commit is contained in:
Dan Brown
2020-02-02 17:31:00 +00:00
parent e6c6de0848
commit 3991fbe726
20 changed files with 200 additions and 178 deletions

View File

@@ -73,7 +73,7 @@ class Saml2Test extends TestCase
$this->assertDatabaseHas('users', [
'email' => 'user@example.com',
'external_auth_id' => 'user',
'email_confirmed' => true,
'email_confirmed' => false,
'name' => 'Barry Scott'
]);
@@ -209,7 +209,7 @@ class Saml2Test extends TestCase
$acsPost = $this->post('/saml2/acs');
$acsPost->assertRedirect('/');
$errorMessage = session()->get('error');
$this->assertEquals('Registration unsuccessful since a user already exists with email address "user@example.com"', $errorMessage);
$this->assertEquals('A user with the email user@example.com already exists but with different credentials.', $errorMessage);
});
}
@@ -271,6 +271,24 @@ class Saml2Test extends TestCase
$this->assertPermissionError($resp);
}
public function test_email_domain_restriction_active_on_new_saml_login()
{
$this->setSettings([
'registration-restrict' => 'testing.com'
]);
config()->set([
'saml2.onelogin.strict' => false,
]);
$this->withPost(['SAMLResponse' => $this->acsPostData], function () {
$acsPost = $this->post('/saml2/acs');
$acsPost->assertRedirect('/login');
$errorMessage = session()->get('error');
$this->assertStringContainsString('That email domain does not have access to this application', $errorMessage);
$this->assertDatabaseMissing('users', ['email' => 'user@example.com']);
});
}
protected function withGet(array $options, callable $callback)
{
return $this->withGlobal($_GET, $options, $callback);