Update tests to pass in CWP kitchen sink context

This commit is contained in:
Robbie Averill 2018-12-02 23:04:34 +00:00
parent 41dc9229bf
commit 1ac36611a6
6 changed files with 37 additions and 10 deletions

View File

@ -19,7 +19,9 @@ class ConfirmedPasswordFieldTest extends SapphireTest
{
parent::setUp();
PasswordValidator::singleton()->setMinLength(0);
PasswordValidator::singleton()
->setMinLength(0)
->setTestNames([]);
}
public function testSetValue()

View File

@ -18,6 +18,7 @@ use SilverStripe\Security\MemberAuthenticator\CMSMemberAuthenticator;
use SilverStripe\Security\MemberAuthenticator\CMSMemberLoginForm;
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
use SilverStripe\Security\MemberAuthenticator\MemberLoginForm;
use SilverStripe\Security\PasswordValidator;
use SilverStripe\Security\Security;
/**
@ -44,6 +45,10 @@ class MemberAuthenticatorTest extends SapphireTest
$this->defaultPassword = null;
}
DefaultAdminService::setDefaultAdmin('admin', 'password');
PasswordValidator::singleton()
->setMinLength(0)
->setTestNames([]);
}
protected function tearDown()

View File

@ -6,6 +6,7 @@ use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Group;
use SilverStripe\Security\MemberCsvBulkLoader;
use SilverStripe\Security\Member;
use SilverStripe\Security\PasswordValidator;
use SilverStripe\Security\Security;
use SilverStripe\Dev\SapphireTest;
@ -13,6 +14,15 @@ class MemberCsvBulkLoaderTest extends SapphireTest
{
protected static $fixture_file = 'MemberCsvBulkLoaderTest.yml';
protected function setUp()
{
parent::setUp();
PasswordValidator::singleton()
->setMinLength(0)
->setTestNames([]);
}
public function testNewImport()
{
$loader = new MemberCsvBulkLoader();

View File

@ -57,7 +57,9 @@ class MemberTest extends FunctionalTest
Member::config()->set('unique_identifier_field', 'Email');
PasswordValidator::singleton()->setMinLength(0);
PasswordValidator::singleton()
->setMinLength(0)
->setTestNames([]);
i18n::set_locale('en_US');
}

View File

@ -18,10 +18,10 @@ class PasswordValidatorTest extends SapphireTest
{
parent::setUp();
// Unset framework default values
PasswordValidator::config()
->remove('min_length')
->remove('historic_count');
->remove('historic_count')
->set('min_test_score', 0);
}
public function testValidate()

View File

@ -21,6 +21,7 @@ use SilverStripe\ORM\ValidationResult;
use SilverStripe\Security\LoginAttempt;
use SilverStripe\Security\Member;
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
use SilverStripe\Security\PasswordValidator;
use SilverStripe\Security\Security;
use SilverStripe\Security\SecurityToken;
@ -51,6 +52,13 @@ class SecurityTest extends FunctionalTest
*/
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();
Director::config()->set('alternate_base_url', '/');
@ -388,7 +396,7 @@ class SecurityTest extends FunctionalTest
// Test external redirection on ChangePasswordForm
$this->get('Security/changepassword?BackURL=http://myspoofedhost.com');
$changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword');
$changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword#123');
$this->assertNotRegExp(
'/^' . preg_quote('http://myspoofedhost.com', '/') . '/',
(string)$changedResponse->getHeader('Location'),
@ -435,7 +443,7 @@ class SecurityTest extends FunctionalTest
// Make sure it redirects correctly after the password has been changed
$this->mainSession->followRedirection();
$changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword');
$changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword#123');
$this->assertEquals(302, $changedResponse->getStatusCode());
$this->assertEquals(
Controller::join_links(Director::absoluteBaseURL(), 'test/link'),
@ -449,7 +457,7 @@ class SecurityTest extends FunctionalTest
// Change the password
$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(
Controller::join_links(Director::absoluteBaseURL(), 'test/back'),
@ -459,7 +467,7 @@ class SecurityTest extends FunctionalTest
// Check if we can login with the new password
$this->logOut();
$goodResponse = $this->doTestLoginForm('testuser@example.com', 'changedPassword');
$goodResponse = $this->doTestLoginForm('testuser@example.com', 'changedPassword#123');
$this->assertEquals(302, $goodResponse->getStatusCode());
$this->assertEquals(
Controller::join_links(Director::absoluteBaseURL(), 'test/link'),
@ -501,12 +509,12 @@ class SecurityTest extends FunctionalTest
// Follow redirection to form without hash in GET parameter
$this->get('Security/changepassword');
$this->doTestChangepasswordForm('1nitialPassword', 'changedPassword');
$this->doTestChangepasswordForm('1nitialPassword', 'changedPassword#123');
$this->assertEquals($this->idFromFixture(Member::class, 'test'), $this->session()->get('loggedInAs'));
// Check if we can login with the new password
$this->logOut();
$goodResponse = $this->doTestLoginForm('testuser@example.com', 'changedPassword');
$goodResponse = $this->doTestLoginForm('testuser@example.com', 'changedPassword#123');
$this->assertEquals(302, $goodResponse->getStatusCode());
$this->assertEquals($this->idFromFixture(Member::class, 'test'), $this->session()->get('loggedInAs'));