|
3 | 3 | namespace unit\LucaDegasperi\OAuth2Server;
|
4 | 4 |
|
5 | 5 | use League\OAuth2\Server\AuthorizationServer;
|
| 6 | +use League\OAuth2\Server\Entity\AccessTokenEntity; |
| 7 | +use League\OAuth2\Server\Entity\ClientEntity; |
| 8 | +use League\OAuth2\Server\Entity\SessionEntity; |
6 | 9 | use League\OAuth2\Server\Grant\AuthCodeGrant;
|
7 | 10 | use League\OAuth2\Server\ResourceServer;
|
8 | 11 | use League\OAuth2\Server\TokenType\TokenTypeInterface;
|
@@ -47,36 +50,46 @@ function it_issues_an_auth_code(AuthorizationServer $issuer, AuthCodeGrant $auth
|
47 | 50 | $this->issueAuthCode('user', '1', ['foo' => 'bar'])->shouldReturn('baz');
|
48 | 51 | }
|
49 | 52 |
|
50 |
| - function it_returns_the_current_scopes(ResourceServer $checker) |
| 53 | + function it_returns_the_current_scopes(ResourceServer $checker, AccessTokenEntity $accessTokenEntity) |
51 | 54 | {
|
52 |
| - $checker->getScopes()->willReturn(['foo', 'bar'])->shouldBeCalled(); |
| 55 | + $accessTokenEntity->getScopes()->willReturn(['foo','bar']); |
| 56 | + $checker->getAccessToken()->willReturn($accessTokenEntity)->shouldBeCalled(); |
53 | 57 | $this->getScopes()->shouldReturn(['foo', 'bar']);
|
54 | 58 | }
|
55 | 59 |
|
56 |
| - function it_checks_if_a_scope_is_included_into_the_current_ones(ResourceServer $checker) |
| 60 | + function it_checks_if_a_scope_is_included_into_the_current_ones(ResourceServer $checker, AccessTokenEntity $accessTokenEntity) |
57 | 61 | {
|
58 |
| - $checker->hasScope('foo')->willReturn(true)->shouldBeCalled(); |
| 62 | + $accessTokenEntity->hasScope('foo')->willReturn(true)->shouldBeCalled(); |
| 63 | + $checker->getAccessToken()->willReturn($accessTokenEntity)->shouldBeCalled(); |
59 | 64 | $this->hasScope('foo')->shouldReturn(true);
|
60 | 65 |
|
61 |
| - $checker->hasScope(['foo', 'bar'])->willReturn(false)->shouldBeCalled(); |
| 66 | + $accessTokenEntity->hasScope(['foo', 'bar'])->willReturn(false)->shouldBecalled(); |
| 67 | + $checker->getAccessToken()->willReturn($accessTokenEntity)->shouldBeCalled(); |
62 | 68 | $this->hasScope(['foo', 'bar'])->shouldReturn(false);
|
63 | 69 | }
|
64 | 70 |
|
65 |
| - function it_returns_the_resource_owner_id(ResourceServer $checker) |
| 71 | + function it_returns_the_resource_owner_id(ResourceServer $checker, AccessTokenEntity $accessTokenEntity, SessionEntity $sessionEntity) |
66 | 72 | {
|
67 |
| - $checker->getOwnerId()->willReturn('1')->shouldBeCalled(); |
| 73 | + $sessionEntity->getOwnerId()->willReturn('1')->shouldBeCalled(); |
| 74 | + $accessTokenEntity->getSession()->willReturn($sessionEntity)->shouldBeCalled(); |
| 75 | + $checker->getAccessToken()->willReturn($accessTokenEntity)->shouldBeCalled(); |
68 | 76 | $this->getResourceOwnerId()->shouldReturn('1');
|
69 | 77 | }
|
70 | 78 |
|
71 |
| - function it_returns_the_resource_owner_type(ResourceServer $checker) |
| 79 | + function it_returns_the_resource_owner_type(ResourceServer $checker, AccessTokenEntity $accessTokenEntity, SessionEntity $sessionEntity) |
72 | 80 | {
|
73 |
| - $checker->getOwnerType()->willReturn('user')->shouldBeCalled(); |
| 81 | + $sessionEntity->getOwnerType()->willReturn('user')->shouldBeCalled(); |
| 82 | + $accessTokenEntity->getSession()->willReturn($sessionEntity)->shouldBeCalled(); |
| 83 | + $checker->getAccessToken()->willReturn($accessTokenEntity)->shouldBeCalled(); |
74 | 84 | $this->getResourceOwnerType()->shouldReturn('user');
|
75 | 85 | }
|
76 | 86 |
|
77 |
| - function it_returns_the_client_id(ResourceServer $checker) |
| 87 | + function it_returns_the_client_id(ResourceServer $checker, AccessTokenEntity $accessTokenEntity, SessionEntity $sessionEntity, ClientEntity $clientEntity) |
78 | 88 | {
|
79 |
| - $checker->getClientId()->willReturn('1')->shouldBeCalled(); |
| 89 | + $clientEntity->getId()->willReturn('1')->shouldBeCalled(); |
| 90 | + $sessionEntity->getClient()->willReturn($clientEntity)->shouldBeCalled(); |
| 91 | + $accessTokenEntity->getSession()->willReturn($sessionEntity)->shouldBeCalled(); |
| 92 | + $checker->getAccessToken()->willReturn($accessTokenEntity)->shouldBeCalled(); |
80 | 93 | $this->getClientId()->shouldReturn('1');
|
81 | 94 | }
|
82 | 95 |
|
|
0 commit comments