mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-07 23:03:00 +03:00
Review and update of login auto initiation PR
For PR #3406 - Updated naming from 'redirect' to 'initate/initation'. - Updated phpunit.xml and .env.example.complete files with the new option. - Cleaned up controller logic a bit. - Added content and design to the new initation view to not leave user on a blank view for a while. - Added non-JS button to initiation view as fallback option for progression. - Moved new test to it's own Test class and expanded with additional scenario tests for better functionality coverage.
This commit is contained in:
80
tests/Auth/LoginAutoInitiateTest.php
Normal file
80
tests/Auth/LoginAutoInitiateTest.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Auth;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class LoginAutoInitiateTest extends TestCase
|
||||
{
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
config()->set([
|
||||
'auth.auto_initiate' => true,
|
||||
'services.google.client_id' => false,
|
||||
'services.github.client_id' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_with_oidc()
|
||||
{
|
||||
config()->set([
|
||||
'auth.method' => 'oidc',
|
||||
]);
|
||||
|
||||
$req = $this->get('/login');
|
||||
$req->assertSeeText('Attempting Login');
|
||||
$req->assertElementExists('form[action$="/oidc/login"][method=POST][id="login-form"] button');
|
||||
$req->assertElementExists('button[form="login-form"]');
|
||||
}
|
||||
|
||||
public function test_with_saml2()
|
||||
{
|
||||
config()->set([
|
||||
'auth.method' => 'saml2',
|
||||
]);
|
||||
|
||||
$req = $this->get('/login');
|
||||
$req->assertSeeText('Attempting Login');
|
||||
$req->assertElementExists('form[action$="/saml2/login"][method=POST][id="login-form"] button');
|
||||
$req->assertElementExists('button[form="login-form"]');
|
||||
}
|
||||
|
||||
public function test_it_does_not_run_if_social_provider_is_active()
|
||||
{
|
||||
config()->set([
|
||||
'auth.method' => 'oidc',
|
||||
'services.google.client_id' => 'abc123a',
|
||||
'services.google.client_secret' => 'def456',
|
||||
]);
|
||||
|
||||
$req = $this->get('/login');
|
||||
$req->assertDontSeeText('Attempting Login');
|
||||
$req->assertSee('Log In');
|
||||
}
|
||||
|
||||
public function test_it_does_not_run_if_prevent_query_string_exists()
|
||||
{
|
||||
config()->set([
|
||||
'auth.method' => 'oidc',
|
||||
]);
|
||||
|
||||
$req = $this->get('/login?prevent_auto_init=true');
|
||||
$req->assertDontSeeText('Attempting Login');
|
||||
$req->assertSee('Log In');
|
||||
}
|
||||
|
||||
public function test_logout_with_auto_init_leads_to_login_page_with_prevention_query()
|
||||
{
|
||||
config()->set([
|
||||
'auth.method' => 'oidc',
|
||||
]);
|
||||
$this->actingAs($this->getEditor());
|
||||
|
||||
$req = $this->post('/logout');
|
||||
$req->assertRedirect('/login?prevent_auto_init=true');
|
||||
}
|
||||
|
||||
}
|
@@ -26,7 +26,6 @@ class OidcTest extends TestCase
|
||||
|
||||
config()->set([
|
||||
'auth.method' => 'oidc',
|
||||
'auth.auto_redirect' => false,
|
||||
'auth.defaults.guard' => 'oidc',
|
||||
'oidc.name' => 'SingleSignOn-Testing',
|
||||
'oidc.display_name_claims' => ['name'],
|
||||
@@ -112,19 +111,6 @@ class OidcTest extends TestCase
|
||||
$this->assertPermissionError($resp);
|
||||
}
|
||||
|
||||
public function test_automatic_redirect_on_login()
|
||||
{
|
||||
config()->set([
|
||||
'auth.auto_redirect' => true,
|
||||
'services.google.client_id' => false,
|
||||
'services.github.client_id' => false,
|
||||
]);
|
||||
$req = $this->get('/login');
|
||||
$req->assertSeeText('SingleSignOn-Testing');
|
||||
$req->assertElementExists('form[action$="/oidc/login"][method=POST] button');
|
||||
$req->assertElementExists('div#loginredirect-wrapper');
|
||||
}
|
||||
|
||||
public function test_login()
|
||||
{
|
||||
$req = $this->post('/oidc/login');
|
||||
|
Reference in New Issue
Block a user