blob: 22852805263a5be99561e7362435612b84f00ea3 (
plain)
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
|
<?php
use Kanboard\Auth\ApiAccessTokenAuth;
use Kanboard\Model\UserModel;
require_once __DIR__.'/../Base.php';
class ApiAccessTokenAuthTest extends Base
{
public function testGetName()
{
$provider = new ApiAccessTokenAuth($this->container);
$this->assertEquals('API Access Token', $provider->getName());
}
public function testAuthenticateWithoutToken()
{
$provider = new ApiAccessTokenAuth($this->container);
$provider->setUsername('admin');
$provider->setPassword('admin');
$this->assertFalse($provider->authenticate());
$this->assertNull($provider->getUser());
}
public function testAuthenticateWithEmptyPassword()
{
$provider = new ApiAccessTokenAuth($this->container);
$provider->setUsername('admin');
$provider->setPassword('');
$this->assertFalse($provider->authenticate());
}
public function testAuthenticateWithTokenAndNoScope()
{
$provider = new ApiAccessTokenAuth($this->container);
$userModel = new UserModel($this->container);
$userModel->update(array(
'id' => 1,
'api_access_token' => 'test',
));
$provider->setUsername('admin');
$provider->setPassword('test');
$this->assertFalse($provider->authenticate());
}
public function testAuthenticateWithToken()
{
$this->container['sessionStorage']->scope = 'API';
$provider = new ApiAccessTokenAuth($this->container);
$userModel = new UserModel($this->container);
$userModel->update(array(
'id' => 1,
'api_access_token' => 'test',
));
$provider->setUsername('admin');
$provider->setPassword('test');
$this->assertTrue($provider->authenticate());
$this->assertInstanceOf('Kanboard\User\DatabaseUserProvider', $provider->getUser());
$provider->setUsername('admin');
$provider->setPassword('something else');
$this->assertFalse($provider->authenticate());
}
}
|