From 2ea45a06e724dfe9c3248fbb659d86558b55265e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Apr 2014 21:00:33 +0200 Subject: [ticket/12352] Add legacy passwords driver for sha1 smf type passwords PHPBB3-12352 --- tests/passwords/drivers_test.php | 33 +++++++++++++++++++++++++++++++++ tests/passwords/manager_test.php | 1 + 2 files changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index c2104b0858..5e2518cdea 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -24,6 +24,7 @@ class phpbb_passwords_helper_test extends \phpbb_test_case 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $this->driver_helper), '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), ); } @@ -82,4 +83,36 @@ class phpbb_passwords_helper_test extends \phpbb_test_case ); $this->assertEquals(false, $this->passwords_drivers['passwords.driver.salted_md5']->get_hash_settings(false)); } + + public function data_hash_sha1_smf() + { + return array( + array(false, 'test', array()), + array(false, 'test', ''), + array('6f9e2a1899e1f15708fd2e554103480eb53e8b57', 'foobar', array('login_name' => 'test')), + ); + } + + /** + * @dataProvider data_hash_sha1_smf + */ + public function test_hash_sha1_smf($expected, $password, $user_row) + { + $this->assertSame($expected, $this->passwords_drivers['passwords.driver.sha1_smf']->hash($password, $user_row)); + } + + public function data_get_settings() + { + return array( + array(false, '6f9e2a1899e1f15708fd2e554103480eb53e8b57', 'passwords.driver.sha1_smf'), + ); + } + + /** + * @dataProvider data_get_settings + */ + public function test_get_settings_only($expected, $hash, $driver) + { + $this->assertSame($expected, $this->passwords_drivers[$driver]->get_settings_only($hash)); + } } diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index f9244d59f2..83ae233e3c 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -30,6 +30,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $this->driver_helper), '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), ); $this->helper = new \phpbb\passwords\helper; -- cgit v1.2.1 From ed1d4fe4a03c55bbc997f11afa11a87b4fe78c4d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 1 May 2014 14:23:39 +0200 Subject: [ticket/12352] Revert to db auth provider if default does not exist This will make sure that we will not encounter a non-existing auth provider. We will revert to the default db auth provider if the one set in the config does not exist in our auth provider collection. PHPBB3-12352 --- tests/session/testable_factory.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index 81724cf661..4bd7fa1366 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -96,6 +96,10 @@ class phpbb_session_testable_factory 'auth.provider.db', new phpbb_mock_auth_provider() ); + $phpbb_container->set( + 'auth.provider_collection', + array('auth.provider.db' => $phpbb_container->get('auth.provider.db')) + ); $session = new phpbb_mock_session_testable; return $session; -- cgit v1.2.1 From 57e4fb38106a3ece446b8713693f89c8745538dc Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 1 May 2014 14:25:16 +0200 Subject: [ticket/12352] Add tests for checking smf passwords PHPBB3-12352 --- tests/passwords/manager_test.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index 83ae233e3c..c2fda170a1 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -139,15 +139,18 @@ class phpbb_passwords_manager_test extends \phpbb_test_case array('foobar', '$H$kklk938d023k//k3023', false), array('foobar', '$H$3PtYMgXb39lrIWkgoxYLWtRkZtY3AY/', false), array('foobar', '$2a$kwiweorurlaeirw', false), + array('foobar', '6f9e2a1899e1f15708fd2e554103480eb53e8b57', false), + array('foobar', '6f9e2a1899e1f15708fd2e554103480eb53e8b57', true, array('login_name' => 'test')), + array('foobar', '6f9e2a1899', false, array('login_name' => 'test')), ); } /** * @dataProvider check_hash_exceptions_data */ - public function test_check_hash_exceptions($password, $hash, $expected) + public function test_check_hash_exceptions($password, $hash, $expected, $user_row = array()) { - $this->assertEquals($expected, $this->manager->check($password, $hash)); + $this->assertEquals($expected, $this->manager->check($password, $hash, $user_row)); } public function data_hash_password_length() -- cgit v1.2.1 From 1e758ba7f01fb07c2f497d755837bdce9bd57f18 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 11 May 2014 22:23:23 +0200 Subject: [ticket/12352] Add passwords driver for passwords that should be converted This driver will only be used for getting the new $CP$ prefix that will signal that the hash is a legacy hash that needs to be converted. PHPBB3-12352 --- tests/passwords/manager_test.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index c2fda170a1..d0f860c4c5 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -30,6 +30,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $this->driver_helper), '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.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), ); @@ -134,13 +135,16 @@ class phpbb_passwords_manager_test extends \phpbb_test_case { return array( array('foobar', '3858f62230ac3c915f300c664312c63f', true), + array('foobar', '$CP$3858f62230ac3c915f300c664312c63f', true), + array('foobar', '$CP$3858f62230ac3c915f300c', false), array('foobar', '$S$b57a939fa4f2c04413a4eea9734a0903647b7adb93181295', false), array('foobar', '$2a\S$kkkkaakdkdiej39023903204j2k3490234jk234j02349', false), array('foobar', '$H$kklk938d023k//k3023', false), array('foobar', '$H$3PtYMgXb39lrIWkgoxYLWtRkZtY3AY/', false), array('foobar', '$2a$kwiweorurlaeirw', false), array('foobar', '6f9e2a1899e1f15708fd2e554103480eb53e8b57', false), - array('foobar', '6f9e2a1899e1f15708fd2e554103480eb53e8b57', true, array('login_name' => 'test')), + array('foobar', '6f9e2a1899e1f15708fd2e554103480eb53e8b57', false, array('login_name' => 'test')), + array('foobar', '$CP$6f9e2a1899e1f15708fd2e554103480eb53e8b57', true, array('login_name' => 'test')), array('foobar', '6f9e2a1899', false, array('login_name' => 'test')), ); } -- cgit v1.2.1 From 3508409c89acd53943d7e9d1b32982fd021122f0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 27 May 2014 18:13:06 +0200 Subject: [ticket/12352] Add tests for phpBB2 md5 passwords driver PHPBB3-12352 --- tests/mock/request.php | 19 +++++++++++++++++++ tests/passwords/drivers_test.php | 37 +++++++++++++++++++++++++++++++++++++ tests/passwords/manager_test.php | 7 +++++++ 3 files changed, 63 insertions(+) (limited to 'tests') diff --git a/tests/mock/request.php b/tests/mock/request.php index 89d5321a25..304fcf0eaf 100644 --- a/tests/mock/request.php +++ b/tests/mock/request.php @@ -15,6 +15,8 @@ class phpbb_mock_request implements \phpbb\request\request_interface { protected $data; + protected $super_globals_disabled = false; + public function __construct($get = array(), $post = array(), $cookie = array(), $server = array(), $request = false, $files = array()) { $this->data[\phpbb\request\request_interface::GET] = $get; @@ -23,6 +25,8 @@ class phpbb_mock_request implements \phpbb\request\request_interface $this->data[\phpbb\request\request_interface::REQUEST] = ($request === false) ? $post + $get : $request; $this->data[\phpbb\request\request_interface::SERVER] = $server; $this->data[\phpbb\request\request_interface::FILES] = $files; + + $this->disable_super_globals(); } public function overwrite($var_name, $value, $super_global = \phpbb\request\request_interface::REQUEST) @@ -83,6 +87,21 @@ class phpbb_mock_request implements \phpbb\request\request_interface return $this->data[$super_global]; } + public function super_globals_disabled() + { + return $this->super_globals_disabled; + } + + public function disable_super_globals() + { + $this->super_globals_disabled = true; + } + + public function enable_super_globals() + { + $this->super_globals_disabled = false; + } + /* custom methods */ public function set_header($header_name, $value) diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 5e2518cdea..cff03b02c9 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -17,7 +17,10 @@ class phpbb_passwords_helper_test extends \phpbb_test_case { // Prepare dependencies for drivers $config = new \phpbb\config\config(array()); + $request = new phpbb_mock_request(array(), array(), array(), array(), array('password' => 'fööbar')); $this->driver_helper = new \phpbb\passwords\driver\helper($config); + $phpbb_root_path = dirname(__FILE__) . '/../../phpBB/'; + $php_ext = 'php'; $this->passwords_drivers = array( 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $this->driver_helper), @@ -25,6 +28,7 @@ class phpbb_passwords_helper_test extends \phpbb_test_case '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), + 'passwords.driver.phpbb2_md5' => new \phpbb\passwords\driver\phpbb2_md5($request, $phpbb_root_path, $php_ext), ); } @@ -115,4 +119,37 @@ class phpbb_passwords_helper_test extends \phpbb_test_case { $this->assertSame($expected, $this->passwords_drivers[$driver]->get_settings_only($hash)); } + + public function data_phpbb2_md5_check() + { + return array( + array(false, 'foobar', 'ae2fc75e20ee25d4520766788fbc96ae'), + array(false, 'foobar', 'ae2fc75e20ee25d4520766788fbc96aeddsf'), + array(false, 'fööbar', 'ae2fc75e20ee25d4520766788fbc96ae'), + array(true, 'fööbar', 'ae2fc75e20ee25d4520766788fbc96ae', utf8_decode('fööbar')), + ); + } + + /** + * @dataProvider data_phpbb2_md5_check + */ + public function test_phpbb2_md5_check($expected, $password, $hash, $request_password = false) + { + if (!$request_password) + { + unset($_REQUEST['password']); + } + else + { + $_REQUEST['password'] = $request_password; + } + $this->assertSame($expected, $this->passwords_drivers['passwords.driver.phpbb2_md5']->check($password, $hash)); + } + + public function test_phpbb2_md5_unneeded_functions() + { + $this->assertSame(false, $this->passwords_drivers['passwords.driver.phpbb2_md5']->hash('foobar')); + + $this->assertSame(false, $this->passwords_drivers['passwords.driver.phpbb2_md5']->get_settings_only('ae2fc75e20ee25d4520766788fbc96ae')); + } } diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index d0f860c4c5..e925502f18 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -24,6 +24,9 @@ class phpbb_passwords_manager_test extends \phpbb_test_case // Prepare dependencies for manager and driver $config = new \phpbb\config\config(array()); $this->driver_helper = new \phpbb\passwords\driver\helper($config); + $request = new phpbb_mock_request(array(), array(), array(), array(), array('password' => 'töst')); + $phpbb_root_path = dirname(__FILE__) . '/../../phpBB/'; + $php_ext = 'php'; $this->passwords_drivers = array( 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $this->driver_helper), @@ -32,6 +35,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $this->driver_helper), 'passwords.driver.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), + 'passwords.driver.phpbb2_md5' => new \phpbb\passwords\driver\phpbb2_md5($request, $phpbb_root_path, $php_ext), ); $this->helper = new \phpbb\passwords\helper; @@ -146,6 +150,9 @@ class phpbb_passwords_manager_test extends \phpbb_test_case array('foobar', '6f9e2a1899e1f15708fd2e554103480eb53e8b57', false, array('login_name' => 'test')), array('foobar', '$CP$6f9e2a1899e1f15708fd2e554103480eb53e8b57', true, array('login_name' => 'test')), array('foobar', '6f9e2a1899', false, array('login_name' => 'test')), + array('fööbar', 'ae2fc75e20ee25d4520766788fbc96ae', false), + array('fööbar', '$CP$ae2fc75e20ee25d4520766788fbc96ae', false), + array(utf8_decode('fööbar'), '$CP$ae2fc75e20ee25d4520766788fbc96ae', true), ); } -- cgit v1.2.1 From b35ed3bc69ac0cdd63791d89f1941b1bb8c69c0b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 27 May 2014 18:26:51 +0200 Subject: [ticket/12352] Add tests for functions in convert password driver PHPBB3-12352 --- tests/passwords/drivers_test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index cff03b02c9..70a320f4bd 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -28,6 +28,7 @@ class phpbb_passwords_helper_test extends \phpbb_test_case '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), + 'passwords.driver.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), 'passwords.driver.phpbb2_md5' => new \phpbb\passwords\driver\phpbb2_md5($request, $phpbb_root_path, $php_ext), ); } @@ -152,4 +153,11 @@ class phpbb_passwords_helper_test extends \phpbb_test_case $this->assertSame(false, $this->passwords_drivers['passwords.driver.phpbb2_md5']->get_settings_only('ae2fc75e20ee25d4520766788fbc96ae')); } + + public function test_convert_password_driver() + { + $this->assertSame(false, $this->passwords_drivers['passwords.driver.convert_password']->hash('foobar')); + + $this->assertSame(false, $this->passwords_drivers['passwords.driver.convert_password']->get_settings_only('ae2fc75e20ee25d4520766788fbc96ae')); + } } -- cgit v1.2.1 From 033272f968249a2951cf7dc6867b8f393d113f2d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 28 May 2014 20:02:58 +0200 Subject: [ticket/12352] Add passwords driver for sha1 password hashes PHPBB3-12352 --- tests/passwords/drivers_test.php | 143 ++++++++++++++++++++++++++++++++++++++- tests/passwords/manager_test.php | 3 +- 2 files changed, 144 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 70a320f4bd..0ac4719b45 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -29,8 +29,9 @@ class phpbb_passwords_helper_test extends \phpbb_test_case '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), 'passwords.driver.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), - 'passwords.driver.phpbb2_md5' => new \phpbb\passwords\driver\phpbb2_md5($request, $phpbb_root_path, $php_ext), + 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), ); + $this->passwords_drivers['passwords.driver.phpbb2_md5'] = new \phpbb\passwords\driver\phpbb2_md5($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); } public function data_helper_encode64() @@ -128,6 +129,9 @@ class phpbb_passwords_helper_test extends \phpbb_test_case array(false, 'foobar', 'ae2fc75e20ee25d4520766788fbc96aeddsf'), array(false, 'fööbar', 'ae2fc75e20ee25d4520766788fbc96ae'), array(true, 'fööbar', 'ae2fc75e20ee25d4520766788fbc96ae', utf8_decode('fööbar')), + array(true, 'fööbar', '$H$966CepJh9RC3hFIm7aKywR6jEn0kpA0', utf8_decode('fööbar')), + array(true, 'fööbar', '$H$9rNjgwETtmc8befO8JL1xFMrrMw8MC.', $this->utf8_to_cp1252(utf8_decode('fööbar'))), + array(true, 'fööbar', '$H$9rNjgwETtmc8befO8JL1xFMrrMw8MC.', $this->utf8_to_cp1252('fööbar')), ); } @@ -160,4 +164,141 @@ class phpbb_passwords_helper_test extends \phpbb_test_case $this->assertSame(false, $this->passwords_drivers['passwords.driver.convert_password']->get_settings_only('ae2fc75e20ee25d4520766788fbc96ae')); } + + public function test_sha1_driver() + { + $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha1']->hash('foobar')); + + $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha1']->get_settings_only('ae2fc75e20ee25d4520766788fbc96ae')); + } + + protected function utf8_to_cp1252($string) + { + static $transform = array( + "\xE2\x82\xAC" => "\x80", + "\xE2\x80\x9A" => "\x82", + "\xC6\x92" => "\x83", + "\xE2\x80\x9E" => "\x84", + "\xE2\x80\xA6" => "\x85", + "\xE2\x80\xA0" => "\x86", + "\xE2\x80\xA1" => "\x87", + "\xCB\x86" => "\x88", + "\xE2\x80\xB0" => "\x89", + "\xC5\xA0" => "\x8A", + "\xE2\x80\xB9" => "\x8B", + "\xC5\x92" => "\x8C", + "\xC5\xBD" => "\x8E", + "\xE2\x80\x98" => "\x91", + "\xE2\x80\x99" => "\x92", + "\xE2\x80\x9C" => "\x93", + "\xE2\x80\x9D" => "\x94", + "\xE2\x80\xA2" => "\x95", + "\xE2\x80\x93" => "\x96", + "\xE2\x80\x94" => "\x97", + "\xCB\x9C" => "\x98", + "\xE2\x84\xA2" => "\x99", + "\xC5\xA1" => "\x9A", + "\xE2\x80\xBA" => "\x9B", + "\xC5\x93" => "\x9C", + "\xC5\xBE" => "\x9E", + "\xC5\xB8" => "\x9F", + "\xC2\xA0" => "\xA0", + "\xC2\xA1" => "\xA1", + "\xC2\xA2" => "\xA2", + "\xC2\xA3" => "\xA3", + "\xC2\xA4" => "\xA4", + "\xC2\xA5" => "\xA5", + "\xC2\xA6" => "\xA6", + "\xC2\xA7" => "\xA7", + "\xC2\xA8" => "\xA8", + "\xC2\xA9" => "\xA9", + "\xC2\xAA" => "\xAA", + "\xC2\xAB" => "\xAB", + "\xC2\xAC" => "\xAC", + "\xC2\xAD" => "\xAD", + "\xC2\xAE" => "\xAE", + "\xC2\xAF" => "\xAF", + "\xC2\xB0" => "\xB0", + "\xC2\xB1" => "\xB1", + "\xC2\xB2" => "\xB2", + "\xC2\xB3" => "\xB3", + "\xC2\xB4" => "\xB4", + "\xC2\xB5" => "\xB5", + "\xC2\xB6" => "\xB6", + "\xC2\xB7" => "\xB7", + "\xC2\xB8" => "\xB8", + "\xC2\xB9" => "\xB9", + "\xC2\xBA" => "\xBA", + "\xC2\xBB" => "\xBB", + "\xC2\xBC" => "\xBC", + "\xC2\xBD" => "\xBD", + "\xC2\xBE" => "\xBE", + "\xC2\xBF" => "\xBF", + "\xC3\x80" => "\xC0", + "\xC3\x81" => "\xC1", + "\xC3\x82" => "\xC2", + "\xC3\x83" => "\xC3", + "\xC3\x84" => "\xC4", + "\xC3\x85" => "\xC5", + "\xC3\x86" => "\xC6", + "\xC3\x87" => "\xC7", + "\xC3\x88" => "\xC8", + "\xC3\x89" => "\xC9", + "\xC3\x8A" => "\xCA", + "\xC3\x8B" => "\xCB", + "\xC3\x8C" => "\xCC", + "\xC3\x8D" => "\xCD", + "\xC3\x8E" => "\xCE", + "\xC3\x8F" => "\xCF", + "\xC3\x90" => "\xD0", + "\xC3\x91" => "\xD1", + "\xC3\x92" => "\xD2", + "\xC3\x93" => "\xD3", + "\xC3\x94" => "\xD4", + "\xC3\x95" => "\xD5", + "\xC3\x96" => "\xD6", + "\xC3\x97" => "\xD7", + "\xC3\x98" => "\xD8", + "\xC3\x99" => "\xD9", + "\xC3\x9A" => "\xDA", + "\xC3\x9B" => "\xDB", + "\xC3\x9C" => "\xDC", + "\xC3\x9D" => "\xDD", + "\xC3\x9E" => "\xDE", + "\xC3\x9F" => "\xDF", + "\xC3\xA0" => "\xE0", + "\xC3\xA1" => "\xE1", + "\xC3\xA2" => "\xE2", + "\xC3\xA3" => "\xE3", + "\xC3\xA4" => "\xE4", + "\xC3\xA5" => "\xE5", + "\xC3\xA6" => "\xE6", + "\xC3\xA7" => "\xE7", + "\xC3\xA8" => "\xE8", + "\xC3\xA9" => "\xE9", + "\xC3\xAA" => "\xEA", + "\xC3\xAB" => "\xEB", + "\xC3\xAC" => "\xEC", + "\xC3\xAD" => "\xED", + "\xC3\xAE" => "\xEE", + "\xC3\xAF" => "\xEF", + "\xC3\xB0" => "\xF0", + "\xC3\xB1" => "\xF1", + "\xC3\xB2" => "\xF2", + "\xC3\xB3" => "\xF3", + "\xC3\xB4" => "\xF4", + "\xC3\xB5" => "\xF5", + "\xC3\xB6" => "\xF6", + "\xC3\xB7" => "\xF7", + "\xC3\xB8" => "\xF8", + "\xC3\xB9" => "\xF9", + "\xC3\xBA" => "\xFA", + "\xC3\xBB" => "\xFB", + "\xC3\xBC" => "\xFC", + "\xC3\xBD" => "\xFD", + "\xC3\xBE" => "\xFE", + "\xC3\xBF" => "\xFF" + ); + return strtr($string, $transform); + } } diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index e925502f18..24243d76c4 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -35,8 +35,9 @@ class phpbb_passwords_manager_test extends \phpbb_test_case 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $this->driver_helper), 'passwords.driver.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), - 'passwords.driver.phpbb2_md5' => new \phpbb\passwords\driver\phpbb2_md5($request, $phpbb_root_path, $php_ext), + 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), ); + $this->passwords_drivers['passwords.driver.phpbb2_md5'] = new \phpbb\passwords\driver\phpbb2_md5($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); $this->helper = new \phpbb\passwords\helper; // Set up passwords manager -- cgit v1.2.1 From dc5a5a7cdfae8ba8e300b7db46eaa64fcc70824c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 28 May 2014 20:35:01 +0200 Subject: [ticket/12352] Rename phpbb2_md5 driver to fit filenames of other drivers PHPBB3-12352 --- tests/passwords/drivers_test.php | 16 ++++++++-------- tests/passwords/manager_test.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 0ac4719b45..3ef39df709 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -31,7 +31,7 @@ class phpbb_passwords_helper_test extends \phpbb_test_case 'passwords.driver.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), ); - $this->passwords_drivers['passwords.driver.phpbb2_md5'] = new \phpbb\passwords\driver\phpbb2_md5($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); + $this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); } public function data_helper_encode64() @@ -122,7 +122,7 @@ class phpbb_passwords_helper_test extends \phpbb_test_case $this->assertSame($expected, $this->passwords_drivers[$driver]->get_settings_only($hash)); } - public function data_phpbb2_md5_check() + public function data_md5_phpbb2_check() { return array( array(false, 'foobar', 'ae2fc75e20ee25d4520766788fbc96ae'), @@ -136,9 +136,9 @@ class phpbb_passwords_helper_test extends \phpbb_test_case } /** - * @dataProvider data_phpbb2_md5_check + * @dataProvider data_md5_phpbb2_check */ - public function test_phpbb2_md5_check($expected, $password, $hash, $request_password = false) + public function test_md5_phpbb2_check($expected, $password, $hash, $request_password = false) { if (!$request_password) { @@ -148,14 +148,14 @@ class phpbb_passwords_helper_test extends \phpbb_test_case { $_REQUEST['password'] = $request_password; } - $this->assertSame($expected, $this->passwords_drivers['passwords.driver.phpbb2_md5']->check($password, $hash)); + $this->assertSame($expected, $this->passwords_drivers['passwords.driver.md5_phpbb2']->check($password, $hash)); } - public function test_phpbb2_md5_unneeded_functions() + public function test_md5_phpbb2_unneeded_functions() { - $this->assertSame(false, $this->passwords_drivers['passwords.driver.phpbb2_md5']->hash('foobar')); + $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_phpbb2']->hash('foobar')); - $this->assertSame(false, $this->passwords_drivers['passwords.driver.phpbb2_md5']->get_settings_only('ae2fc75e20ee25d4520766788fbc96ae')); + $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_phpbb2']->get_settings_only('ae2fc75e20ee25d4520766788fbc96ae')); } public function test_convert_password_driver() diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index 24243d76c4..2a53d79027 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -37,7 +37,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), ); - $this->passwords_drivers['passwords.driver.phpbb2_md5'] = new \phpbb\passwords\driver\phpbb2_md5($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); + $this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); $this->helper = new \phpbb\passwords\helper; // Set up passwords manager -- cgit v1.2.1 From af25aef04ca3ee39cd1597b356638e883ccf72fa Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 28 May 2014 21:03:17 +0200 Subject: [ticket/12352] Add driver for myBB md5 passwords PHPBB3-12352 --- tests/passwords/drivers_test.php | 25 +++++++++++++++++++++++++ tests/passwords/manager_test.php | 1 + 2 files changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 3ef39df709..1f900340c7 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -30,6 +30,7 @@ class phpbb_passwords_helper_test extends \phpbb_test_case 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), 'passwords.driver.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), + 'passwords.driver.md5_mybb' => new \phpbb\passwords\driver\md5_mybb($config, $this->driver_helper), ); $this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); } @@ -172,6 +173,30 @@ class phpbb_passwords_helper_test extends \phpbb_test_case $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha1']->get_settings_only('ae2fc75e20ee25d4520766788fbc96ae')); } + public function data_md5_mybb_check() + { + return array( + array(false, 'foobar', '083d11daea8675b1b4b502c7e55f8dbd'), + array(false, 'foobar', '083d11daea8675b1b4b502c7e55f8dbd', array('user_passwd_salt' => 'ae2fc75e')), + array(true, 'foobar', '6022de2cc0ecf59ff14b57c6205ee170', array('user_passwd_salt' => 'ae2fc75e')), + ); + } + + /** + * @dataProvider data_md5_mybb_check + */ + public function test_md5_mybb_check($expected, $password, $hash, $user_row = array()) + { + $this->assertSame($expected, $this->passwords_drivers['passwords.driver.md5_mybb']->check($password, $hash, $user_row)); + } + + public function test_md5_mybb_driver() + { + $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_mybb']->hash('foobar')); + + $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_mybb']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); + } + protected function utf8_to_cp1252($string) { static $transform = array( diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index 2a53d79027..e2ec1972bb 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -36,6 +36,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case 'passwords.driver.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), + 'passwords.driver.md5_mybb' => new \phpbb\passwords\driver\md5_mybb($config, $this->driver_helper), ); $this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); -- cgit v1.2.1 From 252a061864b631ac2536f589d9c7da3810d82357 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 29 May 2014 12:13:02 +0200 Subject: [ticket/12352] Use correct hashing method in md5_mybb driver PHPBB3-12352 --- tests/passwords/drivers_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 1f900340c7..146f979a27 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -178,7 +178,7 @@ class phpbb_passwords_helper_test extends \phpbb_test_case return array( array(false, 'foobar', '083d11daea8675b1b4b502c7e55f8dbd'), array(false, 'foobar', '083d11daea8675b1b4b502c7e55f8dbd', array('user_passwd_salt' => 'ae2fc75e')), - array(true, 'foobar', '6022de2cc0ecf59ff14b57c6205ee170', array('user_passwd_salt' => 'ae2fc75e')), + array(true, 'foobar', 'b86ee7e24008bfd2890dcfab1ed31333', array('user_passwd_salt' => 'yeOtfFO6')), ); } -- cgit v1.2.1 From c6e1b51d786857478d2c20050c01f92ac2f8ac76 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 29 May 2014 14:00:42 +0200 Subject: [ticket/12352] Add passwords driver for vB passwords PHPBB3-12352 --- tests/passwords/drivers_test.php | 29 ++++++++++++++++++++++++++++- tests/passwords/manager_test.php | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 146f979a27..d67aead75a 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -30,7 +30,8 @@ class phpbb_passwords_helper_test extends \phpbb_test_case 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), 'passwords.driver.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), - 'passwords.driver.md5_mybb' => new \phpbb\passwords\driver\md5_mybb($config, $this->driver_helper), + 'passwords.driver.md5_mybb' => new \phpbb\passwords\driver\md5_mybb($config, $this->driver_helper), + 'passwords.driver.md5_vb' => new \phpbb\passwords\driver\md5_vb($config, $this->driver_helper), ); $this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); } @@ -197,6 +198,32 @@ class phpbb_passwords_helper_test extends \phpbb_test_case $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_mybb']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); } + public function data_md5_vb_check() + { + return array( + array(false, 'foobar', '083d11daea8675b1b4b502c7e55f8dbd'), + array(false, 'foobar', 'b86ee7e24008bfd2890dcfab1ed31333', array('user_passwd_salt' => 'yeOtfFO6')), + array(true, 'foobar', 'b452c54c44c588fc095d2d000935c470', array('user_passwd_salt' => '9^F')), + array(true, 'foobar', 'f23a8241bd115d270c703213e3ef7f52', array('user_passwd_salt' => 'iaU*U%`CBl;/e~>D%do2m@Xf/,KZB0')), + array(false, 'nope', 'f23a8241bd115d270c703213e3ef7f52', array('user_passwd_salt' => 'iaU*U%`CBl;/e~>D%do2m@Xf/,KZB0')), + ); + } + + /** + * @dataProvider data_md5_vb_check + */ + public function test_md5_vb_check($expected, $password, $hash, $user_row = array()) + { + $this->assertSame($expected, $this->passwords_drivers['passwords.driver.md5_vb']->check($password, $hash, $user_row)); + } + + public function test_md5_vb_driver() + { + $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_vb']->hash('foobar')); + + $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_vb']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); + } + protected function utf8_to_cp1252($string) { static $transform = array( diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index e2ec1972bb..959bc9a88c 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -37,6 +37,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), 'passwords.driver.md5_mybb' => new \phpbb\passwords\driver\md5_mybb($config, $this->driver_helper), + 'passwords.driver.md5_vb' => new \phpbb\passwords\driver\md5_vb($config, $this->driver_helper), ); $this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); -- cgit v1.2.1 From 146d3cfe7534d226530e0a42fa3fff37d26608f2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 29 May 2014 14:01:10 +0200 Subject: [ticket/12352] Fix spacing in passwords tests PHPBB3-12352 --- tests/passwords/drivers_test.php | 6 +++--- tests/passwords/manager_test.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index d67aead75a..6861e5f805 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -24,11 +24,11 @@ class phpbb_passwords_helper_test extends \phpbb_test_case $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' => new \phpbb\passwords\driver\bcrypt($config, $this->driver_helper), '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.phpass' => new \phpbb\passwords\driver\phpass($config, $this->driver_helper), 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), - 'passwords.driver.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), + 'passwords.driver.convert_password'=> new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), 'passwords.driver.md5_mybb' => new \phpbb\passwords\driver\md5_mybb($config, $this->driver_helper), 'passwords.driver.md5_vb' => new \phpbb\passwords\driver\md5_vb($config, $this->driver_helper), diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index 959bc9a88c..c6ae7db036 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -29,13 +29,13 @@ class phpbb_passwords_manager_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_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.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $this->driver_helper), + '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.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), - 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), - 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), + 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), + 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), 'passwords.driver.md5_mybb' => new \phpbb\passwords\driver\md5_mybb($config, $this->driver_helper), 'passwords.driver.md5_vb' => new \phpbb\passwords\driver\md5_vb($config, $this->driver_helper), ); -- cgit v1.2.1 From 2d7593995ee888da709e21051c4566b3740ef7f2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 29 May 2014 16:32:48 +0200 Subject: [ticket/12352] Add driver for woltlab community framework 2 passwords PHPBB3-12352 --- tests/passwords/drivers_test.php | 1 + tests/passwords/manager_test.php | 1 + 2 files changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 6861e5f805..0254db2016 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -34,6 +34,7 @@ class phpbb_passwords_helper_test extends \phpbb_test_case 'passwords.driver.md5_vb' => new \phpbb\passwords\driver\md5_vb($config, $this->driver_helper), ); $this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); + $this->passwords_drivers['passwords.driver.bcrypt_wcf2'] = new \phpbb\passwords\driver\bcrypt_wcf2($this->passwords_drivers['passwords.driver.bcrypt'], $this->driver_helper); } public function data_helper_encode64() diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index c6ae7db036..91e1035791 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -40,6 +40,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case 'passwords.driver.md5_vb' => new \phpbb\passwords\driver\md5_vb($config, $this->driver_helper), ); $this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); + $this->passwords_drivers['passwords.driver.bcrypt_wcf2'] = new \phpbb\passwords\driver\bcrypt_wcf2($this->passwords_drivers['passwords.driver.bcrypt'], $this->driver_helper); $this->helper = new \phpbb\passwords\helper; // Set up passwords manager -- cgit v1.2.1 From cf61d35d75bc8b608fb1ee4f5313e797af7ea584 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 29 May 2014 16:33:35 +0200 Subject: [ticket/12352] Add driver for woltlab community framework 1 passwords PHPBB3-12352 --- tests/passwords/drivers_test.php | 1 + tests/passwords/manager_test.php | 1 + 2 files changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 0254db2016..1bc2165ed7 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -28,6 +28,7 @@ class phpbb_passwords_helper_test extends \phpbb_test_case '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), + 'passwords.driver.sha1_wcf1' => new \phpbb\passwords\driver\sha1_wcf1($config, $this->driver_helper), 'passwords.driver.convert_password'=> new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), 'passwords.driver.md5_mybb' => new \phpbb\passwords\driver\md5_mybb($config, $this->driver_helper), diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index 91e1035791..e0cf0913c6 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -36,6 +36,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case 'passwords.driver.convert_password' => new \phpbb\passwords\driver\convert_password($config, $this->driver_helper), 'passwords.driver.sha1_smf' => new \phpbb\passwords\driver\sha1_smf($config, $this->driver_helper), 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), + 'passwords.driver.sha1_wcf1' => new \phpbb\passwords\driver\sha1_wcf1($config, $this->driver_helper), 'passwords.driver.md5_mybb' => new \phpbb\passwords\driver\md5_mybb($config, $this->driver_helper), 'passwords.driver.md5_vb' => new \phpbb\passwords\driver\md5_vb($config, $this->driver_helper), ); -- cgit v1.2.1 From 97c36b00b36a0191a453fd265c4d5f651da065bb Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 29 May 2014 16:33:59 +0200 Subject: [ticket/12352] Add tests for wcf1 and wcf2 drivers PHPBB3-12352 --- tests/passwords/drivers_test.php | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 1bc2165ed7..494b73702e 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -226,6 +226,54 @@ class phpbb_passwords_helper_test extends \phpbb_test_case $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_vb']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); } + public function data_sha1_wcf1_check() + { + return array( + array(false, 'foobar', 'fc46b9d9386167ce365ea3b891bf5dc31ddcd3ff'), + array(false, 'foobar', 'fc46b9d9386167ce365ea3b891bf5dc31ddcd3ff', array('user_passwd_salt' => 'yeOtfFO6')), + array(true, 'foobar', 'fc46b9d9386167ce365ea3b891bf5dc31ddcd3ff', array('user_passwd_salt' => '1a783e478d63f6422783a868db667aed3a857840')), + ); + } + + /** + * @dataProvider data_sha1_wcf1_check + */ + public function test_sha1_wcf1_check($expected, $password, $hash, $user_row = array()) + { + $this->assertSame($expected, $this->passwords_drivers['passwords.driver.sha1_wcf1']->check($password, $hash, $user_row)); + } + + public function test_sha1_wcf1_driver() + { + $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha1_wcf1']->hash('foobar')); + + $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha1_wcf1']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); + } + + public function data_bcrypt_wcf2_check() + { + return array( + array(false, 'foobar', 'fc46b9d9386167ce365ea3b891bf5dc31ddcd3ff'), + array(true, 'foobar', '$2a$08$p8h14U0jsEiVb1Luy.s8oOTXSQ0hVWUXpcNGBoCezeYNXrQyCKHfi'), + array(false, 'foobar', ''), + ); + } + + /** + * @dataProvider data_bcrypt_wcf2_check + */ + public function test_bcrypt_wcf2_check($expected, $password, $hash) + { + $this->assertSame($expected, $this->passwords_drivers['passwords.driver.bcrypt_wcf2']->check($password, $hash)); + } + + public function test_bcrypt_wcf2_driver() + { + $this->assertSame(false, $this->passwords_drivers['passwords.driver.bcrypt_wcf2']->hash('foobar')); + + $this->assertSame(false, $this->passwords_drivers['passwords.driver.bcrypt_wcf2']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); + } + protected function utf8_to_cp1252($string) { static $transform = array( -- cgit v1.2.1 From f3eba6275a6965f866b6e3bed7ce5330a14eb960 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 29 May 2014 22:50:21 +0200 Subject: [ticket/12352] Add passwords driver for xenforo 1.0, 1.1 passwords PHPBB3-12352 --- tests/passwords/drivers_test.php | 26 ++++++++++++++++++++++++++ tests/passwords/manager_test.php | 1 + 2 files changed, 27 insertions(+) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 494b73702e..d562f50d25 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -33,6 +33,7 @@ class phpbb_passwords_helper_test extends \phpbb_test_case 'passwords.driver.sha1' => new \phpbb\passwords\driver\sha1($config, $this->driver_helper), 'passwords.driver.md5_mybb' => new \phpbb\passwords\driver\md5_mybb($config, $this->driver_helper), 'passwords.driver.md5_vb' => new \phpbb\passwords\driver\md5_vb($config, $this->driver_helper), + 'passwords.driver.sha_xf1' => new \phpbb\passwords\driver\sha_xf1($config, $this->driver_helper), ); $this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); $this->passwords_drivers['passwords.driver.bcrypt_wcf2'] = new \phpbb\passwords\driver\bcrypt_wcf2($this->passwords_drivers['passwords.driver.bcrypt'], $this->driver_helper); @@ -274,6 +275,31 @@ class phpbb_passwords_helper_test extends \phpbb_test_case $this->assertSame(false, $this->passwords_drivers['passwords.driver.bcrypt_wcf2']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); } + public function data_sha_xf1_check() + { + return array( + array(false, 'foobar', 'fc46b9d9386167ce365ea3b891bf5dc31ddcd3ff'), + array(false, 'foobar', 'fc46b9d9386167ce365ea3b891bf5dc31ddcd3ff', array('user_passwd_salt' => 'yeOtfFO6')), + array(true, 'foobar', '7f65d2fa8a826d232f8134772252f8b1aaef8594b1edcabd9ab65e5b0f236ff0', array('user_passwd_salt' => '15b6c02cedbd727f563dcca607a89b085287b448966f19c0cc78cae263b1e38c')), + array(true, 'foobar', '69962ae2079420573a3948cc4dedbabd35680051', array('user_passwd_salt' => '15b6c02cedbd727f563dcca607a89b085287b448966f19c0cc78cae263b1e38c')), + ); + } + + /** + * @dataProvider data_sha_xf1_check + */ + public function test_sha_xf1_check($expected, $password, $hash, $user_row = array()) + { + $this->assertSame($expected, $this->passwords_drivers['passwords.driver.sha_xf1']->check($password, $hash, $user_row)); + } + + public function test_sha_xf1_driver() + { + $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha_xf1']->hash('foobar')); + + $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha_xf1']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); + } + protected function utf8_to_cp1252($string) { static $transform = array( diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index e0cf0913c6..714b9d8ebf 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -39,6 +39,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case 'passwords.driver.sha1_wcf1' => new \phpbb\passwords\driver\sha1_wcf1($config, $this->driver_helper), 'passwords.driver.md5_mybb' => new \phpbb\passwords\driver\md5_mybb($config, $this->driver_helper), 'passwords.driver.md5_vb' => new \phpbb\passwords\driver\md5_vb($config, $this->driver_helper), + 'passwords.driver.sha_xf1' => new \phpbb\passwords\driver\sha_xf1($config, $this->driver_helper), ); $this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext); $this->passwords_drivers['passwords.driver.bcrypt_wcf2'] = new \phpbb\passwords\driver\bcrypt_wcf2($this->passwords_drivers['passwords.driver.bcrypt'], $this->driver_helper); -- cgit v1.2.1 From 4b3aacfd18a8a3334532f9fcc830affb5f12963b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 30 May 2014 00:22:55 +0200 Subject: [ticket/12352] Add get_settings_only method to passwords driver base PHPBB3-12352 --- tests/passwords/drivers_test.php | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index d562f50d25..ccfb05c40f 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -156,25 +156,19 @@ class phpbb_passwords_helper_test extends \phpbb_test_case $this->assertSame($expected, $this->passwords_drivers['passwords.driver.md5_phpbb2']->check($password, $hash)); } - public function test_md5_phpbb2_unneeded_functions() + public function test_md5_phpbb2_hash() { $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_phpbb2']->hash('foobar')); - - $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_phpbb2']->get_settings_only('ae2fc75e20ee25d4520766788fbc96ae')); } public function test_convert_password_driver() { $this->assertSame(false, $this->passwords_drivers['passwords.driver.convert_password']->hash('foobar')); - - $this->assertSame(false, $this->passwords_drivers['passwords.driver.convert_password']->get_settings_only('ae2fc75e20ee25d4520766788fbc96ae')); } public function test_sha1_driver() { $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha1']->hash('foobar')); - - $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha1']->get_settings_only('ae2fc75e20ee25d4520766788fbc96ae')); } public function data_md5_mybb_check() @@ -197,8 +191,6 @@ class phpbb_passwords_helper_test extends \phpbb_test_case public function test_md5_mybb_driver() { $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_mybb']->hash('foobar')); - - $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_mybb']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); } public function data_md5_vb_check() @@ -223,8 +215,6 @@ class phpbb_passwords_helper_test extends \phpbb_test_case public function test_md5_vb_driver() { $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_vb']->hash('foobar')); - - $this->assertSame(false, $this->passwords_drivers['passwords.driver.md5_vb']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); } public function data_sha1_wcf1_check() @@ -247,8 +237,6 @@ class phpbb_passwords_helper_test extends \phpbb_test_case public function test_sha1_wcf1_driver() { $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha1_wcf1']->hash('foobar')); - - $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha1_wcf1']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); } public function data_bcrypt_wcf2_check() @@ -271,8 +259,6 @@ class phpbb_passwords_helper_test extends \phpbb_test_case public function test_bcrypt_wcf2_driver() { $this->assertSame(false, $this->passwords_drivers['passwords.driver.bcrypt_wcf2']->hash('foobar')); - - $this->assertSame(false, $this->passwords_drivers['passwords.driver.bcrypt_wcf2']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); } public function data_sha_xf1_check() @@ -296,8 +282,6 @@ class phpbb_passwords_helper_test extends \phpbb_test_case public function test_sha_xf1_driver() { $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha_xf1']->hash('foobar')); - - $this->assertSame(false, $this->passwords_drivers['passwords.driver.sha_xf1']->get_settings_only('6022de2cc0ecf59ff14b57c6205ee170')); } protected function utf8_to_cp1252($string) -- cgit v1.2.1 From fcaae9b0474035b9869f7e80c82242293edcfc27 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 30 May 2014 17:39:04 +0200 Subject: [ticket/12352] Check each newly added passwords driver in manager_test PHPBB3-12352 --- tests/passwords/manager_test.php | 41 ++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index 714b9d8ebf..e46cf820f2 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -144,28 +144,37 @@ class phpbb_passwords_manager_test extends \phpbb_test_case public function check_hash_exceptions_data() { return array( - array('foobar', '3858f62230ac3c915f300c664312c63f', true), - array('foobar', '$CP$3858f62230ac3c915f300c664312c63f', true), - array('foobar', '$CP$3858f62230ac3c915f300c', false), - array('foobar', '$S$b57a939fa4f2c04413a4eea9734a0903647b7adb93181295', false), - array('foobar', '$2a\S$kkkkaakdkdiej39023903204j2k3490234jk234j02349', false), - array('foobar', '$H$kklk938d023k//k3023', false), - array('foobar', '$H$3PtYMgXb39lrIWkgoxYLWtRkZtY3AY/', false), - array('foobar', '$2a$kwiweorurlaeirw', false), - array('foobar', '6f9e2a1899e1f15708fd2e554103480eb53e8b57', false), - array('foobar', '6f9e2a1899e1f15708fd2e554103480eb53e8b57', false, array('login_name' => 'test')), - array('foobar', '$CP$6f9e2a1899e1f15708fd2e554103480eb53e8b57', true, array('login_name' => 'test')), - array('foobar', '6f9e2a1899', false, array('login_name' => 'test')), - array('fööbar', 'ae2fc75e20ee25d4520766788fbc96ae', false), - array('fööbar', '$CP$ae2fc75e20ee25d4520766788fbc96ae', false), - array(utf8_decode('fööbar'), '$CP$ae2fc75e20ee25d4520766788fbc96ae', true), + array('3858f62230ac3c915f300c664312c63f', true), + array('$CP$3858f62230ac3c915f300c664312c63f', true), // md5_phpbb2 + array('$CP$3858f62230ac3c915f300c', false), + array('$S$b57a939fa4f2c04413a4eea9734a0903647b7adb93181295', false), + array('$2a\S$kkkkaakdkdiej39023903204j2k3490234jk234j02349', false), + array('$H$kklk938d023k//k3023', false), + array('$H$3PtYMgXb39lrIWkgoxYLWtRkZtY3AY/', false), + array('$2a$kwiweorurlaeirw', false), + array('6f9e2a1899e1f15708fd2e554103480eb53e8b57', false), + array('6f9e2a1899e1f15708fd2e554103480eb53e8b57', false, 'foobar', array('login_name' => 'test')), + array('$CP$6f9e2a1899e1f15708fd2e554103480eb53e8b57', true, 'foobar', array('login_name' => 'test')), // sha1_smf + array('6f9e2a1899', false, 'foobar', array('login_name' => 'test')), + array('ae2fc75e20ee25d4520766788fbc96ae', false, 'fööbar'), + array('$CP$ae2fc75e20ee25d4520766788fbc96ae', false, 'fööbar'), + array('$CP$ae2fc75e20ee25d4520766788fbc96ae', true, utf8_decode('fööbar')), // md5_phpbb2 + array('b86ee7e24008bfd2890dcfab1ed31333', false, 'foobar', array('user_passwd_salt' => 'yeOtfFO6')), + array('$CP$b86ee7e24008bfd2890dcfab1ed31333', true, 'foobar', array('user_passwd_salt' => 'yeOtfFO6')), // md5_mybb + array('$CP$b452c54c44c588fc095d2d000935c470', true, 'foobar', array('user_passwd_salt' => '9^F')), // md5_vb + array('$CP$f23a8241bd115d270c703213e3ef7f52', true, 'foobar', array('user_passwd_salt' => 'iaU*U%`CBl;/e~>D%do2m@Xf/,KZB0')), // md5_vb + array('$CP$fc46b9d9386167ce365ea3b891bf5dc31ddcd3ff', true, 'foobar', array('user_passwd_salt' => '1a783e478d63f6422783a868db667aed3a857840')), // sha_wcf1 + array('$2a$08$p8h14U0jsEiVb1Luy.s8oOTXSQ0hVWUXpcNGBoCezeYNXrQyCKHfi', false), + array('$CP$$2a$08$p8h14U0jsEiVb1Luy.s8oOTXSQ0hVWUXpcNGBoCezeYNXrQyCKHfi', true), // bcrypt_wcf2 + array('$CP$7f65d2fa8a826d232f8134772252f8b1aaef8594b1edcabd9ab65e5b0f236ff0', true, 'foobar', array('user_passwd_salt' => '15b6c02cedbd727f563dcca607a89b085287b448966f19c0cc78cae263b1e38c')), // sha_xf1 + array('$CP$69962ae2079420573a3948cc4dedbabd35680051', true, 'foobar', array('user_passwd_salt' => '15b6c02cedbd727f563dcca607a89b085287b448966f19c0cc78cae263b1e38c')), // sha_xf1 ); } /** * @dataProvider check_hash_exceptions_data */ - public function test_check_hash_exceptions($password, $hash, $expected, $user_row = array()) + public function test_check_hash_exceptions($hash, $expected, $password = 'foobar', $user_row = array()) { $this->assertEquals($expected, $this->manager->check($password, $hash, $user_row)); } -- cgit v1.2.1 From 4698f6928e44a24a7a10ff8b4fed2c1a24cab338 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 30 May 2014 23:00:57 +0200 Subject: [ticket/12352] Remove usages of user_pass_convert column PHPBB3-12352 --- tests/auth/fixtures/user.xml | 3 --- tests/auth/fixtures/user_533.xml | 3 --- tests/auth/provider_apache_test.php | 1 - tests/auth/provider_db_test.php | 1 - 4 files changed, 8 deletions(-) (limited to 'tests') diff --git a/tests/auth/fixtures/user.xml b/tests/auth/fixtures/user.xml index 77f707bab3..1e0eb6ee49 100644 --- a/tests/auth/fixtures/user.xml +++ b/tests/auth/fixtures/user.xml @@ -6,7 +6,6 @@ username_clean user_password user_passchg - user_pass_convert user_email user_type user_login_attempts @@ -18,7 +17,6 @@ foobar $2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i 0 - 0 example@example.com 0 0 @@ -31,7 +29,6 @@ foobar2 $H$9E45lK6J8nLTSm9oJE5aNCSTFK9wqa/ 0 - 0 example@example.com 0 0 diff --git a/tests/auth/fixtures/user_533.xml b/tests/auth/fixtures/user_533.xml index b64f376e5b..9731e4db4a 100644 --- a/tests/auth/fixtures/user_533.xml +++ b/tests/auth/fixtures/user_533.xml @@ -6,7 +6,6 @@ username_clean user_password user_passchg - user_pass_convert user_email user_type user_login_attempts @@ -18,7 +17,6 @@ foobar $2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi 0 - 0 example@example.com 0 0 @@ -31,7 +29,6 @@ foobar2 $H$9E45lK6J8nLTSm9oJE5aNCSTFK9wqa/ 0 - 0 example@example.com 0 0 diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index e17040902f..2decf0f18c 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -148,7 +148,6 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case 'username_clean' => 'foobar', 'user_password' => $this->password_hash, 'user_passchg' => '0', - 'user_pass_convert' => '0', 'user_email' => 'example@example.com', 'user_email_hash' => '0', 'user_birthday' => '', diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php index f071709a4b..23324f87f2 100644 --- a/tests/auth/provider_db_test.php +++ b/tests/auth/provider_db_test.php @@ -70,7 +70,6 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case 'username' => 'foobar', 'user_password' => $password_hash, 'user_passchg' => '0', - 'user_pass_convert' => '0', 'user_email' => 'example@example.com', 'user_type' => '0', 'user_login_attempts' => '0', -- cgit v1.2.1 From 6f5f0d6d8d5d3afcabccaa9da7c64108af5d4ab7 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 31 May 2014 22:43:07 +0200 Subject: [ticket/12352] Use custom provider collection for auth providers Using this custom provider collection, we can properly check whether the configured auth provider does exist. The method get_provider() has been added for returning the default auth provider or the standard db auth provider if the specified one does not exist. Additionally, the method get_provider() will throw an RuntimeException if none of the above exist. PHPBB3-12352 --- tests/session/testable_factory.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index 4bd7fa1366..3e25286480 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -96,9 +96,11 @@ class phpbb_session_testable_factory 'auth.provider.db', new phpbb_mock_auth_provider() ); + $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); + $provider_collection->add('auth.provider.db'); $phpbb_container->set( 'auth.provider_collection', - array('auth.provider.db' => $phpbb_container->get('auth.provider.db')) + $provider_collection ); $session = new phpbb_mock_session_testable; -- cgit v1.2.1