aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/bshaffer/oauth2-server-php/test/OAuth2
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/bshaffer/oauth2-server-php/test/OAuth2')
-rw-r--r--vendor/bshaffer/oauth2-server-php/test/OAuth2/RequestTest.php18
-rw-r--r--vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseTest.php23
-rw-r--r--vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseType/JwtAccessTokenTest.php21
-rw-r--r--vendor/bshaffer/oauth2-server-php/test/OAuth2/Storage/PdoTest.php8
4 files changed, 64 insertions, 6 deletions
diff --git a/vendor/bshaffer/oauth2-server-php/test/OAuth2/RequestTest.php b/vendor/bshaffer/oauth2-server-php/test/OAuth2/RequestTest.php
index cbf8f096b..770cd8994 100644
--- a/vendor/bshaffer/oauth2-server-php/test/OAuth2/RequestTest.php
+++ b/vendor/bshaffer/oauth2-server-php/test/OAuth2/RequestTest.php
@@ -86,6 +86,24 @@ class RequestTest extends TestCase
$this->assertEquals('correct', $request->query('client_id', $request->request('client_id')));
}
+ public function testRequestHasHeadersAndServerHeaders()
+ {
+ $request = new Request(
+ array(),
+ array(),
+ array(),
+ array(),
+ array(),
+ array('CONTENT_TYPE' => 'text/xml', 'PHP_AUTH_USER' => 'client_id', 'PHP_AUTH_PW' => 'client_pass'),
+ null,
+ array('CONTENT_TYPE' => 'application/json')
+ );
+
+ $this->assertSame('client_id', $request->headers('PHP_AUTH_USER'));
+ $this->assertSame('client_pass', $request->headers('PHP_AUTH_PW'));
+ $this->assertSame('application/json', $request->headers('CONTENT_TYPE'));
+ }
+
private function getTestServer($config = array())
{
$storage = Bootstrap::getInstance()->getMemoryStorage();
diff --git a/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseTest.php b/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseTest.php
index 2d2c57ee6..172bc88fd 100644
--- a/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseTest.php
+++ b/vendor/bshaffer/oauth2-server-php/test/OAuth2/ResponseTest.php
@@ -1,6 +1,8 @@
<?php
-namespace OAuth2;use PHPUnit\Framework\TestCase;
+namespace OAuth2;
+
+use PHPUnit\Framework\TestCase;
class ResponseTest extends TestCase
{
@@ -14,4 +16,23 @@ class ResponseTest extends TestCase
$string = $response->getResponseBody('xml');
$this->assertContains('<response><foo>bar</foo><halland>oates</halland></response>', $string);
}
+
+ public function testSetRedirect()
+ {
+ $response = new Response();
+ $url = 'https://foo/bar';
+ $state = 'stateparam';
+ $response->setRedirect(301, $url, $state);
+ $this->assertEquals(
+ sprintf('%s?state=%s', $url, $state),
+ $response->getHttpHeader('Location')
+ );
+
+ $query = 'query=foo';
+ $response->setRedirect(301, $url . '?' . $query, $state);
+ $this->assertEquals(
+ sprintf('%s?%s&state=%s', $url, $query, $state),
+ $response->getHttpHeader('Location')
+ );
+ }
}
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;
diff --git a/vendor/bshaffer/oauth2-server-php/test/OAuth2/Storage/PdoTest.php b/vendor/bshaffer/oauth2-server-php/test/OAuth2/Storage/PdoTest.php
index 57eb39072..4599f69bf 100644
--- a/vendor/bshaffer/oauth2-server-php/test/OAuth2/Storage/PdoTest.php
+++ b/vendor/bshaffer/oauth2-server-php/test/OAuth2/Storage/PdoTest.php
@@ -6,7 +6,8 @@ class PdoTest extends BaseTest
{
public function testCreatePdoStorageUsingPdoClass()
{
- $pdo = new \PDO(sprintf('sqlite://%s', Bootstrap::getInstance()->getSqliteDir()));
+ $dsn = sprintf('sqlite:%s', Bootstrap::getInstance()->getSqliteDir());
+ $pdo = new \PDO($dsn);
$storage = new Pdo($pdo);
$this->assertNotNull($storage->getClientDetails('oauth_test_client'));
@@ -14,7 +15,7 @@ class PdoTest extends BaseTest
public function testCreatePdoStorageUsingDSN()
{
- $dsn = sprintf('sqlite://%s', Bootstrap::getInstance()->getSqliteDir());
+ $dsn = sprintf('sqlite:%s', Bootstrap::getInstance()->getSqliteDir());
$storage = new Pdo($dsn);
$this->assertNotNull($storage->getClientDetails('oauth_test_client'));
@@ -22,7 +23,8 @@ class PdoTest extends BaseTest
public function testCreatePdoStorageUsingConfig()
{
- $config = array('dsn' => sprintf('sqlite://%s', Bootstrap::getInstance()->getSqliteDir()));
+ $dsn = sprintf('sqlite:%s', Bootstrap::getInstance()->getSqliteDir());
+ $config = array('dsn' => $dsn);
$storage = new Pdo($config);
$this->assertNotNull($storage->getClientDetails('oauth_test_client'));