|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Nord\Lumen\OAuth2\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Helper\Unit; |
|
6
|
|
|
use Nord\Lumen\OAuth2\OAuth2Service; |
|
7
|
|
|
|
|
8
|
|
|
class OAuth2ServiceTest extends \Codeception\Test\Unit |
|
9
|
|
|
{ |
|
10
|
|
|
use \Codeception\Specify; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @var OAuth2Service |
|
14
|
|
|
*/ |
|
15
|
|
|
private $service; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @inheritdoc |
|
19
|
|
|
*/ |
|
20
|
|
|
protected function setup() |
|
21
|
|
|
{ |
|
22
|
|
|
Unit::setAuthorizationHeader(); |
|
23
|
|
|
$this->service = new OAuth2Service(Unit::createAuthorizationServer(), Unit::createResourceServer()); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* |
|
28
|
|
|
*/ |
|
29
|
|
|
public function testAssertIssueAccessToken() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->specify('verify service issueAccessToken', function () { |
|
32
|
|
|
verify($this->service->issueAccessToken())->equals(MockAccessToken::toArray()); |
|
33
|
|
|
}); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* |
|
38
|
|
|
*/ |
|
39
|
|
|
public function testAssertValidateAccessToken() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->specify('verify service validateAccessToken', function () { |
|
42
|
|
|
verify($this->service->validateAccessToken())->true(); |
|
43
|
|
|
}); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* |
|
48
|
|
|
*/ |
|
49
|
|
|
public function testAssertGetResourceOwnerId() |
|
50
|
|
|
{ |
|
51
|
|
|
$this->specify('verify service can getResourceOwnerId', function () { |
|
52
|
|
|
$this->service->validateAccessToken(); |
|
53
|
|
|
verify($this->service->getResourceOwnerId())->equals('test'); |
|
54
|
|
|
}); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* |
|
59
|
|
|
*/ |
|
60
|
|
|
public function testAssertGetResourceOwnerType() |
|
61
|
|
|
{ |
|
62
|
|
|
$this->specify('verify service can getResourceOwnerType', function () { |
|
63
|
|
|
$this->service->validateAccessToken(); |
|
64
|
|
|
verify($this->service->getResourceOwnerType())->equals('test'); |
|
65
|
|
|
}); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* |
|
70
|
|
|
*/ |
|
71
|
|
|
public function testAssertGetClientId() |
|
72
|
|
|
{ |
|
73
|
|
|
$this->specify('verify service can getClientId', function () { |
|
74
|
|
|
$this->service->validateAccessToken(); |
|
75
|
|
|
verify($this->service->getClientId())->equals('test'); |
|
76
|
|
|
}); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|