Skip to content

Commit

Permalink
MINOR: Don't leave cost=31 blowfish setting dormant in code, causing …
Browse files Browse the repository at this point in the history
…timeouts.
  • Loading branch information
Sam Minnee committed Jun 15, 2012
1 parent a1e7c1f commit 09e821e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions tests/security/PasswordEncryptorTest.php
Expand Up @@ -15,6 +15,7 @@ public function setUp() {
public function tearDown() {
parent::tearDown();
Config::set_instance($this->config);
PasswordEncryptor_Blowfish::set_cost(10);
}

function testCreateForCode() {
Expand Down Expand Up @@ -86,12 +87,12 @@ function testEncryptorBlowfish() {
$this->assertFalse($e->check($e->encrypt($password, $salt), "anotherpw", $salt));
$this->assertFalse($e->check($e->encrypt($password, $salt), "mypassword", $modSalt));

PasswordEncryptor_Blowfish::set_cost(15);
PasswordEncryptor_Blowfish::set_cost(11);
$salt = $e->salt($password);
$modSalt = substr($salt, 0, 3) . str_shuffle(substr($salt, 3, strlen($salt)));

$this->assertEquals(15, PasswordEncryptor_Blowfish::get_cost());

$this->assertEquals(11, PasswordEncryptor_Blowfish::get_cost());
$this->assertTrue($e->check($e->encrypt($password, $salt), "mypassword", $salt));
$this->assertFalse($e->check($e->encrypt($password, $salt), "anotherpw", $salt));
$this->assertFalse($e->check($e->encrypt($password, $salt), "mypassword", $modSalt));
Expand All @@ -103,10 +104,6 @@ function testEncryptorBlowfish() {
$this->assertEquals(31, PasswordEncryptor_Blowfish::get_cost());

//Don't actually test this one. It takes too long. 31 takes too long to process
// $salt = $e->salt($password);
// $this->assertTrue($e->check($e->encrypt($password, $salt), "mypassword", $salt));
// $this->assertFalse($e->check($e->encrypt($password, $salt), "anotherpw", $salt));

}

function testEncryptorPHPHashCheck() {
Expand Down

0 comments on commit 09e821e

Please sign in to comment.