From 42b7782927713c2ca2fb704db6217016347b586e Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 19 Mar 2017 21:46:20 +0700 Subject: [ticket/14972] Migrate from deprecated getMock() method to createMock() PHPBB3-14972 --- tests/auth/provider_apache_test.php | 2 +- tests/auth/provider_db_test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/auth') diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index 7d77d763fb..f30d19ef9d 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -27,7 +27,7 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case $config = new \phpbb\config\config(array()); $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); - $this->request = $this->getMock('\phpbb\request\request'); + $this->request = $this->createMock('\phpbb\request\request'); $this->user = new \phpbb\user($lang, '\phpbb\datetime'); $driver_helper = new \phpbb\passwords\driver\helper($config); $passwords_drivers = array( diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php index 6ff77da564..b7d94ed046 100644 --- a/tests/auth/provider_db_test.php +++ b/tests/auth/provider_db_test.php @@ -37,7 +37,7 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case )); $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); - $request = $this->getMock('\phpbb\request\request'); + $request = $this->createMock('\phpbb\request\request'); $user = new \phpbb\user($lang, '\phpbb\datetime'); $driver_helper = new \phpbb\passwords\driver\helper($config); $passwords_drivers = array( -- cgit v1.2.1 From ebac54aa9e705e99a562d2fe2c0f57bc6af8dd32 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 30 Dec 2018 11:36:08 +0100 Subject: [ticket/14948] Adjust calls for twig and phpunit updates PHPBB3-14948 --- tests/auth/provider_apache_test.php | 2 +- tests/auth/provider_oauth_token_storage_test.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'tests/auth') diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index f30d19ef9d..0c26a0a186 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -17,7 +17,7 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case protected $user; protected $request; - protected function setup() + protected function setup(): void { parent::setUp(); diff --git a/tests/auth/provider_oauth_token_storage_test.php b/tests/auth/provider_oauth_token_storage_test.php index ae5de6aa7e..0c0e55dec6 100644 --- a/tests/auth/provider_oauth_token_storage_test.php +++ b/tests/auth/provider_oauth_token_storage_test.php @@ -25,7 +25,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c protected $state_table; protected $user; - protected function setup() + protected function setup(): void { parent::setUp(); @@ -73,7 +73,10 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c $token = $cache_token; } - $this->setExpectedException($exception); + if (!empty($exception)) + { + $this->expectException($exception); + } $stored_token = $this->token_storage->retrieveAccessToken($this->service_name); $this->assertEquals($token, $stored_token); @@ -120,7 +123,10 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c $token = $cache_token; } - $this->setExpectedException($exception); + if (!empty($exception)) + { + $this->expectException($exception); + } $stored_token = $this->token_storage->retrieve_access_token_by_session($this->service_name); $this->assertEquals($token, $stored_token); -- cgit v1.2.1 From 9e772d1421e059d8898f2b095e341107a1502914 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 10 Aug 2019 22:21:14 +0200 Subject: [ticket/11327] Adjust tests for new reset password changes PHPBB3-11327 --- tests/auth/provider_apache_test.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/auth') diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index 0c26a0a186..58d6354228 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -202,6 +202,8 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case 'user_new' => '1', 'user_reminded' => '0', 'user_reminded_time' => '0', + 'reset_token' => '', + 'reset_token_expiration' => '0', ); $this->assertEquals($expected, $this->provider->autologin()); -- cgit v1.2.1 From 2c3a24b678fa5070ffacd4a6bb3cfc26f648c07e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 1 Nov 2019 11:52:44 +0100 Subject: [ticket/12574] Remove passwords manager dependency from ldap Also started to implement tests for ldap provider. PHPBB3-12574 --- tests/auth/provider_ldap_test.php | 197 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 tests/auth/provider_ldap_test.php (limited to 'tests/auth') diff --git a/tests/auth/provider_ldap_test.php b/tests/auth/provider_ldap_test.php new file mode 100644 index 0000000000..2c4b36ffd8 --- /dev/null +++ b/tests/auth/provider_ldap_test.php @@ -0,0 +1,197 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +class phpbb_auth_provider_ldap_test extends phpbb_database_test_case +{ + /** @var \phpbb\auth\provider\ldap */ + protected $provider; + + protected $user; + + protected function setup() + { + parent::setUp(); + + global $phpbb_root_path, $phpEx; + + $db = $this->new_dbal(); + $config = new \phpbb\config\config([ + 'ldap_server' => 'localhost', + 'ldap_port' => 3389, + 'ldap_dn' => 'dc=example,dc=com', + 'ldap_uid' => 'uid', + 'ldap_email' => 'mail', + ]); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $this->user = new \phpbb\user($lang, '\phpbb\datetime'); + + $this->provider = new \phpbb\auth\provider\ldap($config, $db, $lang, $this->user); + } + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user.xml'); + } + + /** + * Test to see if a user is identified to Apache. Expects false if they are. + */ + public function test_init() + { + $this->assertFalse($this->provider->init()); + } +/* + public function test_login() + { + $username = 'foobar'; + $password = 'example'; + + $this->request->expects($this->once()) + ->method('is_set') + ->with('PHP_AUTH_USER', + \phpbb\request\request_interface::SERVER) + ->will($this->returnValue(true)); + $this->request->expects($this->at(1)) + ->method('server') + ->with('PHP_AUTH_USER') + ->will($this->returnValue('foobar')); + $this->request->expects($this->at(2)) + ->method('server') + ->with('PHP_AUTH_PW') + ->will($this->returnValue('example')); + + $expected = array( + 'status' => LOGIN_SUCCESS, + 'error_msg' => false, + 'user_row' => array( + 'user_id' => '1', + 'username' => 'foobar', + 'user_password' => $this->password_hash, + 'user_passchg' => '0', + 'user_email' => 'example@example.com', + 'user_type' => '0', + ), + ); + + $this->assertEquals($expected, $this->provider->login($username, $password)); + } + + public function test_autologin() + { + $this->request->expects($this->once()) + ->method('is_set') + ->with('PHP_AUTH_USER', + \phpbb\request\request_interface::SERVER) + ->will($this->returnValue(true)); + $this->request->expects($this->at(1)) + ->method('server') + ->with('PHP_AUTH_USER') + ->will($this->returnValue('foobar')); + $this->request->expects($this->at(2)) + ->method('server') + ->with('PHP_AUTH_PW') + ->will($this->returnValue('example')); + + $expected = array( + 'user_id' => '1', + 'user_type' => '0', + 'group_id' => '3', + 'user_permissions' => '', + 'user_perm_from' => '0', + 'user_ip' => '', + 'user_regdate' => '0', + 'username' => 'foobar', + 'username_clean' => 'foobar', + 'user_password' => $this->password_hash, + 'user_passchg' => '0', + 'user_email' => 'example@example.com', + 'user_email_hash' => '0', + 'user_birthday' => '', + 'user_lastvisit' => '0', + 'user_lastmark' => '0', + 'user_lastpost_time' => '0', + 'user_lastpage' => '', + 'user_last_confirm_key' => '', + 'user_last_search' => '0', + 'user_warnings' => '0', + 'user_last_warning' => '0', + 'user_login_attempts' => '0', + 'user_inactive_reason' => '0', + 'user_inactive_time' => '0', + 'user_posts' => '0', + 'user_lang' => '', + 'user_timezone' => '', + 'user_dateformat' => 'd M Y H:i', + 'user_style' => '0', + 'user_rank' => '0', + 'user_colour' => '', + 'user_new_privmsg' => '0', + 'user_unread_privmsg' => '0', + 'user_last_privmsg' => '0', + 'user_message_rules' => '0', + 'user_full_folder' => '-3', + 'user_emailtime' => '0', + 'user_topic_show_days' => '0', + 'user_topic_sortby_type' => 't', + 'user_topic_sortby_dir' => 'd', + 'user_post_show_days' => '0', + 'user_post_sortby_type' => 't', + 'user_post_sortby_dir' => 'a', + 'user_notify' => '0', + 'user_notify_pm' => '1', + 'user_notify_type' => '0', + 'user_allow_pm' => '1', + 'user_allow_viewonline' => '1', + 'user_allow_viewemail' => '1', + 'user_allow_massemail' => '1', + 'user_options' => '230271', + 'user_avatar' => '', + 'user_avatar_type' => '', + 'user_avatar_width' => '0', + 'user_avatar_height' => '0', + 'user_sig' => '', + 'user_sig_bbcode_uid' => '', + 'user_sig_bbcode_bitfield' => '', + 'user_jabber' => '', + 'user_actkey' => '', + 'user_newpasswd' => '', + 'user_form_salt' => '', + 'user_new' => '1', + 'user_reminded' => '0', + 'user_reminded_time' => '0', + ); + + $this->assertEquals($expected, $this->provider->autologin()); + } + + public function test_validate_session() + { + $user = array( + 'username' => 'foobar', + 'user_type' + ); + $this->request->expects($this->once()) + ->method('is_set') + ->with('PHP_AUTH_USER', + \phpbb\request\request_interface::SERVER) + ->will($this->returnValue(true)); + $this->request->expects($this->once()) + ->method('server') + ->with('PHP_AUTH_USER') + ->will($this->returnValue('foobar')); + + $this->assertTrue($this->provider->validate_session($user)); + } +*/ +} -- cgit v1.2.1 From 0cd7033baad12acc2abcee38b023031322623dc4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 1 Nov 2019 12:03:45 +0100 Subject: [ticket/12574] Run LDAP test as slow test and install ldap extension PHPBB3-12574 --- tests/auth/provider_ldap_test.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/auth') diff --git a/tests/auth/provider_ldap_test.php b/tests/auth/provider_ldap_test.php index 2c4b36ffd8..2b3c377d9e 100644 --- a/tests/auth/provider_ldap_test.php +++ b/tests/auth/provider_ldap_test.php @@ -11,6 +11,9 @@ * */ +/** + * @group slow + */ class phpbb_auth_provider_ldap_test extends phpbb_database_test_case { /** @var \phpbb\auth\provider\ldap */ -- cgit v1.2.1 From 9aee50968e0ecb8b88000815b273d0395418e1ff Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 1 Nov 2019 12:16:56 +0100 Subject: [ticket/12574] Don't add extension to php config & set default username PHPBB3-12574 --- tests/auth/provider_ldap_test.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auth') diff --git a/tests/auth/provider_ldap_test.php b/tests/auth/provider_ldap_test.php index 2b3c377d9e..211966875e 100644 --- a/tests/auth/provider_ldap_test.php +++ b/tests/auth/provider_ldap_test.php @@ -38,6 +38,7 @@ class phpbb_auth_provider_ldap_test extends phpbb_database_test_case $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $this->user = new \phpbb\user($lang, '\phpbb\datetime'); + $this->user->data['username'] = 'admin'; $this->provider = new \phpbb\auth\provider\ldap($config, $db, $lang, $this->user); } -- cgit v1.2.1 From c75502e09c9b997779a109b132298dd16b16e6d9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 1 Nov 2019 12:40:52 +0100 Subject: [ticket/12574] Use correct config entry for connecting to ldap PHPBB3-12574 --- tests/auth/provider_ldap_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auth') diff --git a/tests/auth/provider_ldap_test.php b/tests/auth/provider_ldap_test.php index 211966875e..5482f964bf 100644 --- a/tests/auth/provider_ldap_test.php +++ b/tests/auth/provider_ldap_test.php @@ -31,7 +31,7 @@ class phpbb_auth_provider_ldap_test extends phpbb_database_test_case $config = new \phpbb\config\config([ 'ldap_server' => 'localhost', 'ldap_port' => 3389, - 'ldap_dn' => 'dc=example,dc=com', + 'ldap_base_dn' => 'dc=example,dc=com', 'ldap_uid' => 'uid', 'ldap_email' => 'mail', ]); -- cgit v1.2.1 From 149df2d7b674e601f8f1197fe705a2a23d2a4229 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 1 Nov 2019 13:03:50 +0100 Subject: [ticket/12574] Adjust login tests for ldap PHPBB3-12574 --- tests/auth/fixtures/user.xml | 12 ++++ tests/auth/provider_ldap_test.php | 134 ++++---------------------------------- 2 files changed, 26 insertions(+), 120 deletions(-) (limited to 'tests/auth') diff --git a/tests/auth/fixtures/user.xml b/tests/auth/fixtures/user.xml index 1e0eb6ee49..33f69a9067 100644 --- a/tests/auth/fixtures/user.xml +++ b/tests/auth/fixtures/user.xml @@ -1,5 +1,17 @@ + + group_id + group_name + group_type + group_desc + + 1 + REGISTERED + 3 + foobar + +
user_idusername diff --git a/tests/auth/provider_ldap_test.php b/tests/auth/provider_ldap_test.php index 5482f964bf..7d95f476bc 100644 --- a/tests/auth/provider_ldap_test.php +++ b/tests/auth/provider_ldap_test.php @@ -55,36 +55,23 @@ class phpbb_auth_provider_ldap_test extends phpbb_database_test_case { $this->assertFalse($this->provider->init()); } -/* + public function test_login() { - $username = 'foobar'; - $password = 'example'; - - $this->request->expects($this->once()) - ->method('is_set') - ->with('PHP_AUTH_USER', - \phpbb\request\request_interface::SERVER) - ->will($this->returnValue(true)); - $this->request->expects($this->at(1)) - ->method('server') - ->with('PHP_AUTH_USER') - ->will($this->returnValue('foobar')); - $this->request->expects($this->at(2)) - ->method('server') - ->with('PHP_AUTH_PW') - ->will($this->returnValue('example')); + $username = 'admin'; + $password = 'adminadmin'; $expected = array( - 'status' => LOGIN_SUCCESS, + 'status' => LOGIN_SUCCESS_CREATE_PROFILE, // successful login and user created 'error_msg' => false, 'user_row' => array( - 'user_id' => '1', - 'username' => 'foobar', - 'user_password' => $this->password_hash, - 'user_passchg' => '0', - 'user_email' => 'example@example.com', - 'user_type' => '0', + 'username' => 'admin', + 'user_password' => '', + 'user_email' => 'admin@example.com', + 'user_type' => 0, + 'group_id' => 1, + 'user_new' => 0, + 'user_ip' => '', ), ); @@ -93,109 +80,16 @@ class phpbb_auth_provider_ldap_test extends phpbb_database_test_case public function test_autologin() { - $this->request->expects($this->once()) - ->method('is_set') - ->with('PHP_AUTH_USER', - \phpbb\request\request_interface::SERVER) - ->will($this->returnValue(true)); - $this->request->expects($this->at(1)) - ->method('server') - ->with('PHP_AUTH_USER') - ->will($this->returnValue('foobar')); - $this->request->expects($this->at(2)) - ->method('server') - ->with('PHP_AUTH_PW') - ->will($this->returnValue('example')); - - $expected = array( - 'user_id' => '1', - 'user_type' => '0', - 'group_id' => '3', - 'user_permissions' => '', - 'user_perm_from' => '0', - 'user_ip' => '', - 'user_regdate' => '0', - 'username' => 'foobar', - 'username_clean' => 'foobar', - 'user_password' => $this->password_hash, - 'user_passchg' => '0', - 'user_email' => 'example@example.com', - 'user_email_hash' => '0', - 'user_birthday' => '', - 'user_lastvisit' => '0', - 'user_lastmark' => '0', - 'user_lastpost_time' => '0', - 'user_lastpage' => '', - 'user_last_confirm_key' => '', - 'user_last_search' => '0', - 'user_warnings' => '0', - 'user_last_warning' => '0', - 'user_login_attempts' => '0', - 'user_inactive_reason' => '0', - 'user_inactive_time' => '0', - 'user_posts' => '0', - 'user_lang' => '', - 'user_timezone' => '', - 'user_dateformat' => 'd M Y H:i', - 'user_style' => '0', - 'user_rank' => '0', - 'user_colour' => '', - 'user_new_privmsg' => '0', - 'user_unread_privmsg' => '0', - 'user_last_privmsg' => '0', - 'user_message_rules' => '0', - 'user_full_folder' => '-3', - 'user_emailtime' => '0', - 'user_topic_show_days' => '0', - 'user_topic_sortby_type' => 't', - 'user_topic_sortby_dir' => 'd', - 'user_post_show_days' => '0', - 'user_post_sortby_type' => 't', - 'user_post_sortby_dir' => 'a', - 'user_notify' => '0', - 'user_notify_pm' => '1', - 'user_notify_type' => '0', - 'user_allow_pm' => '1', - 'user_allow_viewonline' => '1', - 'user_allow_viewemail' => '1', - 'user_allow_massemail' => '1', - 'user_options' => '230271', - 'user_avatar' => '', - 'user_avatar_type' => '', - 'user_avatar_width' => '0', - 'user_avatar_height' => '0', - 'user_sig' => '', - 'user_sig_bbcode_uid' => '', - 'user_sig_bbcode_bitfield' => '', - 'user_jabber' => '', - 'user_actkey' => '', - 'user_newpasswd' => '', - 'user_form_salt' => '', - 'user_new' => '1', - 'user_reminded' => '0', - 'user_reminded_time' => '0', - ); - - $this->assertEquals($expected, $this->provider->autologin()); + $this->assertNull($this->provider->autologin()); } public function test_validate_session() { $user = array( - 'username' => 'foobar', + 'username' => 'admin', 'user_type' ); - $this->request->expects($this->once()) - ->method('is_set') - ->with('PHP_AUTH_USER', - \phpbb\request\request_interface::SERVER) - ->will($this->returnValue(true)); - $this->request->expects($this->once()) - ->method('server') - ->with('PHP_AUTH_USER') - ->will($this->returnValue('foobar')); - $this->assertTrue($this->provider->validate_session($user)); + $this->assertNull($this->provider->validate_session($user)); } -*/ } -- cgit v1.2.1 From 0d668fee3686d1df8a0415572cebb01025419cd6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 1 Nov 2019 13:38:09 +0100 Subject: [ticket/12574] Fix incorrect setup() method declaration & ldap extension PHPBB3-12574 --- tests/auth/provider_ldap_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auth') diff --git a/tests/auth/provider_ldap_test.php b/tests/auth/provider_ldap_test.php index 7d95f476bc..63cd63eee2 100644 --- a/tests/auth/provider_ldap_test.php +++ b/tests/auth/provider_ldap_test.php @@ -21,7 +21,7 @@ class phpbb_auth_provider_ldap_test extends phpbb_database_test_case protected $user; - protected function setup() + protected function setup() : void { parent::setUp(); -- cgit v1.2.1 From 9e0c3fc81ec0c3006acc5aa3074cedb98f11e680 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 1 Nov 2019 14:30:27 +0100 Subject: [ticket/12574] Stop using passwords manager in apache provider PHPBB3-12574 --- tests/auth/provider_apache_test.php | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) (limited to 'tests/auth') diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index 58d6354228..b1c84d47b6 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -28,41 +28,14 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $this->request = $this->createMock('\phpbb\request\request'); - $this->user = new \phpbb\user($lang, '\phpbb\datetime'); - $driver_helper = new \phpbb\passwords\driver\helper($config); - $passwords_drivers = array( - 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper), - 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $driver_helper), - 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $driver_helper), - 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper), - ); - - $passwords_helper = new \phpbb\passwords\helper; - // Set up passwords manager - $passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers)); - - if (version_compare(PHP_VERSION, '5.3.7', '<')) - { - $this->password_hash = '$2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi'; - } - else - { - $this->password_hash = '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i'; - } + $this->user = new \phpbb\user($lang, '\phpbb\datetime');; - $this->provider = new \phpbb\auth\provider\apache($db, $config, $passwords_manager, $this->request, $this->user, $phpbb_root_path, $phpEx); + $this->provider = new \phpbb\auth\provider\apache($config, $db, $lang, $this->request, $this->user, $phpbb_root_path, $phpEx); } public function getDataSet() { - if ((version_compare(PHP_VERSION, '5.3.7', '<'))) - { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user_533.xml'); - } - else - { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user.xml'); - } + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user.xml'); } /** @@ -109,7 +82,7 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case 'user_row' => array( 'user_id' => '1', 'username' => 'foobar', - 'user_password' => $this->password_hash, + 'user_password' => '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i', 'user_passchg' => '0', 'user_email' => 'example@example.com', 'user_type' => '0', @@ -145,7 +118,7 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case 'user_regdate' => '0', 'username' => 'foobar', 'username_clean' => 'foobar', - 'user_password' => $this->password_hash, + 'user_password' => '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i', 'user_passchg' => '0', 'user_email' => 'example@example.com', 'user_email_hash' => '0', -- cgit v1.2.1 From a00b8c29204e4517ada908cdc0bc6eacf93d7305 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 1 Nov 2019 14:37:27 +0100 Subject: [ticket/12574] Clean up dependencies of db auth provider PHPBB3-12574 --- tests/auth/provider_db_test.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tests/auth') diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php index b7d94ed046..2c467518f5 100644 --- a/tests/auth/provider_db_test.php +++ b/tests/auth/provider_db_test.php @@ -52,8 +52,20 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case $passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers)); $phpbb_container = new phpbb_mock_container_builder(); + $plugins = new \phpbb\di\service_collection($phpbb_container); + $plugins->add('core.captcha.plugins.nogd'); + $phpbb_container->set( + 'captcha.factory', + new \phpbb\captcha\factory($phpbb_container, $plugins) + ); + $phpbb_container->set( + 'core.captcha.plugins.nogd', + new \phpbb\captcha\plugins\nogd() + ); + /** @var \phpbb\captcha\factory $captcha_factory */ + $captcha_factory = $phpbb_container->get('captcha.factory'); - $provider = new \phpbb\auth\provider\db($db, $config, $passwords_manager, $request, $user, $phpbb_container, $phpbb_root_path, $phpEx); + $provider = new \phpbb\auth\provider\db($captcha_factory, $config, $db, $passwords_manager, $request, $user, $phpbb_root_path, $phpEx); if (version_compare(PHP_VERSION, '5.3.7', '<')) { $password_hash = '$2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi'; -- cgit v1.2.1 From 0cbe05faadfade06737f3f057fb1b9aa44a78693 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 1 Nov 2019 16:15:25 +0100 Subject: [ticket/12574] Remove special cases for PHP < 5.3.7 PHPBB3-12574 --- tests/auth/fixtures/user_533.xml | 39 --------------------------------------- tests/auth/provider_db_test.php | 21 +++------------------ 2 files changed, 3 insertions(+), 57 deletions(-) delete mode 100644 tests/auth/fixtures/user_533.xml (limited to 'tests/auth') diff --git a/tests/auth/fixtures/user_533.xml b/tests/auth/fixtures/user_533.xml deleted file mode 100644 index 9731e4db4a..0000000000 --- a/tests/auth/fixtures/user_533.xml +++ /dev/null @@ -1,39 +0,0 @@ - - -
- user_id - username - username_clean - user_password - user_passchg - user_email - user_type - user_login_attempts - user_permissions - user_sig - - 1 - foobar - foobar - $2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi - 0 - example@example.com - 0 - 0 - - - - - 2 - foobar2 - foobar2 - $H$9E45lK6J8nLTSm9oJE5aNCSTFK9wqa/ - 0 - example@example.com - 0 - 0 - - - -
-
diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php index 2c467518f5..8305e7caa4 100644 --- a/tests/auth/provider_db_test.php +++ b/tests/auth/provider_db_test.php @@ -15,14 +15,7 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case { public function getDataSet() { - if ((version_compare(PHP_VERSION, '5.3.7', '<'))) - { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user_533.xml'); - } - else - { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user.xml'); - } + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user.xml'); } public function test_login() @@ -66,14 +59,7 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case $captcha_factory = $phpbb_container->get('captcha.factory'); $provider = new \phpbb\auth\provider\db($captcha_factory, $config, $db, $passwords_manager, $request, $user, $phpbb_root_path, $phpEx); - if (version_compare(PHP_VERSION, '5.3.7', '<')) - { - $password_hash = '$2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi'; - } - else - { - $password_hash = '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i'; - } + $password_hash = '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i'; $expected = array( 'status' => LOGIN_SUCCESS, @@ -100,7 +86,6 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case // Check if convert works $login_return = $provider->login('foobar2', 'example'); - $password_start = (version_compare(PHP_VERSION, '5.3.7', '<')) ? '$2a$10$' : '$2y$10$'; - $this->assertStringStartsWith($password_start, $login_return['user_row']['user_password']); + $this->assertStringStartsWith('$2y$10$', $login_return['user_row']['user_password']); } } -- cgit v1.2.1 From c11dbffbac8789d9532234ed88a1e47026632363 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 17 Nov 2019 09:42:27 +0100 Subject: [ticket/12574] Remove not used user_type PHPBB3-12574 --- tests/auth/provider_ldap_test.php | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/auth') diff --git a/tests/auth/provider_ldap_test.php b/tests/auth/provider_ldap_test.php index 63cd63eee2..0bc9961f52 100644 --- a/tests/auth/provider_ldap_test.php +++ b/tests/auth/provider_ldap_test.php @@ -87,7 +87,6 @@ class phpbb_auth_provider_ldap_test extends phpbb_database_test_case { $user = array( 'username' => 'admin', - 'user_type' ); $this->assertNull($this->provider->validate_session($user)); -- cgit v1.2.1 From 9872316cac4df4987fdabc9512ca6ebeb7e5e04f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 18 Nov 2019 21:06:00 +0100 Subject: [ticket/16167] Remove uses of user_email_hash PHPBB3-16167 --- tests/auth/provider_apache_test.php | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/auth') diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index b1c84d47b6..ebc97c204a 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -121,7 +121,6 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case 'user_password' => '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i', 'user_passchg' => '0', 'user_email' => 'example@example.com', - 'user_email_hash' => '0', 'user_birthday' => '', 'user_lastvisit' => '0', 'user_lastmark' => '0', -- cgit v1.2.1 From d5f9e3a05eced92ce8a2ebd9a93f23770e1db6bb Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 22 Dec 2019 16:12:04 +0100 Subject: [ticket/16263] Do not expect numbers as strings in apache provider test PHPBB3-16263 --- tests/auth/provider_apache_test.php | 80 ++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'tests/auth') diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index ebc97c204a..0f9169ff8b 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -109,61 +109,61 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case ->will($this->returnValue('example')); $expected = array( - 'user_id' => '1', - 'user_type' => '0', - 'group_id' => '3', + 'user_id' => 1, + 'user_type' => 0, + 'group_id' => 3, 'user_permissions' => '', - 'user_perm_from' => '0', + 'user_perm_from' => 0, 'user_ip' => '', - 'user_regdate' => '0', + 'user_regdate' => 0, 'username' => 'foobar', 'username_clean' => 'foobar', 'user_password' => '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i', - 'user_passchg' => '0', + 'user_passchg' => 0, 'user_email' => 'example@example.com', 'user_birthday' => '', - 'user_lastvisit' => '0', - 'user_lastmark' => '0', - 'user_lastpost_time' => '0', + 'user_lastvisit' => 0, + 'user_lastmark' => 0, + 'user_lastpost_time' => 0, 'user_lastpage' => '', 'user_last_confirm_key' => '', - 'user_last_search' => '0', - 'user_warnings' => '0', - 'user_last_warning' => '0', - 'user_login_attempts' => '0', - 'user_inactive_reason' => '0', - 'user_inactive_time' => '0', - 'user_posts' => '0', + 'user_last_search' => 0, + 'user_warnings' => 0, + 'user_last_warning' => 0, + 'user_login_attempts' => 0, + 'user_inactive_reason' => 0, + 'user_inactive_time' => 0, + 'user_posts' => 0, 'user_lang' => '', 'user_timezone' => '', 'user_dateformat' => 'd M Y H:i', - 'user_style' => '0', - 'user_rank' => '0', + 'user_style' => 0, + 'user_rank' => 0, 'user_colour' => '', - 'user_new_privmsg' => '0', - 'user_unread_privmsg' => '0', - 'user_last_privmsg' => '0', - 'user_message_rules' => '0', - 'user_full_folder' => '-3', - 'user_emailtime' => '0', - 'user_topic_show_days' => '0', + 'user_new_privmsg' => 0, + 'user_unread_privmsg' => 0, + 'user_last_privmsg' => 0, + 'user_message_rules' => 0, + 'user_full_folder' => -3, + 'user_emailtime' => 0, + 'user_topic_show_days' => 0, 'user_topic_sortby_type' => 't', 'user_topic_sortby_dir' => 'd', - 'user_post_show_days' => '0', + 'user_post_show_days' => 0, 'user_post_sortby_type' => 't', 'user_post_sortby_dir' => 'a', - 'user_notify' => '0', - 'user_notify_pm' => '1', - 'user_notify_type' => '0', - 'user_allow_pm' => '1', - 'user_allow_viewonline' => '1', - 'user_allow_viewemail' => '1', - 'user_allow_massemail' => '1', - 'user_options' => '230271', + 'user_notify' => 0, + 'user_notify_pm' => 1, + 'user_notify_type' => 0, + 'user_allow_pm' => 1, + 'user_allow_viewonline' => 1, + 'user_allow_viewemail' => 1, + 'user_allow_massemail' => 1, + 'user_options' => 230271, 'user_avatar' => '', 'user_avatar_type' => '', - 'user_avatar_width' => '0', - 'user_avatar_height' => '0', + 'user_avatar_width' => 0, + 'user_avatar_height' => 0, 'user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => '', @@ -171,11 +171,11 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case 'user_actkey' => '', 'user_newpasswd' => '', 'user_form_salt' => '', - 'user_new' => '1', - 'user_reminded' => '0', - 'user_reminded_time' => '0', + 'user_new' => 1, + 'user_reminded' => 0, + 'user_reminded_time' => 0, 'reset_token' => '', - 'reset_token_expiration' => '0', + 'reset_token_expiration' => 0, ); $this->assertEquals($expected, $this->provider->autologin()); -- cgit v1.2.1