update composer libs
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -36,7 +36,7 @@ class Bootstrap
|
||||
{
|
||||
if (!$this->sqlite) {
|
||||
$this->removeSqliteDb();
|
||||
$pdo = new \PDO(sprintf('sqlite://%s', $this->getSqliteDir()));
|
||||
$pdo = new \PDO(sprintf('sqlite:%s', $this->getSqliteDir()));
|
||||
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
$this->createSqliteDb($pdo);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user