aboutsummaryrefslogtreecommitdiffstats
path: root/tests
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
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')
-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);
+ }
+ }
}
-------------------------------------- r432 | dmorgan | 2011-02-06 01:59:38 +0000 (Sun, 06 Feb 2011) | 1 line Import cleaned advertising ------------------------------------------------------------------------ r446 | dmorgan | 2011-02-06 22:37:08 +0000 (Sun, 06 Feb 2011) | 1 line Import Clean perl-install ------------------------------------------------------------------------ r448 | dmorgan | 2011-02-06 23:02:36 +0000 (Sun, 06 Feb 2011) | 1 line Add cleaned files ------------------------------------------------------------------------ r449 | dmorgan | 2011-02-06 23:03:52 +0000 (Sun, 06 Feb 2011) | 1 line Import cleaned kernel ------------------------------------------------------------------------ r450 | dmorgan | 2011-02-06 23:23:30 +0000 (Sun, 06 Feb 2011) | 1 line Import cleaned tools ------------------------------------------------------------------------ r451 | dmorgan | 2011-02-07 00:01:56 +0000 (Mon, 07 Feb 2011) | 1 line Import stage1 ------------------------------------------------------------------------ r473 | dmorgan | 2011-02-07 11:20:50 +0000 (Mon, 07 Feb 2011) | 1 line Import images ------------------------------------------------------------------------ r497 | ennael | 2011-02-09 21:02:06 +0000 (Wed, 09 Feb 2011) | 2 lines readd missing file ------------------------------------------------------------------------ r502 | pterjan | 2011-02-09 23:30:32 +0000 (Wed, 09 Feb 2011) | 1 line Import rescue ------------------------------------------------------------------------ r603 | ennael | 2011-02-24 13:32:54 +0000 (Thu, 24 Feb 2011) | 2 lines import cleaned rescue for Mageia ------------------------------------------------------------------------ r2061 | tv | 2011-10-20 20:32:19 +0100 (Thu, 20 Oct 2011) | 1 line import (cleaned) doc ------------------------------------------------------------------------
Diffstat (limited to 'perl-install')