aboutsummaryrefslogtreecommitdiffstats
path: root/tests/crypto
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-06-27 14:29:23 +0200
committerMarc Alexander <admin@m-a-styles.de>2013-09-14 13:54:06 +0200
commit6f33ca85a23a53a7c50d2cfb44a60da9b0b4d02f (patch)
treea4ba6129905c0c02a2a38de73048574eb24a33e5 /tests/crypto
parentdc76146cefd6fd26f2325bb86b17e1266bc2ccc0 (diff)
downloadforums-6f33ca85a23a53a7c50d2cfb44a60da9b0b4d02f.tar
forums-6f33ca85a23a53a7c50d2cfb44a60da9b0b4d02f.tar.gz
forums-6f33ca85a23a53a7c50d2cfb44a60da9b0b4d02f.tar.bz2
forums-6f33ca85a23a53a7c50d2cfb44a60da9b0b4d02f.tar.xz
forums-6f33ca85a23a53a7c50d2cfb44a60da9b0b4d02f.zip
[feature/passwords] Add tests for combined hashing of passwords
PHPBB3-11610
Diffstat (limited to 'tests/crypto')
-rw-r--r--tests/crypto/manager_test.php41
1 files changed, 39 insertions, 2 deletions
diff --git a/tests/crypto/manager_test.php b/tests/crypto/manager_test.php
index 36ea277602..d0ca96e324 100644
--- a/tests/crypto/manager_test.php
+++ b/tests/crypto/manager_test.php
@@ -110,8 +110,8 @@ class phpbb_crypto_manager_test extends PHPUnit_Framework_TestCase
$test_word = $password;
$time = microtime(true);
- // Limit each test to 3 seconds
- while ((microtime(true) - $time) < 3)
+ // Limit each test to 1 second
+ while ((microtime(true) - $time) < 1)
{
$this->assertEquals($test_word === $password, $this->manager->check_hash($test_word, $hash));
$test_word = str_shuffle($test_word);
@@ -125,4 +125,41 @@ class phpbb_crypto_manager_test extends PHPUnit_Framework_TestCase
$this->assertEquals(false, $driver->hash('foobar', 'foobar'));
}
}
+
+ public function test_combined_hash_data()
+ {
+ return array(
+ array(
+ 'crypto.driver.salted_md5',
+ array('crypto.driver.bcrypt_2y', 'crypto.driver.bcrypt'),
+ ),
+ array(
+ 'crypto.driver.salted_md5',
+ array('crypto.driver.bcrypt'),
+ ),
+ array(
+ 'crypto.driver.phpass',
+ array('crypto.driver.salted_md5'),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider test_combined_hash_data
+ */
+ public function test_combined_hash_password($first_type, $second_type)
+ {
+ $password = 'foobar';
+ $test_word = $password;
+ $hash = $this->manager->hash_password($password, $first_type);
+ $combined_hash = $this->manager->hash_password($hash, $second_type);
+
+ $time = microtime(true);
+ // Limit each test to 1 second
+ while ((microtime(true) - $time) < 1)
+ {
+ $this->assertEquals(($test_word === $password), $this->manager->check_hash($test_word, $combined_hash));
+ $test_word = str_shuffle($test_word);
+ }
+ }
}