diff options
author | Marc Alexander <admin@m-a-styles.de> | 2016-08-09 21:07:49 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2016-10-03 22:09:07 +0200 |
commit | 1d40c0f43b366638de16a99a874ce1475249ade0 (patch) | |
tree | 4342364241a0eba7660784b8a89c2b64380b1a4c /tests/passwords/drivers_test.php | |
parent | 7bb4e88acdb0f45f8bfbad74b558db65524cbe1a (diff) | |
download | forums-1d40c0f43b366638de16a99a874ce1475249ade0.tar forums-1d40c0f43b366638de16a99a874ce1475249ade0.tar.gz forums-1d40c0f43b366638de16a99a874ce1475249ade0.tar.bz2 forums-1d40c0f43b366638de16a99a874ce1475249ade0.tar.xz forums-1d40c0f43b366638de16a99a874ce1475249ade0.zip |
[ticket/14733] Support increasing hashing cost factor
PHPBB3-14733
Diffstat (limited to 'tests/passwords/drivers_test.php')
-rw-r--r-- | tests/passwords/drivers_test.php | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 5f9fd523c9..01c69a38bb 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -23,8 +23,8 @@ class phpbb_passwords_helper_test extends \phpbb_test_case $php_ext = 'php'; $this->passwords_drivers = array( - 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $this->driver_helper), - 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $this->driver_helper), + 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $this->driver_helper, 10), + 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $this->driver_helper, 10), 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $this->driver_helper), 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $this->driver_helper), 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), @@ -413,4 +413,23 @@ class phpbb_passwords_helper_test extends \phpbb_test_case ); return strtr($string, $transform); } + + public function data_needs_rehash() + { + return array( + array('passwords.driver.bcrypt_2y', '$2y$10$somerandomhash', false), + array('passwords.driver.bcrypt', '$2a$10$somerandomhash', false), + array('passwords.driver.salted_md5', 'foobar', false), + array('passwords.driver.bcrypt_2y', '$2y$9$somerandomhash', true), + array('passwords.driver.bcrypt', '$2a$04$somerandomhash', true), + ); + } + + /** + * @dataProvider data_needs_rehash + */ + public function test_needs_rehash($driver, $hash, $expected) + { + $this->assertSame($this->passwords_drivers[$driver]->needs_rehash($hash), $expected); + } } |