-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #9 - Added compatibility for refresh tokens
- Loading branch information
1 parent
413d7dd
commit 754769b
Showing
2 changed files
with
83 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace League\OAuth2\Client\Test\Token; | ||
|
||
use League\OAuth2\Client\Token\AppleAccessToken; | ||
use PHPUnit\Framework\TestCase; | ||
use Mockery as m; | ||
|
||
class AppleAccessTokenTest extends TestCase | ||
{ | ||
public function tearDown() | ||
{ | ||
m::close(); | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
* @preserveGlobalState disabled | ||
*/ | ||
public function testCreatingAccessToken() | ||
{ | ||
$externalJWTMock = m::mock('overload:Firebase\JWT\JWT'); | ||
$externalJWTMock->shouldReceive('decode') | ||
->with('something', 'examplekey', ['RS256']) | ||
->once() | ||
->andReturn([ | ||
'sub' => '123.abc.123' | ||
]); | ||
|
||
$externalJWKMock = m::mock('overload:Firebase\JWT\JWK'); | ||
$externalJWKMock->shouldReceive('parseKeySet') | ||
->once() | ||
->andReturn(['examplekey']); | ||
|
||
$accessToken = new AppleAccessToken([ | ||
'access_token' => 'access_token', | ||
'token_type' => 'Bearer', | ||
'expires_in' => 3600, | ||
'refresh_token' => 'abc.0.def', | ||
'id_token' => 'something' | ||
]); | ||
$this->assertEquals('something', $accessToken->getIdToken()); | ||
$this->assertEquals('123.abc.123', $accessToken->getResourceOwnerId()); | ||
$this->assertEquals('access_token', $accessToken->getToken()); | ||
} | ||
|
||
public function testCreatingRefreshToken() | ||
{ | ||
$refreshToken = new AppleAccessToken([ | ||
'access_token' => 'access_token', | ||
'token_type' => 'Bearer', | ||
'expires_in' => 3600 | ||
]); | ||
$this->assertEquals('access_token', $refreshToken->getToken()); | ||
} | ||
} |