From 1183fe80c64411c105cd80dd3c15d7c9008d6b8f Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Thu, 1 May 2014 14:33:11 +0100 Subject: [PATCH] Lots of fixes for tests following exceptions changes --- tests/AbstractServerTest.php | 4 +- ...onTest.php => AuthorizationServerTest.php} | 33 ++------------ tests/Grant/AbstractGrantTest.php | 6 +-- tests/Grant/AuthCodeTest.php | 30 ++++++------- tests/Grant/ClientCredentialsTest.php | 8 ++-- tests/Grant/PasswordTest.php | 19 ++++---- tests/Grant/RefreshTokenTest.php | 13 +++--- ...esourceTest.php => ResourceServerTest.php} | 45 ++----------------- 8 files changed, 47 insertions(+), 111 deletions(-) rename tests/{AuthorizationTest.php => AuthorizationServerTest.php} (68%) rename tests/{ResourceTest.php => ResourceServerTest.php} (80%) diff --git a/tests/AbstractServerTest.php b/tests/AbstractServerTest.php index 231105dc..a25b8f13 100644 --- a/tests/AbstractServerTest.php +++ b/tests/AbstractServerTest.php @@ -5,7 +5,7 @@ namespace LeagueTests; use LeagueTests\Stubs\StubAbstractServer; use \Mockery as M; -class AbstractTokenTests extends \PHPUnit_Framework_TestCase +class AbstractTokenTest extends \PHPUnit_Framework_TestCase { function testSetGet() { @@ -19,7 +19,7 @@ class AbstractTokenTests extends \PHPUnit_Framework_TestCase function testGetStorageException() { - $this->setExpectedException('League\OAuth2\Server\Exception\ServerException'); + $this->setExpectedException('League\OAuth2\Server\Exception\ServerErrorException'); $server = new StubAbstractServer(); $server->getStorage('foobar'); } diff --git a/tests/AuthorizationTest.php b/tests/AuthorizationServerTest.php similarity index 68% rename from tests/AuthorizationTest.php rename to tests/AuthorizationServerTest.php index 26110571..fd447b6c 100644 --- a/tests/AuthorizationTest.php +++ b/tests/AuthorizationServerTest.php @@ -7,33 +7,8 @@ use League\OAuth2\Server\Grant\GrantTypeInterface; use League\OAuth2\Server\Storage\ScopeInterface; use \Mockery as M; -class AuthorizationTests extends \PHPUnit_Framework_TestCase +class AuthorizationTest extends \PHPUnit_Framework_TestCase { - public function testGetExceptionMessage() - { - $m = AuthorizationServer::getExceptionMessage('access_denied'); - - $reflector = new \ReflectionClass('League\OAuth2\Server\AuthorizationServer'); - $exceptionMessages = $reflector->getProperty('exceptionMessages'); - $exceptionMessages->setAccessible(true); - $v = $exceptionMessages->getValue(); - - $this->assertEquals($v['access_denied'], $m); - } - - public function testGetExceptionCode() - { - $this->assertEquals('access_denied', AuthorizationServer::getExceptionType(2)); - } - - public function testGetExceptionHttpHeaders() - { - $this->assertEquals(array('HTTP/1.1 401 Unauthorized'), AuthorizationServer::getExceptionHttpHeaders('access_denied')); - $this->assertEquals(array('HTTP/1.1 500 Internal Server Error'), AuthorizationServer::getExceptionHttpHeaders('server_error')); - $this->assertEquals(array('HTTP/1.1 501 Not Implemented'), AuthorizationServer::getExceptionHttpHeaders('unsupported_grant_type')); - $this->assertEquals(array('HTTP/1.1 400 Bad Request'), AuthorizationServer::getExceptionHttpHeaders('invalid_refresh')); - } - public function testSetGet() { $server = new AuthorizationServer; @@ -67,7 +42,7 @@ class AuthorizationTests extends \PHPUnit_Framework_TestCase public function testInvalidGrantType() { - $this->setExpectedException('League\OAuth2\Server\Exception\InvalidGrantTypeException'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidGrantException'); $server = new AuthorizationServer; $server->getGrantType('foobar'); } @@ -90,14 +65,14 @@ class AuthorizationTests extends \PHPUnit_Framework_TestCase public function testIssueAccessTokenEmptyGrantType() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $server = new AuthorizationServer; $this->assertTrue($server->issueAccessToken()); } public function testIssueAccessTokenInvalidGrantType() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException'); + $this->setExpectedException('League\OAuth2\Server\Exception\UnsupportedGrantTypeException'); $_POST['grant_type'] = 'foobar'; diff --git a/tests/Grant/AbstractGrantTest.php b/tests/Grant/AbstractGrantTest.php index 60b28979..9d4d6523 100644 --- a/tests/Grant/AbstractGrantTest.php +++ b/tests/Grant/AbstractGrantTest.php @@ -5,7 +5,7 @@ namespace LeagueTests\Grant; use League\OAuth2\Server\Grant; use League\OAuth2\Server\Entity\Scope; use League\OAuth2\Server\AuthorizationServer; -use League\OAuth2\Server\Grant\ClientException; +use League\OAuth2\Server\Exception\InvalidRequestException; use LeagueTests\Stubs\StubAbstractGrant; use Mockery as M; @@ -74,7 +74,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase public function testValidateScopesMissingScope() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface'); $scopeStorage->shouldReceive('setServer'); @@ -91,7 +91,7 @@ class AbstractGrantTest extends \PHPUnit_Framework_TestCase public function testValidateScopesInvalidScope() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidScopeException'); $scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface'); $scopeStorage->shouldReceive('setServer'); diff --git a/tests/Grant/AuthCodeTest.php b/tests/Grant/AuthCodeTest.php index ecd04309..eb15238c 100644 --- a/tests/Grant/AuthCodeTest.php +++ b/tests/Grant/AuthCodeTest.php @@ -9,7 +9,7 @@ use League\OAuth2\Server\Entity\Client; use League\OAuth2\Server\Entity\Session; use League\OAuth2\Server\Entity\AuthCode as AC; use League\OAuth2\Server\AuthorizationServer as Authorization; -use League\OAuth2\Server\Grant\ClientException; +use League\OAuth2\Server\Exception\InvalidRequestException; use Mockery as M; class AuthCodeTest extends \PHPUnit_Framework_TestCase @@ -27,7 +27,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCheckAuthoriseParamsMissingClientId() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "client_id" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = []; @@ -41,7 +41,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCheckAuthoriseParamsMissingRedirectUri() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "redirect_uri" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'client_id' => 'testapp' @@ -56,7 +56,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCheckAuthoriseParamsMissingStateParam() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "state" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'client_id' => 'testapp', @@ -73,7 +73,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCheckAuthoriseParamsMissingResponseType() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "response_type" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'client_id' => 'testapp', @@ -89,7 +89,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCheckAuthoriseParamsInvalidResponseType() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The authorization server does not support obtaining an access token using this method.'); + $this->setExpectedException('League\OAuth2\Server\Exception\UnsupportedResponseTypeException'); $_POST = [ 'client_id' => 'testapp', @@ -106,7 +106,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCheckAuthoriseParamsInvalidClient() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'Client authentication failed'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidClientException'); $_POST = [ 'client_id' => 'testapp', @@ -129,7 +129,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCheckAuthoriseParamsInvalidScope() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The requested scope is invalid, unknown, or malformed. Check the "foo" scope.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidScopeException'); $_POST = [ 'response_type' => 'code', @@ -260,7 +260,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCompleteFlowMissingClientId() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "client_id" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST['grant_type'] = 'authorization_code'; @@ -274,7 +274,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCompleteFlowMissingClientSecret() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "client_secret" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'grant_type' => 'authorization_code', @@ -290,7 +290,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCompleteFlowMissingRedirectUri() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "redirect_uri" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'grant_type' => 'authorization_code', @@ -307,7 +307,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCompleteFlowInvalidClient() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'Client authentication failed'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidClientException'); $_POST = [ 'grant_type' => 'authorization_code', @@ -331,7 +331,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCompleteFlowMissingCode() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "code" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'grant_type' => 'authorization_code', @@ -379,7 +379,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCompleteFlowInvalidCode() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "code" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'grant_type' => 'authorization_code', @@ -428,7 +428,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase public function testCompleteFlowRedirectUriMismatch() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "redirect_uri" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'grant_type' => 'authorization_code', diff --git a/tests/Grant/ClientCredentialsTest.php b/tests/Grant/ClientCredentialsTest.php index 0ba342c7..1686c611 100644 --- a/tests/Grant/ClientCredentialsTest.php +++ b/tests/Grant/ClientCredentialsTest.php @@ -13,7 +13,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase { function testCompleteFlowMissingClientId() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "client_id" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST['grant_type'] = 'client_credentials'; @@ -27,7 +27,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase function testCompleteFlowMissingClientSecret() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "client_secret" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'grant_type' => 'client_credentials', @@ -43,7 +43,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase function testCompleteFlowInvalidClient() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'Client authentication failed'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidClientException'); $_POST = [ 'grant_type' => 'client_credentials', @@ -66,7 +66,7 @@ class ClientCredentialsTest extends \PHPUnit_Framework_TestCase function testCompleteFlowInvalidScope() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The requested scope is invalid, unknown, or malformed. Check the "foo" scope.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidScopeException'); $_POST = [ 'grant_type' => 'client_credentials', diff --git a/tests/Grant/PasswordTest.php b/tests/Grant/PasswordTest.php index 9941761c..85110223 100644 --- a/tests/Grant/PasswordTest.php +++ b/tests/Grant/PasswordTest.php @@ -7,14 +7,13 @@ use League\OAuth2\Server\Grant\RefreshToken; use League\OAuth2\Server\Entity\Scope; use League\OAuth2\Server\Entity\Client; use League\OAuth2\Server\AuthorizationServer; -use League\OAuth2\Server\Grant\ClientException; use Mockery as M; class PasswordTest extends \PHPUnit_Framework_TestCase { function testCompleteFlowMissingClientId() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "client_id" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST['grant_type'] = 'password'; @@ -28,7 +27,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase function testCompleteFlowMissingClientSecret() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "client_secret" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'grant_type' => 'password', @@ -44,7 +43,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase function testCompleteFlowInvalidClient() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'Client authentication failed'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidClientException'); $_POST = [ 'grant_type' => 'password', @@ -67,7 +66,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase function testNoUsername() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "username" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'grant_type' => 'password', @@ -109,7 +108,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase function testNoPassword() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "password" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'grant_type' => 'password', @@ -152,7 +151,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase function testNoCallable() { - $this->setExpectedException('League\OAuth2\Server\Exception\InvalidGrantTypeException', 'Null or non-callable callback set on Password grant'); + $this->setExpectedException('League\OAuth2\Server\Exception\ServerErrorException'); $_POST = [ 'grant_type' => 'password', @@ -196,7 +195,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase function testCompleteFlowInvalidScope() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The requested scope is invalid, unknown, or malformed. Check the "foo" scope.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidScopeException'); $_POST = [ 'grant_type' => 'password', @@ -244,7 +243,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase function testCompleteFlowNoScopes() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "scope" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'grant_type' => 'password', @@ -293,7 +292,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase function testCompleteFlowInvalidCredentials() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The user credentials were incorrect.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidCredentialsException'); $_POST = [ 'grant_type' => 'password', diff --git a/tests/Grant/RefreshTokenTest.php b/tests/Grant/RefreshTokenTest.php index c6b0bc36..539f0d8d 100644 --- a/tests/Grant/RefreshTokenTest.php +++ b/tests/Grant/RefreshTokenTest.php @@ -9,7 +9,6 @@ use League\OAuth2\Server\Entity\AccessToken; use League\OAuth2\Server\Entity\Session; use League\OAuth2\Server\Entity\RefreshToken as RT; use League\OAuth2\Server\AuthorizationServer; -use League\OAuth2\Server\Grant\ClientException; use Mockery as M; class RefreshTokenTest extends \PHPUnit_Framework_TestCase @@ -27,7 +26,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase function testCompleteFlowMissingClientId() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "client_id" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST['grant_type'] = 'refresh_token'; @@ -40,7 +39,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase function testCompleteFlowMissingClientSecret() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "client_secret" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'grant_type' => 'refresh_token', @@ -56,7 +55,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase function testCompleteFlowInvalidClient() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'Client authentication failed'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidClientException'); $_POST = [ 'grant_type' => 'refresh_token', @@ -79,7 +78,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase function testCompleteFlowMissingRefreshToken() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "refresh_token" parameter.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $_POST = [ 'grant_type' => 'refresh_token', @@ -113,7 +112,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase function testCompleteFlowInvalidRefreshToken() { - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The refresh token is invalid.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRefreshException'); $_POST = [ 'grant_type' => 'refresh_token', @@ -352,7 +351,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase $server->addGrantType($grant); - $this->setExpectedException('League\OAuth2\Server\Exception\ClientException', 'The requested scope is invalid, unknown, or malformed. Check the "blah" scope.'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidScopeException'); $server->issueAccessToken(); } diff --git a/tests/ResourceTest.php b/tests/ResourceServerTest.php similarity index 80% rename from tests/ResourceTest.php rename to tests/ResourceServerTest.php index eb7662ca..5d80f78f 100644 --- a/tests/ResourceTest.php +++ b/tests/ResourceServerTest.php @@ -10,7 +10,7 @@ use League\OAuth2\Server\Entity\Client; use League\OAuth2\Server\Entity\Scope; use \Mockery as M; -class ResourceServerTests extends \PHPUnit_Framework_TestCase +class ResourceServerTest extends \PHPUnit_Framework_TestCase { private function returnDefault() { @@ -54,7 +54,7 @@ class ResourceServerTests extends \PHPUnit_Framework_TestCase public function testDetermineAccessTokenMissingToken() { - $this->setExpectedException('League\OAuth2\Server\Exception\InvalidAccessTokenException'); + $this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException'); $sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface'); $sessionStorage->shouldReceive('setServer'); @@ -89,43 +89,6 @@ class ResourceServerTests extends \PHPUnit_Framework_TestCase $method->invoke($server); } - public function testDetermineAccessTokenBrokenCurlRequest() - { - $this->setExpectedException('League\OAuth2\Server\Exception\InvalidAccessTokenException'); - - $sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface'); - $sessionStorage->shouldReceive('setServer'); - - $accessTokenStorage = M::mock('League\OAuth2\Server\Storage\AccessTokenInterface'); - $accessTokenStorage->shouldReceive('setServer'); - $accessTokenStorage->shouldReceive('get')->andReturn(false); - - $clientStorage = M::mock('League\OAuth2\Server\Storage\ClientInterface'); - $clientStorage->shouldReceive('setServer'); - - $scopeStorage = M::mock('League\OAuth2\Server\Storage\ScopeInterface'); - $scopeStorage->shouldReceive('setServer'); - - $server = new ResourceServer( - $sessionStorage, - $accessTokenStorage, - $clientStorage, - $scopeStorage - ); - - $request = new \Symfony\Component\HttpFoundation\Request(); - $request->headers = new \Symfony\Component\HttpFoundation\ParameterBag([ - 'Authorization' => 'Bearer, Bearer abcdef' - ]); - $server->setRequest($request); - - $reflector = new \ReflectionClass($server); - $method = $reflector->getMethod('determineAccessToken'); - $method->setAccessible(true); - - $method->invoke($server); - } - public function testIsValidNotValid() { $sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface'); @@ -148,7 +111,7 @@ class ResourceServerTests extends \PHPUnit_Framework_TestCase $scopeStorage ); - $this->assertFalse($server->isValid()); + $this->assertFalse($server->isValidRequest()); } public function testIsValid() @@ -197,7 +160,7 @@ class ResourceServerTests extends \PHPUnit_Framework_TestCase ]); $server->setRequest($request); - $this->assertTrue($server->isValid()); + $this->assertTrue($server->isValidRequest()); $this->assertEquals('at', $server->getTokenKey()); $this->assertEquals(123, $server->getOwnerId()); $this->assertEquals('user', $server->getOwnerType());