aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php')
-rw-r--r--vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php b/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php
index 7e37509ef..6195d557a 100644
--- a/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php
+++ b/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php
@@ -40,6 +40,23 @@ class JwtAccessTokenTest extends TestCase
$this->assertEquals(3600, $delta);
$this->assertEquals($decodedAccessToken['id'], $decodedAccessToken['jti']);
}
+
+ public function testExtraPayloadCallback()
+ {
+ $jwtconfig = array('jwt_extra_payload_callable' => function() {
+ return array('custom_param' => 'custom_value');
+ });
+
+ $server = $this->getTestServer($jwtconfig);
+ $jwtResponseType = $server->getResponseType('token');
+
+ $accessToken = $jwtResponseType->createAccessToken('Test Client ID', 123, 'test', false);
+ $jwt = new Jwt;
+ $decodedAccessToken = $jwt->decode($accessToken['access_token'], null, false);
+
+ $this->assertArrayHasKey('custom_param', $decodedAccessToken);
+ $this->assertEquals('custom_value', $decodedAccessToken['custom_param']);
+ }
public function testGrantJwtAccessToken()
{
@@ -140,7 +157,7 @@ class JwtAccessTokenTest extends TestCase
$this->assertNotNull($response->getParameter('access_token'));
}
- private function getTestServer()
+ private function getTestServer($jwtconfig = array())
{
$memoryStorage = Bootstrap::getInstance()->getMemoryStorage();
@@ -153,7 +170,7 @@ class JwtAccessTokenTest extends TestCase
$server->addGrantType(new ClientCredentials($memoryStorage));
// make the "token" response type a JwtAccessToken
- $config = array('issuer' => 'https://api.example.com');
+ $config = array_merge(array('issuer' => 'https://api.example.com'), $jwtconfig);
$server->addResponseType(new JwtAccessToken($memoryStorage, $memoryStorage, null, $config));
return $server;