Permalink
Browse files

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
  • Loading branch information...
1 parent 41c04fe commit 61e27830c69384054b929c2d1cf41ebba104c7f0 @chillu chillu committed Feb 23, 2010
@@ -42,7 +42,7 @@ public static function authenticate($RAW_data, Form $form = null) {
"Member",
"\"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()) {
$member->registerFailedLogin();
@@ -22,7 +22,8 @@ function testLegacyPasswordHashMigrationUponLogin() {
$member = DataObject::get_by_id('Member', $member->ID);
$this->assertEquals($member->PasswordEncryption, "sha1_v2.4");
- $this->assertTrue($member->checkPassword('mypassword'));
+ $result = $member->checkPassword('mypassword');
+ $this->assertTrue($result->valid());
}
function testNoLegacyPasswordHashMigrationOnIncompatibleAlgorithm() {
@@ -42,6 +43,7 @@ function testNoLegacyPasswordHashMigrationOnIncompatibleAlgorithm() {
$member = DataObject::get_by_id('Member', $member->ID);
$this->assertEquals($member->PasswordEncryption, "crc32");
- $this->assertTrue($member->checkPassword('mypassword'));
+ $result = $member->checkPassword('mypassword');
+ $this->assertTrue($result->valid());
}
}
@@ -38,14 +38,16 @@ function testDefaultPasswordEncryptionDoesntChangeExistingMembers() {
$member->PasswordEncryption,
'sha1_v2.4'
);
- $this->assertTrue($member->checkPassword("mynewpassword"));
+ $result = $member->checkPassword('mynewpassword');
+ $this->assertTrue($result->valid());
}
function testSetPassword() {
$member = $this->objFromFixture('Member', 'test');
$member->Password = "test1";
$member->write();
- $this->assertTrue($member->checkPassword("test1"));
+ $result = $member->checkPassword('test1');
+ $this->assertTrue($result->valid());
}
/**
@@ -154,7 +154,7 @@ function testRepeatedLoginAttemptsLockingPeopleOut() {
/* THE FIRST 4 TIMES, THE MEMBER SHOULDN'T BE LOCKED OUT */
if($i < 5) {
$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 */
@@ -165,7 +165,8 @@ function testRepeatedLoginAttemptsLockingPeopleOut() {
}
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')));
}
}
@@ -16,6 +16,7 @@ function testRun() {
$m = DataObject::get_by_id('Member', $m->ID);
$this->assertEquals($m->PasswordEncryption, 'sha1_v2.4');
$this->assertNotEquals($m->Password, 'plain');
- $this->assertTrue($m->checkPassword('plain'));
+ $result = $m->checkPassword('plain');
+ $this->assertTrue($result->valid());
}
}

0 comments on commit 61e2783

Please sign in to comment.