MINOR Fixed unit tests after change Member->checkPassword() to return ValidationResult instead of boolean (see r98268) (merged from r98274)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@99701 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-02-23 04:05:34 +00:00
parent 41c04fe61b
commit 61e27830c6
5 changed files with 14 additions and 8 deletions

View File

@ -42,7 +42,7 @@ class MemberAuthenticator extends Authenticator {
"Member", "Member",
"\"Email\" = '$SQL_user' AND \"Password\" IS NOT NULL" "\"Email\" = '$SQL_user' AND \"Password\" IS NOT NULL"
); );
$result = $member->checkPassword($RAW_data['Password']); $result = ($member) ? $member->checkPassword($RAW_data['Password']) : false;
if($member && !$result->valid()) { if($member && !$result->valid()) {
$member->registerFailedLogin(); $member->registerFailedLogin();

View File

@ -22,7 +22,8 @@ class MemberAuthenticatorTest extends SapphireTest {
$member = DataObject::get_by_id('Member', $member->ID); $member = DataObject::get_by_id('Member', $member->ID);
$this->assertEquals($member->PasswordEncryption, "sha1_v2.4"); $this->assertEquals($member->PasswordEncryption, "sha1_v2.4");
$this->assertTrue($member->checkPassword('mypassword')); $result = $member->checkPassword('mypassword');
$this->assertTrue($result->valid());
} }
function testNoLegacyPasswordHashMigrationOnIncompatibleAlgorithm() { function testNoLegacyPasswordHashMigrationOnIncompatibleAlgorithm() {
@ -42,6 +43,7 @@ class MemberAuthenticatorTest extends SapphireTest {
$member = DataObject::get_by_id('Member', $member->ID); $member = DataObject::get_by_id('Member', $member->ID);
$this->assertEquals($member->PasswordEncryption, "crc32"); $this->assertEquals($member->PasswordEncryption, "crc32");
$this->assertTrue($member->checkPassword('mypassword')); $result = $member->checkPassword('mypassword');
$this->assertTrue($result->valid());
} }
} }

View File

@ -38,14 +38,16 @@ class MemberTest extends FunctionalTest {
$member->PasswordEncryption, $member->PasswordEncryption,
'sha1_v2.4' 'sha1_v2.4'
); );
$this->assertTrue($member->checkPassword("mynewpassword")); $result = $member->checkPassword('mynewpassword');
$this->assertTrue($result->valid());
} }
function testSetPassword() { function testSetPassword() {
$member = $this->objFromFixture('Member', 'test'); $member = $this->objFromFixture('Member', 'test');
$member->Password = "test1"; $member->Password = "test1";
$member->write(); $member->write();
$this->assertTrue($member->checkPassword("test1")); $result = $member->checkPassword('test1');
$this->assertTrue($result->valid());
} }
/** /**

View File

@ -154,7 +154,7 @@ class SecurityTest extends FunctionalTest {
/* THE FIRST 4 TIMES, THE MEMBER SHOULDN'T BE LOCKED OUT */ /* THE FIRST 4 TIMES, THE MEMBER SHOULDN'T BE LOCKED OUT */
if($i < 5) { if($i < 5) {
$this->assertNull($member->LockedOutUntil); $this->assertNull($member->LockedOutUntil);
$this->assertTrue(false !== stripos($this->loginErrorMessage(), _t('Member.ERRORWRONGCRED'))); $this->assertContains($this->loginErrorMessage(), _t('Member.ERRORWRONGCRED'));
} }
/* AFTER THAT THE USER IS LOCKED OUT FOR 15 MINUTES */ /* AFTER THAT THE USER IS LOCKED OUT FOR 15 MINUTES */
@ -165,7 +165,8 @@ class SecurityTest extends FunctionalTest {
} }
if($i > 5) { if($i > 5) {
$this->assertTrue(false !== stripos($this->loginErrorMessage(), _t('Member.ERRORLOCKEDOUT'))); $this->assertContains(_t('Member.ERRORLOCKEDOUT'), $this->loginErrorMessage());
// $this->assertTrue(false !== stripos($this->loginErrorMessage(), _t('Member.ERRORLOCKEDOUT')));
} }
} }

View File

@ -16,6 +16,7 @@ class EncryptAllPasswordsTaskTest extends SapphireTest {
$m = DataObject::get_by_id('Member', $m->ID); $m = DataObject::get_by_id('Member', $m->ID);
$this->assertEquals($m->PasswordEncryption, 'sha1_v2.4'); $this->assertEquals($m->PasswordEncryption, 'sha1_v2.4');
$this->assertNotEquals($m->Password, 'plain'); $this->assertNotEquals($m->Password, 'plain');
$this->assertTrue($m->checkPassword('plain')); $result = $m->checkPassword('plain');
$this->assertTrue($result->valid());
} }
} }