mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-09 02:06:32 +02:00
Merge branch '3.3.x'
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_groups">
|
||||
<column>group_id</column>
|
||||
<column>group_name</column>
|
||||
<column>group_type</column>
|
||||
<column>group_desc</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>REGISTERED</value>
|
||||
<value>3</value>
|
||||
<value>foobar</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_users">
|
||||
<column>user_id</column>
|
||||
<column>username</column>
|
||||
|
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_users">
|
||||
<column>user_id</column>
|
||||
<column>username</column>
|
||||
<column>username_clean</column>
|
||||
<column>user_password</column>
|
||||
<column>user_passchg</column>
|
||||
<column>user_email</column>
|
||||
<column>user_type</column>
|
||||
<column>user_login_attempts</column>
|
||||
<column>user_permissions</column>
|
||||
<column>user_sig</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>foobar</value>
|
||||
<value>foobar</value>
|
||||
<value>$2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi</value>
|
||||
<value>0</value>
|
||||
<value>example@example.com</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>foobar2</value>
|
||||
<value>foobar2</value>
|
||||
<value>$H$9E45lK6J8nLTSm9oJE5aNCSTFK9wqa/</value>
|
||||
<value>0</value>
|
||||
<value>example@example.com</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
@@ -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),
|
||||
);
|
||||
$this->user = new \phpbb\user($lang, '\phpbb\datetime');;
|
||||
|
||||
$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->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',
|
||||
|
@@ -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()
|
||||
@@ -52,16 +45,21 @@ 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);
|
||||
if (version_compare(PHP_VERSION, '5.3.7', '<'))
|
||||
{
|
||||
$password_hash = '$2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi';
|
||||
}
|
||||
else
|
||||
{
|
||||
$password_hash = '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i';
|
||||
}
|
||||
$provider = new \phpbb\auth\provider\db($captcha_factory, $config, $db, $passwords_manager, $request, $user, $phpbb_root_path, $phpEx);
|
||||
$password_hash = '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i';
|
||||
|
||||
$expected = array(
|
||||
'status' => LOGIN_SUCCESS,
|
||||
@@ -88,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']);
|
||||
}
|
||||
}
|
||||
|
94
tests/auth/provider_ldap_test.php
Normal file
94
tests/auth/provider_ldap_test.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group slow
|
||||
*/
|
||||
class phpbb_auth_provider_ldap_test extends phpbb_database_test_case
|
||||
{
|
||||
/** @var \phpbb\auth\provider\ldap */
|
||||
protected $provider;
|
||||
|
||||
protected $user;
|
||||
|
||||
protected function setup() : void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$db = $this->new_dbal();
|
||||
$config = new \phpbb\config\config([
|
||||
'ldap_server' => 'localhost',
|
||||
'ldap_port' => 3389,
|
||||
'ldap_base_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->user->data['username'] = 'admin';
|
||||
|
||||
$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 = 'admin';
|
||||
$password = 'adminadmin';
|
||||
|
||||
$expected = array(
|
||||
'status' => LOGIN_SUCCESS_CREATE_PROFILE, // successful login and user created
|
||||
'error_msg' => false,
|
||||
'user_row' => array(
|
||||
'username' => 'admin',
|
||||
'user_password' => '',
|
||||
'user_email' => 'admin@example.com',
|
||||
'user_type' => 0,
|
||||
'group_id' => 1,
|
||||
'user_new' => 0,
|
||||
'user_ip' => '',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $this->provider->login($username, $password));
|
||||
}
|
||||
|
||||
public function test_autologin()
|
||||
{
|
||||
$this->assertNull($this->provider->autologin());
|
||||
}
|
||||
|
||||
public function test_validate_session()
|
||||
{
|
||||
$user = array(
|
||||
'username' => 'admin',
|
||||
);
|
||||
|
||||
$this->assertNull($this->provider->validate_session($user));
|
||||
}
|
||||
}
|
@@ -60,13 +60,34 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case
|
||||
// Set up passwords manager
|
||||
$passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
|
||||
|
||||
$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()
|
||||
);
|
||||
// Set up passwords manager
|
||||
$db_auth_provider = new \phpbb\auth\provider\db(
|
||||
new \phpbb\captcha\factory($phpbb_container, $plugins),
|
||||
$config,
|
||||
$db,
|
||||
$passwords_manager,
|
||||
$request,
|
||||
$user,
|
||||
$phpbb_root_path,
|
||||
$phpEx
|
||||
);
|
||||
|
||||
$oauth_provider = new \phpbb\auth\provider\oauth\oauth(
|
||||
$config,
|
||||
$phpbb_container,
|
||||
$db,
|
||||
$db_auth_provider,
|
||||
$phpbb_dispatcher,
|
||||
$lang,
|
||||
$passwords_manager,
|
||||
$request,
|
||||
$oauth_provider_collection,
|
||||
$user,
|
||||
|
@@ -51,26 +51,13 @@ class phpbb_passwords_manager_test extends \phpbb_test_case
|
||||
|
||||
public function hash_password_data()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.3.7', '<'))
|
||||
{
|
||||
return array(
|
||||
array('', '2a', 60),
|
||||
array('passwords.driver.bcrypt_2y', '2a', 60),
|
||||
array('passwords.driver.bcrypt', '2a', 60),
|
||||
array('passwords.driver.salted_md5', 'H', 34),
|
||||
array('passwords.driver.foobar', '', false),
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(
|
||||
array('', '2y', 60),
|
||||
array('passwords.driver.bcrypt_2y', '2y', 60),
|
||||
array('passwords.driver.bcrypt', '2a', 60),
|
||||
array('passwords.driver.salted_md5', 'H', 34),
|
||||
array('passwords.driver.foobar', '', false),
|
||||
);
|
||||
}
|
||||
return array(
|
||||
array('', '2y', 60),
|
||||
array('passwords.driver.bcrypt_2y', '2y', 60),
|
||||
array('passwords.driver.bcrypt', '2a', 60),
|
||||
array('passwords.driver.salted_md5', 'H', 34),
|
||||
array('passwords.driver.foobar', '', false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,23 +87,12 @@ class phpbb_passwords_manager_test extends \phpbb_test_case
|
||||
|
||||
public function check_password_data()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.3.7', '<'))
|
||||
{
|
||||
return array(
|
||||
array('passwords.driver.bcrypt'),
|
||||
array('passwords.driver.salted_md5'),
|
||||
array('passwords.driver.phpass'),
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(
|
||||
array('passwords.driver.bcrypt_2y'),
|
||||
array('passwords.driver.bcrypt'),
|
||||
array('passwords.driver.salted_md5'),
|
||||
array('passwords.driver.phpass'),
|
||||
);
|
||||
}
|
||||
return array(
|
||||
array('passwords.driver.bcrypt_2y'),
|
||||
array('passwords.driver.bcrypt'),
|
||||
array('passwords.driver.salted_md5'),
|
||||
array('passwords.driver.phpass'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +112,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case
|
||||
}
|
||||
|
||||
// Check if convert_flag is correctly set
|
||||
$default_type = (version_compare(PHP_VERSION, '5.3.7', '<')) ? 'passwords.driver.bcrypt' : 'passwords.driver.bcrypt_2y';
|
||||
$default_type = 'passwords.driver.bcrypt_2y';
|
||||
$this->assertEquals(($hash_type !== $default_type), $this->manager->convert_flag);
|
||||
}
|
||||
|
||||
@@ -200,79 +176,43 @@ class phpbb_passwords_manager_test extends \phpbb_test_case
|
||||
public function test_hash_password_8bit_bcrypt()
|
||||
{
|
||||
$this->assertEquals(false, $this->manager->hash('foobar𝄞', 'passwords.driver.bcrypt'));
|
||||
if (version_compare(PHP_VERSION, '5.3.7', '<'))
|
||||
{
|
||||
$this->assertEquals(false, $this->manager->hash('foobar𝄞', 'passwords.driver.bcrypt_2y'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->assertNotEquals(false, $this->manager->hash('foobar𝄞', 'passwords.driver.bcrypt_2y'));
|
||||
}
|
||||
$this->assertNotEquals(false, $this->manager->hash('foobar𝄞', 'passwords.driver.bcrypt_2y'));
|
||||
}
|
||||
|
||||
public function combined_hash_data()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.3.7', '<'))
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.bcrypt'),
|
||||
),
|
||||
array(
|
||||
'passwords.driver.phpass',
|
||||
array('passwords.driver.salted_md5'),
|
||||
),
|
||||
array(
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.phpass', 'passwords.driver.bcrypt'),
|
||||
),
|
||||
array(
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.salted_md5'),
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'$H$',
|
||||
array('$2a$'),
|
||||
),
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.bcrypt_2y'),
|
||||
),
|
||||
array(
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.bcrypt'),
|
||||
),
|
||||
array(
|
||||
'passwords.driver.phpass',
|
||||
array('passwords.driver.salted_md5'),
|
||||
),
|
||||
array(
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.bcrypt_2y', 'passwords.driver.bcrypt'),
|
||||
),
|
||||
array(
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.salted_md5'),
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'passwords.driver.bcrypt_2y',
|
||||
array('passwords.driver.salted_md4'),
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'$H$',
|
||||
array('$2y$'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return array(
|
||||
array(
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.bcrypt_2y'),
|
||||
),
|
||||
array(
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.bcrypt'),
|
||||
),
|
||||
array(
|
||||
'passwords.driver.phpass',
|
||||
array('passwords.driver.salted_md5'),
|
||||
),
|
||||
array(
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.bcrypt_2y', 'passwords.driver.bcrypt'),
|
||||
),
|
||||
array(
|
||||
'passwords.driver.salted_md5',
|
||||
array('passwords.driver.salted_md5'),
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'passwords.driver.bcrypt_2y',
|
||||
array('passwords.driver.salted_md4'),
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'$H$',
|
||||
array('$2y$'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user