mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #8654 from creative-commoners/pulls/4.3/password-complexity-test-fixes
Update tests to pass in CWP kitchen sink context
This commit is contained in:
commit
7d1aa44786
@ -19,7 +19,9 @@ class ConfirmedPasswordFieldTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
PasswordValidator::singleton()->setMinLength(0);
|
PasswordValidator::singleton()
|
||||||
|
->setMinLength(0)
|
||||||
|
->setTestNames([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetValue()
|
public function testSetValue()
|
||||||
|
@ -18,6 +18,7 @@ use SilverStripe\Security\MemberAuthenticator\CMSMemberAuthenticator;
|
|||||||
use SilverStripe\Security\MemberAuthenticator\CMSMemberLoginForm;
|
use SilverStripe\Security\MemberAuthenticator\CMSMemberLoginForm;
|
||||||
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
|
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
|
||||||
use SilverStripe\Security\MemberAuthenticator\MemberLoginForm;
|
use SilverStripe\Security\MemberAuthenticator\MemberLoginForm;
|
||||||
|
use SilverStripe\Security\PasswordValidator;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,6 +45,10 @@ class MemberAuthenticatorTest extends SapphireTest
|
|||||||
$this->defaultPassword = null;
|
$this->defaultPassword = null;
|
||||||
}
|
}
|
||||||
DefaultAdminService::setDefaultAdmin('admin', 'password');
|
DefaultAdminService::setDefaultAdmin('admin', 'password');
|
||||||
|
|
||||||
|
PasswordValidator::singleton()
|
||||||
|
->setMinLength(0)
|
||||||
|
->setTestNames([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
|
@ -6,6 +6,7 @@ use SilverStripe\ORM\DataObject;
|
|||||||
use SilverStripe\Security\Group;
|
use SilverStripe\Security\Group;
|
||||||
use SilverStripe\Security\MemberCsvBulkLoader;
|
use SilverStripe\Security\MemberCsvBulkLoader;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\PasswordValidator;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
|
||||||
@ -13,6 +14,15 @@ class MemberCsvBulkLoaderTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
protected static $fixture_file = 'MemberCsvBulkLoaderTest.yml';
|
protected static $fixture_file = 'MemberCsvBulkLoaderTest.yml';
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
PasswordValidator::singleton()
|
||||||
|
->setMinLength(0)
|
||||||
|
->setTestNames([]);
|
||||||
|
}
|
||||||
|
|
||||||
public function testNewImport()
|
public function testNewImport()
|
||||||
{
|
{
|
||||||
$loader = new MemberCsvBulkLoader();
|
$loader = new MemberCsvBulkLoader();
|
||||||
|
@ -57,7 +57,9 @@ class MemberTest extends FunctionalTest
|
|||||||
|
|
||||||
Member::config()->set('unique_identifier_field', 'Email');
|
Member::config()->set('unique_identifier_field', 'Email');
|
||||||
|
|
||||||
PasswordValidator::singleton()->setMinLength(0);
|
PasswordValidator::singleton()
|
||||||
|
->setMinLength(0)
|
||||||
|
->setTestNames([]);
|
||||||
|
|
||||||
i18n::set_locale('en_US');
|
i18n::set_locale('en_US');
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,10 @@ class PasswordValidatorTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
// Unset framework default values
|
|
||||||
PasswordValidator::config()
|
PasswordValidator::config()
|
||||||
->remove('min_length')
|
->remove('min_length')
|
||||||
->remove('historic_count');
|
->remove('historic_count')
|
||||||
|
->set('min_test_score', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testValidate()
|
public function testValidate()
|
||||||
|
@ -21,6 +21,7 @@ use SilverStripe\ORM\ValidationResult;
|
|||||||
use SilverStripe\Security\LoginAttempt;
|
use SilverStripe\Security\LoginAttempt;
|
||||||
use SilverStripe\Security\Member;
|
use SilverStripe\Security\Member;
|
||||||
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
|
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
|
||||||
|
use SilverStripe\Security\PasswordValidator;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
use SilverStripe\Security\SecurityToken;
|
use SilverStripe\Security\SecurityToken;
|
||||||
|
|
||||||
@ -51,6 +52,13 @@ class SecurityTest extends FunctionalTest
|
|||||||
*/
|
*/
|
||||||
Member::config()->set('unique_identifier_field', 'Email');
|
Member::config()->set('unique_identifier_field', 'Email');
|
||||||
|
|
||||||
|
PasswordValidator::config()
|
||||||
|
->remove('min_length')
|
||||||
|
->remove('historic_count')
|
||||||
|
->remove('min_test_score');
|
||||||
|
|
||||||
|
Member::set_password_validator(null);
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
Director::config()->set('alternate_base_url', '/');
|
Director::config()->set('alternate_base_url', '/');
|
||||||
@ -388,7 +396,7 @@ class SecurityTest extends FunctionalTest
|
|||||||
|
|
||||||
// Test external redirection on ChangePasswordForm
|
// Test external redirection on ChangePasswordForm
|
||||||
$this->get('Security/changepassword?BackURL=http://myspoofedhost.com');
|
$this->get('Security/changepassword?BackURL=http://myspoofedhost.com');
|
||||||
$changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword');
|
$changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword#123');
|
||||||
$this->assertNotRegExp(
|
$this->assertNotRegExp(
|
||||||
'/^' . preg_quote('http://myspoofedhost.com', '/') . '/',
|
'/^' . preg_quote('http://myspoofedhost.com', '/') . '/',
|
||||||
(string)$changedResponse->getHeader('Location'),
|
(string)$changedResponse->getHeader('Location'),
|
||||||
@ -435,7 +443,7 @@ class SecurityTest extends FunctionalTest
|
|||||||
|
|
||||||
// Make sure it redirects correctly after the password has been changed
|
// Make sure it redirects correctly after the password has been changed
|
||||||
$this->mainSession->followRedirection();
|
$this->mainSession->followRedirection();
|
||||||
$changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword');
|
$changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword#123');
|
||||||
$this->assertEquals(302, $changedResponse->getStatusCode());
|
$this->assertEquals(302, $changedResponse->getStatusCode());
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
Controller::join_links(Director::absoluteBaseURL(), 'test/link'),
|
Controller::join_links(Director::absoluteBaseURL(), 'test/link'),
|
||||||
@ -449,7 +457,7 @@ class SecurityTest extends FunctionalTest
|
|||||||
|
|
||||||
// Change the password
|
// Change the password
|
||||||
$this->get('Security/changepassword?BackURL=test/back');
|
$this->get('Security/changepassword?BackURL=test/back');
|
||||||
$changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword');
|
$changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword#123');
|
||||||
$this->assertEquals(302, $changedResponse->getStatusCode());
|
$this->assertEquals(302, $changedResponse->getStatusCode());
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
Controller::join_links(Director::absoluteBaseURL(), 'test/back'),
|
Controller::join_links(Director::absoluteBaseURL(), 'test/back'),
|
||||||
@ -459,7 +467,7 @@ class SecurityTest extends FunctionalTest
|
|||||||
|
|
||||||
// Check if we can login with the new password
|
// Check if we can login with the new password
|
||||||
$this->logOut();
|
$this->logOut();
|
||||||
$goodResponse = $this->doTestLoginForm('testuser@example.com', 'changedPassword');
|
$goodResponse = $this->doTestLoginForm('testuser@example.com', 'changedPassword#123');
|
||||||
$this->assertEquals(302, $goodResponse->getStatusCode());
|
$this->assertEquals(302, $goodResponse->getStatusCode());
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
Controller::join_links(Director::absoluteBaseURL(), 'test/link'),
|
Controller::join_links(Director::absoluteBaseURL(), 'test/link'),
|
||||||
@ -501,12 +509,12 @@ class SecurityTest extends FunctionalTest
|
|||||||
|
|
||||||
// Follow redirection to form without hash in GET parameter
|
// Follow redirection to form without hash in GET parameter
|
||||||
$this->get('Security/changepassword');
|
$this->get('Security/changepassword');
|
||||||
$this->doTestChangepasswordForm('1nitialPassword', 'changedPassword');
|
$this->doTestChangepasswordForm('1nitialPassword', 'changedPassword#123');
|
||||||
$this->assertEquals($this->idFromFixture(Member::class, 'test'), $this->session()->get('loggedInAs'));
|
$this->assertEquals($this->idFromFixture(Member::class, 'test'), $this->session()->get('loggedInAs'));
|
||||||
|
|
||||||
// Check if we can login with the new password
|
// Check if we can login with the new password
|
||||||
$this->logOut();
|
$this->logOut();
|
||||||
$goodResponse = $this->doTestLoginForm('testuser@example.com', 'changedPassword');
|
$goodResponse = $this->doTestLoginForm('testuser@example.com', 'changedPassword#123');
|
||||||
$this->assertEquals(302, $goodResponse->getStatusCode());
|
$this->assertEquals(302, $goodResponse->getStatusCode());
|
||||||
$this->assertEquals($this->idFromFixture(Member::class, 'test'), $this->session()->get('loggedInAs'));
|
$this->assertEquals($this->idFromFixture(Member::class, 'test'), $this->session()->get('loggedInAs'));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user