Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 42 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_auth_provider_ldap_test | |
0.00% |
0 / 42 |
|
0.00% |
0 / 6 |
72 | |
0.00% |
0 / 1 |
| setUp | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
2 | |||
| getDataSet | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| test_init | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| test_login | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
6 | |||
| test_autologin | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| test_validate_session | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | /** |
| 15 | * @group slow |
| 16 | */ |
| 17 | class phpbb_auth_provider_ldap_test extends phpbb_database_test_case |
| 18 | { |
| 19 | /** @var \phpbb\auth\provider\ldap */ |
| 20 | protected $provider; |
| 21 | |
| 22 | /** @var \phpbb\user */ |
| 23 | protected $user; |
| 24 | |
| 25 | protected function setUp() : void |
| 26 | { |
| 27 | parent::setUp(); |
| 28 | |
| 29 | global $phpbb_root_path, $phpEx; |
| 30 | |
| 31 | $db = $this->new_dbal(); |
| 32 | $config = new \phpbb\config\config([ |
| 33 | 'ldap_server' => 'localhost', |
| 34 | 'ldap_port' => 3389, |
| 35 | 'ldap_base_dn' => 'dc=example,dc=com', |
| 36 | 'ldap_uid' => 'uid', |
| 37 | 'ldap_email' => 'mail', |
| 38 | ]); |
| 39 | $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); |
| 40 | $lang = new \phpbb\language\language($lang_loader); |
| 41 | $this->user = new \phpbb\user($lang, '\phpbb\datetime'); |
| 42 | $this->user->data['username'] = 'admin'; |
| 43 | |
| 44 | $this->provider = new \phpbb\auth\provider\ldap($config, $db, $lang, $this->user); |
| 45 | } |
| 46 | |
| 47 | public function getDataSet() |
| 48 | { |
| 49 | return $this->createXMLDataSet(__DIR__ . '/fixtures/user.xml'); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Test to see if a user is identified to Apache. Expects false if they are. |
| 54 | */ |
| 55 | public function test_init() |
| 56 | { |
| 57 | if (!extension_loaded('ldap')) |
| 58 | { |
| 59 | $this->markTestSkipped('LDAP extension not available.'); |
| 60 | } |
| 61 | |
| 62 | $this->assertFalse($this->provider->init()); |
| 63 | } |
| 64 | |
| 65 | public function test_login() |
| 66 | { |
| 67 | if (!extension_loaded('ldap')) |
| 68 | { |
| 69 | $this->markTestSkipped('LDAP extension not available.'); |
| 70 | } |
| 71 | |
| 72 | $username = 'admin'; |
| 73 | $password = 'adminadmin'; |
| 74 | |
| 75 | $expected = array( |
| 76 | 'status' => LOGIN_SUCCESS_CREATE_PROFILE, // successful login and user created |
| 77 | 'error_msg' => false, |
| 78 | 'user_row' => array( |
| 79 | 'username' => 'admin', |
| 80 | 'user_password' => '', |
| 81 | 'user_email' => 'admin@example.com', |
| 82 | 'user_type' => 0, |
| 83 | 'group_id' => 1, |
| 84 | 'user_new' => 0, |
| 85 | 'user_ip' => '', |
| 86 | ), |
| 87 | ); |
| 88 | |
| 89 | $this->assertEquals($expected, $this->provider->login($username, $password)); |
| 90 | } |
| 91 | |
| 92 | public function test_autologin() |
| 93 | { |
| 94 | $this->assertNull($this->provider->autologin()); |
| 95 | } |
| 96 | |
| 97 | public function test_validate_session() |
| 98 | { |
| 99 | $user = array( |
| 100 | 'username' => 'admin', |
| 101 | ); |
| 102 | |
| 103 | $this->assertNull($this->provider->validate_session($user)); |
| 104 | } |
| 105 | } |