|
1
|
|
|
<?php
|
|
2
|
|
|
/**
|
|
3
|
|
|
* OpenFireRestAPI is based entirely on official documentation of the REST API
|
|
4
|
|
|
* Plugin and you can extend it by following the directives of the documentation
|
|
5
|
|
|
*
|
|
6
|
|
|
* For the full copyright and license information, please read the LICENSE
|
|
7
|
|
|
* file that was distributed with this source code. For the full list of
|
|
8
|
|
|
* contributors, visit https://github.com/gnello/PHPOpenFireRestAPI/contributors
|
|
9
|
|
|
*
|
|
10
|
|
|
* @author Luca Agnello <[email protected]>
|
|
11
|
|
|
* @link https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html
|
|
12
|
|
|
*/
|
|
13
|
|
|
|
|
14
|
|
|
namespace Gnello\OpenFireRestAPI;
|
|
15
|
|
|
|
|
16
|
|
|
/**
|
|
17
|
|
|
* Class AuthenticationTokenTest
|
|
18
|
|
|
* @package Gnello\OpenFireRestAPI
|
|
19
|
|
|
*/
|
|
20
|
|
|
class AuthenticationTokenTest extends \PHPUnit_Framework_TestCase
|
|
21
|
|
|
{
|
|
22
|
|
|
public function testAuthenticationTokenGetAuthModeBase()
|
|
23
|
|
|
{
|
|
24
|
|
|
$fixture = new AuthenticationToken('username', 'password');
|
|
25
|
|
|
$this->assertEquals(AuthenticationToken::AUTH_BASE, $fixture->getAuthMode());
|
|
26
|
|
|
}
|
|
27
|
|
|
|
|
28
|
|
|
public function testAuthenticationTokenGetAuthModeSharedSecretKey()
|
|
29
|
|
|
{
|
|
30
|
|
|
$fixture = new AuthenticationToken('shared_secret_key');
|
|
31
|
|
|
$this->assertEquals(AuthenticationToken::AUTH_SECRET_KEY, $fixture->getAuthMode());
|
|
32
|
|
|
}
|
|
33
|
|
|
|
|
34
|
|
|
public function testAuthenticationTokenGetAuthModeNotBase()
|
|
35
|
|
|
{
|
|
36
|
|
|
$fixture = new AuthenticationToken('username', 'password', 'shared_secret_key');
|
|
37
|
|
|
$this->assertNotEquals(AuthenticationToken::AUTH_BASE, $fixture->getAuthMode());
|
|
38
|
|
|
}
|
|
39
|
|
|
|
|
40
|
|
|
public function testAuthenticationTokenGetAuthModeNotSharedSecretKey()
|
|
41
|
|
|
{
|
|
42
|
|
|
$fixture = new AuthenticationToken('username', 'password', 'shared_secret_key');
|
|
43
|
|
|
$this->assertNotEquals(AuthenticationToken::AUTH_SECRET_KEY, $fixture->getAuthMode());
|
|
44
|
|
|
}
|
|
45
|
|
|
|
|
46
|
|
|
public function testAuthenticationTokenGetAuthTokenBase()
|
|
47
|
|
|
{
|
|
48
|
|
|
$fixture = new AuthenticationToken('username', 'password');
|
|
49
|
|
|
$this->assertEquals("basic " . base64_encode("username:password"), $fixture->getAuthToken());
|
|
50
|
|
|
}
|
|
51
|
|
|
|
|
52
|
|
|
public function testAuthenticationTokenGetAuthTokenSharedSecretKey()
|
|
53
|
|
|
{
|
|
54
|
|
|
$fixture = new AuthenticationToken('shared_secret_key');
|
|
55
|
|
|
$this->assertEquals('shared_secret_key', $fixture->getAuthToken());
|
|
56
|
|
|
}
|
|
57
|
|
|
|
|
58
|
|
|
public function testAuthenticationTokenGetAuthTokenNull()
|
|
59
|
|
|
{
|
|
60
|
|
|
$fixture = new AuthenticationToken('username', 'password', 'shared_secret_key');
|
|
61
|
|
|
$this->assertNull($fixture->getAuthToken());
|
|
62
|
|
|
}
|
|
63
|
|
|
|
|
64
|
|
|
public function testAuthenticationTokenGetSharedSecretKey()
|
|
65
|
|
|
{
|
|
66
|
|
|
$fixture = new AuthenticationToken('shared_secret_key');
|
|
67
|
|
|
$this->assertEquals('shared_secret_key', $fixture->getSharedSecretKey());
|
|
68
|
|
|
}
|
|
69
|
|
|
|
|
70
|
|
|
public function testAuthenticationTokenGetUsername()
|
|
71
|
|
|
{
|
|
72
|
|
|
$fixture = new AuthenticationToken('username', 'password');
|
|
73
|
|
|
$this->assertEquals('username', $fixture->getUsername());
|
|
74
|
|
|
}
|
|
75
|
|
|
|
|
76
|
|
|
public function testAuthenticationTokenGetPassword()
|
|
77
|
|
|
{
|
|
78
|
|
|
$fixture = new AuthenticationToken('username', 'password');
|
|
79
|
|
|
$this->assertEquals('password', $fixture->getPassword());
|
|
80
|
|
|
}
|
|
81
|
|
|
} |