Move all functionality of old Password class to new Password class

This commit is contained in:
Kijin Sung 2016-03-13 23:23:48 +09:00
parent 642f048f64
commit f4dc7e6b21
3 changed files with 73 additions and 316 deletions

View file

@ -27,9 +27,9 @@ class PasswordTest extends \Codeception\TestCase\Test
$this->assertTrue($algo === 'bcrypt' || $algo === 'pbkdf2');
}
public function testGetSelectedAlgorithm()
public function testGetDefaultAlgorithm()
{
$algo = Rhymix\Framework\Password::getSelectedAlgorithm();
$algo = Rhymix\Framework\Password::getDefaultAlgorithm();
$this->assertTrue($algo === 'bcrypt' || $algo === 'pbkdf2' || $algo === 'md5');
}
@ -40,6 +40,16 @@ class PasswordTest extends \Codeception\TestCase\Test
$this->assertTrue($work_factor <= 31);
}
public function testGetRandomPassword()
{
$password = Rhymix\Framework\Password::getRandomPassword(16);
$this->assertEquals(16, strlen($password));
$this->assertRegexp('/[a-z]/', $password);
$this->assertRegexp('/[A-Z]/', $password);
$this->assertRegexp('/[0-9]/', $password);
$this->assertRegexp('/[^a-zA-Z0-9]/', $password);
}
public function testHashPassword()
{
$password = Rhymix\Framework\Security::getRandom(32);