1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
require_once dirname(__FILE__).'/../../phpBB/includes/functions.php';
class phpbb_auth_provider_apache_test extends phpbb_database_test_case
{
protected $provider;
protected $user;
protected $request;
protected function setup()
{
parent::setUp();
global $phpbb_root_path, $phpEx;
$db = $this->new_dbal();
$config = new phpbb_config(array());
$this->request = $this->getMock('phpbb_request');
$this->user = $this->getMock('phpbb_user');
$this->provider = new phpbb_auth_provider_apache($db, $config, $this->request, $this->user, $phpbb_root_path, $phpEx);
}
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->user->data['username'] = 'foobar';
$this->request->overwrite('PHP_AUTH_USER', 'foobar', phpbb_request_interface::SERVER);
$this->assertFalse($this->provider->init());
}
public function test_login()
{
$username = 'foobar';
$password = 'example';
$this->request->overwrite('PHP_AUTH_USER', $username, phpbb_request_interface::SERVER);
$this->request->overwrite('PHP_AUTH_PW', $password, phpbb_request_interface::SERVER);
$expected = array(
'status' => LOGIN_SUCCESS,
'error_msg' => false,
'user_row' => array(
'user_id' => '1',
'username' => 'foobar',
'user_password' => '$H$9E45lK6J8nLTSm9oJE5aNCSTFK9wqa/',
'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->overwrite('PHP_AUTH_USER', 'foobar', phpbb_request_interface::SERVER);
$this->request->overwrite('PHP_AUTH_PW', 'example', phpbb_request_interface::SERVER);
$expected = array(
'status' => LOGIN_SUCCESS,
'error_msg' => false,
'user_row' => array(
'user_id' => '1',
'username' => 'foobar',
'username_clean' => 'foobar',
'user_password' => '$H$9E45lK6J8nLTSm9oJE5aNCSTFK9wqa/',
'user_passchg' => '0',
'user_pass_convert' => '0',
'user_email' => 'example@example.com',
'user_type' => '0',
'user_login_attempts' => '0',
'user_permission' => '',
'user_sig' => '',
'user_occ' => '',
'user_interests' => '',
),
);
$this->assertEquals($expected, $this->provider->autologin());
}
public function test_validate_session()
{
$this->markTestIncomplete();
}
}
|