2016-02-18 17:37:50 +05:30
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace LeagueTests;
|
|
|
|
|
2018-11-08 15:11:01 +05:30
|
|
|
use DateInterval;
|
2016-04-17 17:36:17 +05:30
|
|
|
use League\OAuth2\Server\AuthorizationServer;
|
2018-11-02 20:08:07 +05:30
|
|
|
use League\OAuth2\Server\CryptKey;
|
2016-03-10 22:04:32 +05:30
|
|
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
|
|
|
use League\OAuth2\Server\Grant\AuthCodeGrant;
|
2016-02-18 17:37:50 +05:30
|
|
|
use League\OAuth2\Server\Grant\ClientCredentialsGrant;
|
|
|
|
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
2016-03-10 22:04:32 +05:30
|
|
|
use League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface;
|
2016-02-20 04:39:39 +05:30
|
|
|
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
2016-03-10 22:04:32 +05:30
|
|
|
use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface;
|
2016-02-18 17:37:50 +05:30
|
|
|
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
|
2016-04-10 20:28:01 +05:30
|
|
|
use League\OAuth2\Server\RequestTypes\AuthorizationRequest;
|
2016-03-10 22:04:32 +05:30
|
|
|
use League\OAuth2\Server\ResponseTypes\BearerTokenResponse;
|
2016-04-09 20:16:40 +05:30
|
|
|
use LeagueTests\Stubs\AccessTokenEntity;
|
|
|
|
use LeagueTests\Stubs\AuthCodeEntity;
|
2016-03-15 05:40:47 +05:30
|
|
|
use LeagueTests\Stubs\ClientEntity;
|
2017-10-19 02:41:13 +05:30
|
|
|
use LeagueTests\Stubs\ScopeEntity;
|
2016-02-20 04:39:39 +05:30
|
|
|
use LeagueTests\Stubs\StubResponseType;
|
2016-03-18 04:55:32 +05:30
|
|
|
use LeagueTests\Stubs\UserEntity;
|
2017-11-08 23:37:07 +05:30
|
|
|
use PHPUnit\Framework\TestCase;
|
2018-02-18 01:01:59 +05:30
|
|
|
use Psr\Http\Message\ResponseInterface;
|
2016-03-18 04:55:32 +05:30
|
|
|
use Zend\Diactoros\Response;
|
2016-04-10 20:28:01 +05:30
|
|
|
use Zend\Diactoros\ServerRequest;
|
2016-03-18 04:55:32 +05:30
|
|
|
use Zend\Diactoros\ServerRequestFactory;
|
2016-02-18 17:37:50 +05:30
|
|
|
|
2017-11-08 23:37:07 +05:30
|
|
|
class AuthorizationServerTest extends TestCase
|
2016-02-18 17:37:50 +05:30
|
|
|
{
|
2017-11-14 04:01:50 +05:30
|
|
|
const DEFAULT_SCOPE = 'basic';
|
2017-10-19 02:41:13 +05:30
|
|
|
|
2019-06-27 17:24:22 +05:30
|
|
|
public function setUp(): void
|
2017-08-01 18:29:21 +05:30
|
|
|
{
|
|
|
|
// Make sure the keys have the correct permissions.
|
|
|
|
chmod(__DIR__ . '/Stubs/private.key', 0600);
|
|
|
|
chmod(__DIR__ . '/Stubs/public.key', 0600);
|
2017-10-31 14:44:46 +05:30
|
|
|
chmod(__DIR__ . '/Stubs/private.key.crlf', 0600);
|
2017-08-01 18:29:21 +05:30
|
|
|
}
|
|
|
|
|
2016-02-18 17:37:50 +05:30
|
|
|
public function testRespondToRequestInvalidGrantType()
|
|
|
|
{
|
2016-04-17 17:24:25 +05:30
|
|
|
$server = new AuthorizationServer(
|
2016-07-08 18:59:21 +05:30
|
|
|
$this->getMockBuilder(ClientRepositoryInterface::class)->getMock(),
|
|
|
|
$this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
|
|
|
|
$this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
|
2016-03-28 20:40:41 +05:30
|
|
|
'file://' . __DIR__ . '/Stubs/private.key',
|
2017-07-01 22:41:19 +05:30
|
|
|
base64_encode(random_bytes(36)),
|
2016-02-18 17:37:50 +05:30
|
|
|
new StubResponseType()
|
|
|
|
);
|
|
|
|
|
2018-11-08 15:11:01 +05:30
|
|
|
$server->enableGrantType(new ClientCredentialsGrant(), new DateInterval('PT1M'));
|
2016-02-18 17:37:50 +05:30
|
|
|
|
2016-03-11 04:53:29 +05:30
|
|
|
try {
|
2016-04-09 20:50:30 +05:30
|
|
|
$server->respondToAccessTokenRequest(ServerRequestFactory::fromGlobals(), new Response);
|
2016-03-11 04:53:29 +05:30
|
|
|
} catch (OAuthServerException $e) {
|
|
|
|
$this->assertEquals('unsupported_grant_type', $e->getErrorType());
|
|
|
|
$this->assertEquals(400, $e->getHttpStatusCode());
|
|
|
|
}
|
2016-02-18 17:37:50 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
public function testRespondToRequest()
|
|
|
|
{
|
2019-07-23 03:04:54 +05:30
|
|
|
$client = new ClientEntity();
|
|
|
|
$client->setConfidential();
|
|
|
|
|
2016-07-08 18:59:21 +05:30
|
|
|
$clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
|
2019-07-23 03:04:54 +05:30
|
|
|
$clientRepository->method('getClientEntity')->willReturn($client);
|
2016-02-18 17:37:50 +05:30
|
|
|
|
2017-10-19 02:41:13 +05:30
|
|
|
$scope = new ScopeEntity();
|
2016-03-24 00:20:14 +05:30
|
|
|
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
|
2017-10-19 02:41:13 +05:30
|
|
|
$scopeRepositoryMock->method('getScopeEntityByIdentifier')->willReturn($scope);
|
2016-03-24 00:20:14 +05:30
|
|
|
$scopeRepositoryMock->method('finalizeScopes')->willReturnArgument(0);
|
|
|
|
|
2016-07-08 18:59:21 +05:30
|
|
|
$accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock();
|
2016-03-25 18:39:26 +05:30
|
|
|
$accessTokenRepositoryMock->method('getNewToken')->willReturn(new AccessTokenEntity());
|
|
|
|
|
2016-04-17 17:24:25 +05:30
|
|
|
$server = new AuthorizationServer(
|
2016-02-18 17:37:50 +05:30
|
|
|
$clientRepository,
|
2016-03-25 18:39:26 +05:30
|
|
|
$accessTokenRepositoryMock,
|
2016-03-24 00:20:14 +05:30
|
|
|
$scopeRepositoryMock,
|
2016-03-28 20:40:41 +05:30
|
|
|
'file://' . __DIR__ . '/Stubs/private.key',
|
2017-07-01 22:41:19 +05:30
|
|
|
base64_encode(random_bytes(36)),
|
2016-02-18 17:37:50 +05:30
|
|
|
new StubResponseType()
|
|
|
|
);
|
|
|
|
|
2017-10-31 05:18:02 +05:30
|
|
|
$server->setDefaultScope(self::DEFAULT_SCOPE);
|
2018-11-08 15:11:01 +05:30
|
|
|
$server->enableGrantType(new ClientCredentialsGrant(), new DateInterval('PT1M'));
|
2016-02-18 17:37:50 +05:30
|
|
|
|
|
|
|
$_POST['grant_type'] = 'client_credentials';
|
|
|
|
$_POST['client_id'] = 'foo';
|
|
|
|
$_POST['client_secret'] = 'bar';
|
2016-04-09 20:50:30 +05:30
|
|
|
$response = $server->respondToAccessTokenRequest(ServerRequestFactory::fromGlobals(), new Response);
|
2016-02-18 17:37:50 +05:30
|
|
|
$this->assertEquals(200, $response->getStatusCode());
|
|
|
|
}
|
2016-03-10 22:04:32 +05:30
|
|
|
|
2016-04-10 20:28:01 +05:30
|
|
|
public function testGetResponseType()
|
2016-03-10 22:04:32 +05:30
|
|
|
{
|
2016-07-08 18:59:21 +05:30
|
|
|
$clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
|
2016-03-24 00:20:14 +05:30
|
|
|
|
2016-04-17 17:24:25 +05:30
|
|
|
$server = new AuthorizationServer(
|
2016-03-10 22:04:32 +05:30
|
|
|
$clientRepository,
|
2016-07-08 18:59:21 +05:30
|
|
|
$this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
|
|
|
|
$this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
|
2016-03-18 04:55:32 +05:30
|
|
|
'file://' . __DIR__ . '/Stubs/private.key',
|
2016-04-10 20:28:01 +05:30
|
|
|
'file://' . __DIR__ . '/Stubs/public.key'
|
2016-03-10 22:04:32 +05:30
|
|
|
);
|
|
|
|
|
2016-04-10 20:28:01 +05:30
|
|
|
$abstractGrantReflection = new \ReflectionClass($server);
|
|
|
|
$method = $abstractGrantReflection->getMethod('getResponseType');
|
|
|
|
$method->setAccessible(true);
|
2016-03-18 04:55:32 +05:30
|
|
|
|
2017-12-07 01:54:42 +05:30
|
|
|
$this->assertInstanceOf(BearerTokenResponse::class, $method->invoke($server));
|
2016-04-10 20:28:01 +05:30
|
|
|
}
|
2016-04-17 17:36:17 +05:30
|
|
|
|
2018-11-16 17:27:37 +05:30
|
|
|
public function testGetResponseTypeExtended()
|
|
|
|
{
|
|
|
|
$clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
|
|
|
|
$privateKey = 'file://' . __DIR__ . '/Stubs/private.key';
|
|
|
|
$encryptionKey = 'file://' . __DIR__ . '/Stubs/public.key';
|
|
|
|
|
2019-07-02 23:39:47 +05:30
|
|
|
$server = new AuthorizationServer(
|
|
|
|
$clientRepository,
|
|
|
|
$this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
|
|
|
|
$this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
|
|
|
|
'file://' . __DIR__ . '/Stubs/private.key',
|
|
|
|
'file://' . __DIR__ . '/Stubs/public.key'
|
|
|
|
);
|
2018-11-16 17:27:37 +05:30
|
|
|
|
|
|
|
$abstractGrantReflection = new \ReflectionClass($server);
|
|
|
|
$method = $abstractGrantReflection->getMethod('getResponseType');
|
|
|
|
$method->setAccessible(true);
|
2019-07-02 23:39:47 +05:30
|
|
|
|
2018-11-16 17:27:37 +05:30
|
|
|
$responseType = $method->invoke($server);
|
|
|
|
|
2019-07-02 23:39:47 +05:30
|
|
|
$responseTypeReflection = new \ReflectionClass($responseType);
|
|
|
|
|
|
|
|
$privateKeyProperty = $responseTypeReflection->getProperty('privateKey');
|
|
|
|
$privateKeyProperty->setAccessible(true);
|
|
|
|
|
|
|
|
$encryptionKeyProperty = $responseTypeReflection->getProperty('encryptionKey');
|
|
|
|
$encryptionKeyProperty->setAccessible(true);
|
|
|
|
|
2018-11-16 17:27:37 +05:30
|
|
|
// generated instances should have keys setup
|
2019-07-02 23:39:47 +05:30
|
|
|
$this->assertSame($privateKey, $privateKeyProperty->getValue($responseType)->getKeyPath());
|
|
|
|
$this->assertSame($encryptionKey, $encryptionKeyProperty->getValue($responseType));
|
2018-11-16 17:27:37 +05:30
|
|
|
}
|
|
|
|
|
2018-11-16 03:52:08 +05:30
|
|
|
public function testMultipleRequestsGetDifferentResponseTypeInstances()
|
2018-11-02 20:08:07 +05:30
|
|
|
{
|
|
|
|
$privateKey = 'file://' . __DIR__ . '/Stubs/private.key';
|
|
|
|
$encryptionKey = 'file://' . __DIR__ . '/Stubs/public.key';
|
|
|
|
|
|
|
|
$responseTypePrototype = new class extends BearerTokenResponse {
|
|
|
|
/* @return null|CryptKey */
|
|
|
|
public function getPrivateKey()
|
|
|
|
{
|
|
|
|
return $this->privateKey;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getEncryptionKey()
|
|
|
|
{
|
|
|
|
return $this->encryptionKey;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
|
|
|
|
|
|
|
|
$server = new AuthorizationServer(
|
|
|
|
$clientRepository,
|
|
|
|
$this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
|
|
|
|
$this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
|
|
|
|
$privateKey,
|
|
|
|
$encryptionKey,
|
|
|
|
$responseTypePrototype
|
|
|
|
);
|
|
|
|
|
|
|
|
$abstractGrantReflection = new \ReflectionClass($server);
|
2018-11-16 03:52:08 +05:30
|
|
|
$method = $abstractGrantReflection->getMethod('getResponseType');
|
2018-11-02 20:08:07 +05:30
|
|
|
$method->setAccessible(true);
|
|
|
|
|
|
|
|
$responseTypeA = $method->invoke($server);
|
|
|
|
$responseTypeB = $method->invoke($server);
|
|
|
|
|
|
|
|
// prototype should not get changed
|
|
|
|
$this->assertNull($responseTypePrototype->getPrivateKey());
|
|
|
|
$this->assertNull($responseTypePrototype->getEncryptionKey());
|
|
|
|
|
|
|
|
// generated instances should have keys setup
|
|
|
|
$this->assertSame($privateKey, $responseTypeA->getPrivateKey()->getKeyPath());
|
|
|
|
$this->assertSame($encryptionKey, $responseTypeA->getEncryptionKey());
|
|
|
|
|
|
|
|
// all instances should be different but based on the same prototype
|
|
|
|
$this->assertSame(get_class($responseTypePrototype), get_class($responseTypeA));
|
|
|
|
$this->assertSame(get_class($responseTypePrototype), get_class($responseTypeB));
|
|
|
|
$this->assertNotSame($responseTypePrototype, $responseTypeA);
|
|
|
|
$this->assertNotSame($responseTypePrototype, $responseTypeB);
|
|
|
|
$this->assertNotSame($responseTypeA, $responseTypeB);
|
2016-04-10 20:28:01 +05:30
|
|
|
}
|
2016-04-17 17:36:17 +05:30
|
|
|
|
2016-04-10 20:28:01 +05:30
|
|
|
public function testCompleteAuthorizationRequest()
|
2016-03-10 22:04:32 +05:30
|
|
|
{
|
2016-07-08 18:59:21 +05:30
|
|
|
$clientRepository = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
|
2016-03-10 22:04:32 +05:30
|
|
|
|
2016-04-17 17:24:25 +05:30
|
|
|
$server = new AuthorizationServer(
|
2016-03-10 22:04:32 +05:30
|
|
|
$clientRepository,
|
2016-07-08 18:59:21 +05:30
|
|
|
$this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
|
|
|
|
$this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
|
2016-03-28 20:40:41 +05:30
|
|
|
'file://' . __DIR__ . '/Stubs/private.key',
|
|
|
|
'file://' . __DIR__ . '/Stubs/public.key'
|
2016-03-10 22:04:32 +05:30
|
|
|
);
|
|
|
|
|
2016-04-10 20:28:01 +05:30
|
|
|
$authCodeRepository = $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock();
|
|
|
|
$authCodeRepository->method('getNewAuthCode')->willReturn(new AuthCodeEntity());
|
2016-03-10 22:04:32 +05:30
|
|
|
|
2016-04-10 20:28:01 +05:30
|
|
|
$grant = new AuthCodeGrant(
|
|
|
|
$authCodeRepository,
|
2016-07-08 18:59:21 +05:30
|
|
|
$this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
|
2018-11-08 15:11:01 +05:30
|
|
|
new DateInterval('PT10M')
|
2016-04-10 20:28:01 +05:30
|
|
|
);
|
|
|
|
|
|
|
|
$server->enableGrantType($grant);
|
|
|
|
|
|
|
|
$authRequest = new AuthorizationRequest();
|
|
|
|
$authRequest->setAuthorizationApproved(true);
|
|
|
|
$authRequest->setClient(new ClientEntity());
|
|
|
|
$authRequest->setGrantTypeId('authorization_code');
|
|
|
|
$authRequest->setUser(new UserEntity());
|
|
|
|
|
2017-12-07 01:54:42 +05:30
|
|
|
$this->assertInstanceOf(
|
|
|
|
ResponseInterface::class,
|
|
|
|
$server->completeAuthorizationRequest($authRequest, new Response)
|
2016-04-10 20:28:01 +05:30
|
|
|
);
|
2016-03-10 22:04:32 +05:30
|
|
|
}
|
|
|
|
|
2016-04-10 20:28:01 +05:30
|
|
|
public function testValidateAuthorizationRequest()
|
2016-03-10 22:04:32 +05:30
|
|
|
{
|
2016-04-10 20:28:01 +05:30
|
|
|
$client = new ClientEntity();
|
2016-05-04 16:04:37 +05:30
|
|
|
$client->setRedirectUri('http://foo/bar');
|
2018-08-16 02:10:41 +05:30
|
|
|
$client->setConfidential();
|
2016-04-10 20:28:01 +05:30
|
|
|
$clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
|
|
|
|
$clientRepositoryMock->method('getClientEntity')->willReturn($client);
|
|
|
|
|
2017-10-19 02:41:13 +05:30
|
|
|
$scope = new ScopeEntity();
|
|
|
|
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
|
|
|
|
$scopeRepositoryMock->method('getScopeEntityByIdentifier')->willReturn($scope);
|
|
|
|
|
2016-04-10 20:28:01 +05:30
|
|
|
$grant = new AuthCodeGrant(
|
2016-07-08 18:59:21 +05:30
|
|
|
$this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
|
|
|
|
$this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
|
2018-11-08 15:11:01 +05:30
|
|
|
new DateInterval('PT10M')
|
2016-04-10 20:28:01 +05:30
|
|
|
);
|
|
|
|
$grant->setClientRepository($clientRepositoryMock);
|
2016-03-10 22:04:32 +05:30
|
|
|
|
2016-04-17 17:24:25 +05:30
|
|
|
$server = new AuthorizationServer(
|
2016-04-10 20:28:01 +05:30
|
|
|
$clientRepositoryMock,
|
2016-07-08 18:59:21 +05:30
|
|
|
$this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
|
2017-10-19 02:41:13 +05:30
|
|
|
$scopeRepositoryMock,
|
2016-03-28 20:40:41 +05:30
|
|
|
'file://' . __DIR__ . '/Stubs/private.key',
|
2017-10-31 05:18:02 +05:30
|
|
|
'file://' . __DIR__ . '/Stubs/public.key'
|
2016-03-10 22:04:32 +05:30
|
|
|
);
|
2017-10-31 05:18:02 +05:30
|
|
|
|
|
|
|
$server->setDefaultScope(self::DEFAULT_SCOPE);
|
2016-04-10 20:28:01 +05:30
|
|
|
$server->enableGrantType($grant);
|
|
|
|
|
|
|
|
$request = new ServerRequest(
|
|
|
|
[],
|
|
|
|
[],
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
'php://input',
|
|
|
|
$headers = [],
|
|
|
|
$cookies = [],
|
|
|
|
$queryParams = [
|
|
|
|
'response_type' => 'code',
|
|
|
|
'client_id' => 'foo',
|
|
|
|
]
|
|
|
|
);
|
2016-03-10 22:04:32 +05:30
|
|
|
|
2017-12-07 01:54:42 +05:30
|
|
|
$this->assertInstanceOf(AuthorizationRequest::class, $server->validateAuthorizationRequest($request));
|
2016-04-10 20:28:01 +05:30
|
|
|
}
|
|
|
|
|
2016-05-04 16:04:37 +05:30
|
|
|
public function testValidateAuthorizationRequestWithMissingRedirectUri()
|
|
|
|
{
|
|
|
|
$client = new ClientEntity();
|
|
|
|
$clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
|
|
|
|
$clientRepositoryMock->method('getClientEntity')->willReturn($client);
|
|
|
|
|
|
|
|
$grant = new AuthCodeGrant(
|
2018-02-12 03:44:34 +05:30
|
|
|
$this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(),
|
|
|
|
$this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(),
|
2018-11-08 15:11:01 +05:30
|
|
|
new DateInterval('PT10M')
|
2016-05-04 16:04:37 +05:30
|
|
|
);
|
|
|
|
$grant->setClientRepository($clientRepositoryMock);
|
|
|
|
|
|
|
|
$server = new AuthorizationServer(
|
|
|
|
$clientRepositoryMock,
|
2018-02-12 03:44:34 +05:30
|
|
|
$this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
|
|
|
|
$this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
|
2016-05-04 16:04:37 +05:30
|
|
|
'file://' . __DIR__ . '/Stubs/private.key',
|
|
|
|
'file://' . __DIR__ . '/Stubs/public.key'
|
|
|
|
);
|
|
|
|
$server->enableGrantType($grant);
|
|
|
|
|
|
|
|
$request = new ServerRequest(
|
|
|
|
[],
|
|
|
|
[],
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
'php://input',
|
|
|
|
$headers = [],
|
|
|
|
$cookies = [],
|
|
|
|
$queryParams = [
|
|
|
|
'response_type' => 'code',
|
|
|
|
'client_id' => 'foo',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$server->validateAuthorizationRequest($request);
|
|
|
|
} catch (OAuthServerException $e) {
|
|
|
|
$this->assertEquals('invalid_client', $e->getErrorType());
|
|
|
|
$this->assertEquals(401, $e->getHttpStatusCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-10 20:28:01 +05:30
|
|
|
public function testValidateAuthorizationRequestUnregistered()
|
|
|
|
{
|
2016-04-17 17:24:25 +05:30
|
|
|
$server = new AuthorizationServer(
|
2016-07-08 18:59:21 +05:30
|
|
|
$this->getMockBuilder(ClientRepositoryInterface::class)->getMock(),
|
|
|
|
$this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(),
|
|
|
|
$this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(),
|
2016-04-10 20:28:01 +05:30
|
|
|
'file://' . __DIR__ . '/Stubs/private.key',
|
|
|
|
'file://' . __DIR__ . '/Stubs/public.key'
|
|
|
|
);
|
|
|
|
|
2019-06-27 17:24:22 +05:30
|
|
|
$request = (new ServerRequest())->withQueryParams([
|
|
|
|
'response_type' => 'code',
|
|
|
|
'client_id' => 'foo',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class);
|
|
|
|
$this->expectExceptionCode(2);
|
2016-04-10 20:28:01 +05:30
|
|
|
|
|
|
|
$server->validateAuthorizationRequest($request);
|
2016-03-10 22:04:32 +05:30
|
|
|
}
|
2016-02-18 17:37:50 +05:30
|
|
|
}
|