the whole shebang
This commit is contained in:
26
vendor/ircmaxell/password-compat/test/Unit/PasswordGetInfoTest.php
vendored
Normal file
26
vendor/ircmaxell/password-compat/test/Unit/PasswordGetInfoTest.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
class PasswordGetInfoTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public static function provideInfo() {
|
||||
return array(
|
||||
array('foo', array('algo' => 0, 'algoName' => 'unknown', 'options' => array())),
|
||||
array('$2y$', array('algo' => 0, 'algoName' => 'unknown', 'options' => array())),
|
||||
array('$2y$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', array('algo' => PASSWORD_BCRYPT, 'algoName' => 'bcrypt', 'options' => array('cost' => 7))),
|
||||
array('$2y$10$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', array('algo' => PASSWORD_BCRYPT, 'algoName' => 'bcrypt', 'options' => array('cost' => 10))),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
public function testFuncExists() {
|
||||
$this->assertTrue(function_exists('password_get_info'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInfo
|
||||
*/
|
||||
public function testInfo($hash, $info) {
|
||||
$this->assertEquals($info, password_get_info($hash));
|
||||
}
|
||||
|
||||
}
|
84
vendor/ircmaxell/password-compat/test/Unit/PasswordHashTest.php
vendored
Normal file
84
vendor/ircmaxell/password-compat/test/Unit/PasswordHashTest.php
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
class PasswordHashTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testFuncExists() {
|
||||
$this->assertTrue(function_exists('password_hash'));
|
||||
}
|
||||
|
||||
public function testStringLength() {
|
||||
$this->assertEquals(60, strlen(password_hash('foo', PASSWORD_BCRYPT)));
|
||||
}
|
||||
|
||||
public function testHash() {
|
||||
$hash = password_hash('foo', PASSWORD_BCRYPT);
|
||||
$this->assertEquals($hash, crypt('foo', $hash));
|
||||
}
|
||||
|
||||
public function testKnownSalt() {
|
||||
$hash = password_hash("rasmuslerdorf", PASSWORD_BCRYPT, array("cost" => 7, "salt" => "usesomesillystringforsalt"));
|
||||
$this->assertEquals('$2y$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', $hash);
|
||||
}
|
||||
|
||||
public function testRawSalt() {
|
||||
$hash = password_hash("test", PASSWORD_BCRYPT, array("salt" => "123456789012345678901" . chr(0)));
|
||||
$this->assertEquals('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', $hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testInvalidAlgo() {
|
||||
password_hash('foo', array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testInvalidAlgo2() {
|
||||
password_hash('foo', 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testInvalidPassword() {
|
||||
password_hash(array(), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testInvalidSalt() {
|
||||
password_hash('foo', PASSWORD_BCRYPT, array('salt' => array()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testInvalidBcryptCostLow() {
|
||||
password_hash('foo', PASSWORD_BCRYPT, array('cost' => 3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testInvalidBcryptCostHigh() {
|
||||
password_hash('foo', PASSWORD_BCRYPT, array('cost' => 32));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testInvalidBcryptCostInvalid() {
|
||||
password_hash('foo', PASSWORD_BCRYPT, array('cost' => 'foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testInvalidBcryptSaltShort() {
|
||||
password_hash('foo', PASSWORD_BCRYPT, array('salt' => 'abc'));
|
||||
}
|
||||
|
||||
}
|
26
vendor/ircmaxell/password-compat/test/Unit/PasswordNeedsRehashTest.php
vendored
Normal file
26
vendor/ircmaxell/password-compat/test/Unit/PasswordNeedsRehashTest.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
class PasswordNeedsRehashTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public static function provideCases() {
|
||||
return array(
|
||||
array('foo', 0, array(), false),
|
||||
array('foo', 1, array(), true),
|
||||
array('$2y$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', PASSWORD_BCRYPT, array(), true),
|
||||
array('$2y$07$usesomesillystringfore2udlvp1ii2e./u9c8sbjqp8i90dh6hi', PASSWORD_BCRYPT, array('cost' => 7), false),
|
||||
array('$2y$07$usesomesillystringfore2udlvp1ii2e./u9c8sbjqp8i90dh6hi', PASSWORD_BCRYPT, array('cost' => 5), true),
|
||||
);
|
||||
}
|
||||
|
||||
public function testFuncExists() {
|
||||
$this->assertTrue(function_exists('password_needs_rehash'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideCases
|
||||
*/
|
||||
public function testCases($hash, $algo, $options, $valid) {
|
||||
$this->assertEquals($valid, password_needs_rehash($hash, $algo, $options));
|
||||
}
|
||||
|
||||
}
|
29
vendor/ircmaxell/password-compat/test/Unit/PasswordVerifyTest.php
vendored
Normal file
29
vendor/ircmaxell/password-compat/test/Unit/PasswordVerifyTest.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class PasswordVerifyTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testFuncExists() {
|
||||
$this->assertTrue(function_exists('password_verify'));
|
||||
}
|
||||
|
||||
public function testFailedType() {
|
||||
$this->assertFalse(password_verify(123, 123));
|
||||
}
|
||||
|
||||
public function testSaltOnly() {
|
||||
$this->assertFalse(password_verify('foo', '$2a$07$usesomesillystringforsalt$'));
|
||||
}
|
||||
|
||||
public function testInvalidPassword() {
|
||||
$this->assertFalse(password_verify('rasmusler', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi'));
|
||||
}
|
||||
|
||||
public function testValidPassword() {
|
||||
$this->assertTrue(password_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi'));
|
||||
}
|
||||
|
||||
public function testInValidHash() {
|
||||
$this->assertFalse(password_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hj'));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user