diff options
author | Marc Alexander <admin@m-a-styles.de> | 2013-10-09 22:53:13 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2013-10-09 22:53:13 +0200 |
commit | cd74fb094629cf07209b4fa13ebf0ddf5b4ce47c (patch) | |
tree | 343dbdf6fdd3e87788e10479e88cf19f584cd6e3 /tests/passwords/manager_test.php | |
parent | 3b6038cfcd6e00aaf8e9b5f68f2a925c9a85da51 (diff) | |
download | forums-cd74fb094629cf07209b4fa13ebf0ddf5b4ce47c.tar forums-cd74fb094629cf07209b4fa13ebf0ddf5b4ce47c.tar.gz forums-cd74fb094629cf07209b4fa13ebf0ddf5b4ce47c.tar.bz2 forums-cd74fb094629cf07209b4fa13ebf0ddf5b4ce47c.tar.xz forums-cd74fb094629cf07209b4fa13ebf0ddf5b4ce47c.zip |
[feature/passwords] Increase test coverage to 35 out ouf 36 methods
Only one small code part in the salted md5 driver can't be tested right now.
Passwords helper and passwords driver helper are now fully covered by tests.
PHPBB3-11610
Diffstat (limited to 'tests/passwords/manager_test.php')
-rw-r--r-- | tests/passwords/manager_test.php | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index 4ad5b439d6..568c53be3f 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -7,8 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../mock/container_builder.php'; - class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase { protected $passwords_drivers; @@ -19,11 +17,6 @@ class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase public function setUp() { - global $phpbb_root_path, $phpEx; - - // Mock phpbb_container - $this->phpbb_container = new phpbb_mock_container_builder; - // Prepare dependencies for manager and driver $config = new \phpbb\config\config(array()); $this->driver_helper = new \phpbb\passwords\driver\helper($config); @@ -38,7 +31,6 @@ class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase foreach ($this->passwords_drivers as $key => $driver) { $driver->set_name($key); - $this->phpbb_container->set($key, $driver); } $this->helper = new \phpbb\passwords\helper; @@ -218,6 +210,11 @@ class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase array('passwords.driver.salted_md5'), false, ), + array( + 'passwords.driver.bcrypt_2y', + array('passwords.driver.salted_md4'), + false, + ), ); } } @@ -257,4 +254,20 @@ class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase $this->assertNotEquals($first_id, $this->driver_helper->unique_id()); } } + + public function test_check_hash_with_large_input() + { + // 16 MB password, should be rejected quite fast + $start_time = time(); + $this->assertFalse($this->manager->check(str_repeat('a', 1024 * 1024 * 16), '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1')); + $this->assertLessThanOrEqual(5, time() - $start_time); + } + + public function test_hash_password_with_large_input() + { + // 16 MB password, should be rejected quite fast + $start_time = time(); + $this->assertFalse($this->manager->hash(str_repeat('a', 1024 * 1024 * 16))); + $this->assertLessThanOrEqual(5, time() - $start_time); + } } |