mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
TEST Add historical password count test
This commit is contained in:
parent
8bc7cae1e2
commit
e8b959864e
@ -8,6 +8,11 @@ use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
class PasswordValidatorTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @var bool
|
||||
*/
|
||||
protected $usesDatabase = true;
|
||||
|
||||
public function testValidate()
|
||||
{
|
||||
@ -44,8 +49,30 @@ class PasswordValidatorTest extends SapphireTest
|
||||
$this->assertTrue($r->isValid(), 'Passing enough tests');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that a certain number of historical passwords are checked if specified
|
||||
*/
|
||||
public function testHistoricalPasswordCount()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
$validator = new PasswordValidator;
|
||||
$validator->checkHistoricalPasswords(3);
|
||||
Member::set_password_validator($validator);
|
||||
|
||||
$member = new Member;
|
||||
$member->FirstName = 'Repeat';
|
||||
$member->Surname = 'Password-Man';
|
||||
$member->Password = 'honk';
|
||||
$member->write();
|
||||
|
||||
// Create a set of used passwords
|
||||
$member->changePassword('foobar');
|
||||
$member->changePassword('foobaz');
|
||||
$member->changePassword('barbaz');
|
||||
|
||||
$this->assertFalse($member->changePassword('barbaz')->isValid());
|
||||
$this->assertFalse($member->changePassword('foobaz')->isValid());
|
||||
$this->assertFalse($member->changePassword('foobar')->isValid());
|
||||
$this->assertTrue($member->changePassword('honk')->isValid());
|
||||
$this->assertTrue($member->changePassword('newpassword')->isValid());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user