diff --git a/examples/public/api.php b/examples/public/api.php index 1fa9d82dc..66b0f7c41 100644 --- a/examples/public/api.php +++ b/examples/public/api.php @@ -33,18 +33,18 @@ function (ServerRequestInterface $request, ResponseInterface $response) use ($app) { $users = [ [ - 'id' => 123, - 'name' => 'Alex', + 'id' => 123, + 'name' => 'Alex', 'email' => 'alex@thephpleague.com', ], [ - 'id' => 124, - 'name' => 'Frank', + 'id' => 124, + 'name' => 'Frank', 'email' => 'frank@thephpleague.com', ], [ - 'id' => 125, - 'name' => 'Phil', + 'id' => 125, + 'name' => 'Phil', 'email' => 'phil@thephpleague.com', ], ]; diff --git a/examples/public/auth_code.php b/examples/public/auth_code.php index c082e3b3f..4d41e4b7a 100644 --- a/examples/public/auth_code.php +++ b/examples/public/auth_code.php @@ -24,7 +24,7 @@ include __DIR__ . '/../vendor/autoload.php'; $app = new App([ - 'settings' => [ + 'settings' => [ 'displayErrorDetails' => true, ], AuthorizationServer::class => function () { diff --git a/examples/public/client_credentials.php b/examples/public/client_credentials.php index 1e5f090d7..089a336c5 100644 --- a/examples/public/client_credentials.php +++ b/examples/public/client_credentials.php @@ -20,7 +20,7 @@ include __DIR__ . '/../vendor/autoload.php'; $app = new App([ - 'settings' => [ + 'settings' => [ 'displayErrorDetails' => true, ], AuthorizationServer::class => function () { diff --git a/examples/public/implicit.php b/examples/public/implicit.php index ac43f5dd1..e74f0e337 100644 --- a/examples/public/implicit.php +++ b/examples/public/implicit.php @@ -22,7 +22,7 @@ include __DIR__ . '/../vendor/autoload.php'; $app = new App([ - 'settings' => [ + 'settings' => [ 'displayErrorDetails' => true, ], AuthorizationServer::class => function () { diff --git a/examples/public/middleware_use.php b/examples/public/middleware_use.php index 9f958ed26..3e743f778 100644 --- a/examples/public/middleware_use.php +++ b/examples/public/middleware_use.php @@ -26,7 +26,7 @@ include __DIR__ . '/../vendor/autoload.php'; $app = new App([ - 'settings' => [ + 'settings' => [ 'displayErrorDetails' => true, ], AuthorizationServer::class => function () { @@ -89,7 +89,7 @@ if (\in_array('basic', $request->getAttribute('oauth_scopes', []))) { $params = [ - 'id' => 1, + 'id' => 1, 'name' => 'Alex', 'city' => 'London', ]; diff --git a/examples/public/refresh_token.php b/examples/public/refresh_token.php index 39be08262..d76d421db 100644 --- a/examples/public/refresh_token.php +++ b/examples/public/refresh_token.php @@ -21,7 +21,7 @@ include __DIR__ . '/../vendor/autoload.php'; $app = new App([ - 'settings' => [ + 'settings' => [ 'displayErrorDetails' => true, ], AuthorizationServer::class => function () { diff --git a/examples/src/Repositories/ClientRepository.php b/examples/src/Repositories/ClientRepository.php index 3a398f4ed..1d6107c6e 100644 --- a/examples/src/Repositories/ClientRepository.php +++ b/examples/src/Repositories/ClientRepository.php @@ -39,9 +39,9 @@ public function validateClient($clientIdentifier, $clientSecret, $grantType) { $clients = [ 'myawesomeapp' => [ - 'secret' => \password_hash('abc123', PASSWORD_BCRYPT), - 'name' => self::CLIENT_NAME, - 'redirect_uri' => self::REDIRECT_URI, + 'secret' => \password_hash('abc123', PASSWORD_BCRYPT), + 'name' => self::CLIENT_NAME, + 'redirect_uri' => self::REDIRECT_URI, 'is_confidential' => true, ], ]; diff --git a/src/Grant/AuthCodeGrant.php b/src/Grant/AuthCodeGrant.php index 8336cf649..9d6e63dd2 100644 --- a/src/Grant/AuthCodeGrant.php +++ b/src/Grant/AuthCodeGrant.php @@ -366,13 +366,13 @@ public function completeAuthorizationRequest(AuthorizationRequest $authorization ); $payload = [ - 'client_id' => $authCode->getClient()->getIdentifier(), - 'redirect_uri' => $authCode->getRedirectUri(), - 'auth_code_id' => $authCode->getIdentifier(), - 'scopes' => $authCode->getScopes(), - 'user_id' => $authCode->getUserIdentifier(), - 'expire_time' => (new DateTimeImmutable())->add($this->authCodeTTL)->getTimestamp(), - 'code_challenge' => $authorizationRequest->getCodeChallenge(), + 'client_id' => $authCode->getClient()->getIdentifier(), + 'redirect_uri' => $authCode->getRedirectUri(), + 'auth_code_id' => $authCode->getIdentifier(), + 'scopes' => $authCode->getScopes(), + 'user_id' => $authCode->getUserIdentifier(), + 'expire_time' => (new DateTimeImmutable())->add($this->authCodeTTL)->getTimestamp(), + 'code_challenge' => $authorizationRequest->getCodeChallenge(), 'code_challenge_method' => $authorizationRequest->getCodeChallengeMethod(), ]; @@ -387,7 +387,7 @@ public function completeAuthorizationRequest(AuthorizationRequest $authorization $this->makeRedirectUri( $finalRedirectUri, [ - 'code' => $this->encrypt($jsonPayload), + 'code' => $this->encrypt($jsonPayload), 'state' => $authorizationRequest->getState(), ] ) diff --git a/src/Grant/ImplicitGrant.php b/src/Grant/ImplicitGrant.php index 0bd91d5ac..0229dd9ee 100644 --- a/src/Grant/ImplicitGrant.php +++ b/src/Grant/ImplicitGrant.php @@ -207,9 +207,9 @@ public function completeAuthorizationRequest(AuthorizationRequest $authorization $finalRedirectUri, [ 'access_token' => (string) $accessToken, - 'token_type' => 'Bearer', - 'expires_in' => $accessToken->getExpiryDateTime()->getTimestamp() - \time(), - 'state' => $authorizationRequest->getState(), + 'token_type' => 'Bearer', + 'expires_in' => $accessToken->getExpiryDateTime()->getTimestamp() - \time(), + 'state' => $authorizationRequest->getState(), ], $this->queryDelimiter ) diff --git a/src/ResponseTypes/BearerTokenResponse.php b/src/ResponseTypes/BearerTokenResponse.php index 33c1606e8..afafcf35a 100644 --- a/src/ResponseTypes/BearerTokenResponse.php +++ b/src/ResponseTypes/BearerTokenResponse.php @@ -26,19 +26,19 @@ public function generateHttpResponse(ResponseInterface $response) $expireDateTime = $this->accessToken->getExpiryDateTime()->getTimestamp(); $responseParams = [ - 'token_type' => 'Bearer', - 'expires_in' => $expireDateTime - \time(), + 'token_type' => 'Bearer', + 'expires_in' => $expireDateTime - \time(), 'access_token' => (string) $this->accessToken, ]; if ($this->refreshToken instanceof RefreshTokenEntityInterface) { $refreshTokenPayload = \json_encode([ - 'client_id' => $this->accessToken->getClient()->getIdentifier(), + 'client_id' => $this->accessToken->getClient()->getIdentifier(), 'refresh_token_id' => $this->refreshToken->getIdentifier(), - 'access_token_id' => $this->accessToken->getIdentifier(), - 'scopes' => $this->accessToken->getScopes(), - 'user_id' => $this->accessToken->getUserIdentifier(), - 'expire_time' => $this->refreshToken->getExpiryDateTime()->getTimestamp(), + 'access_token_id' => $this->accessToken->getIdentifier(), + 'scopes' => $this->accessToken->getScopes(), + 'user_id' => $this->accessToken->getUserIdentifier(), + 'expire_time' => $this->refreshToken->getExpiryDateTime()->getTimestamp(), ]); if ($refreshTokenPayload === false) { diff --git a/tests/AuthorizationServerTest.php b/tests/AuthorizationServerTest.php index af8c89d8a..dfdafbe9f 100644 --- a/tests/AuthorizationServerTest.php +++ b/tests/AuthorizationServerTest.php @@ -301,7 +301,7 @@ public function testValidateAuthorizationRequest() $cookies = [], $queryParams = [ 'response_type' => 'code', - 'client_id' => 'foo', + 'client_id' => 'foo', ] ); @@ -342,7 +342,7 @@ public function testValidateAuthorizationRequestWithMissingRedirectUri() $cookies = [], $queryParams = [ 'response_type' => 'code', - 'client_id' => 'foo', + 'client_id' => 'foo', ] ); @@ -369,7 +369,7 @@ public function testValidateAuthorizationRequestUnregistered() 'client_id' => 'foo', ]); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(2); $server->validateAuthorizationRequest($request); diff --git a/tests/Grant/AbstractGrantTest.php b/tests/Grant/AbstractGrantTest.php index 618545efe..e3a312a35 100644 --- a/tests/Grant/AbstractGrantTest.php +++ b/tests/Grant/AbstractGrantTest.php @@ -109,7 +109,7 @@ public function testGetClientCredentialsClientSecretNotAString() [], [], [ - 'client_id' => 'client_id', + 'client_id' => 'client_id', 'client_secret' => ['not', 'a', 'string'], ] ); @@ -161,9 +161,9 @@ public function testValidateClientConfidential() $abstractGrantReflection = new \ReflectionClass($grantMock); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', - 'redirect_uri' => 'http://foo/bar', + 'redirect_uri' => 'http://foo/bar', ]); $validateClientMethod = $abstractGrantReflection->getMethod('validateClient'); @@ -229,7 +229,7 @@ public function testValidateClientInvalidClientSecret() $abstractGrantReflection = new \ReflectionClass($grantMock); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'foo', ]); @@ -255,7 +255,7 @@ public function testValidateClientInvalidRedirectUri() $abstractGrantReflection = new \ReflectionClass($grantMock); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'redirect_uri' => 'http://bar/foo', ]); @@ -281,7 +281,7 @@ public function testValidateClientInvalidRedirectUriArray() $abstractGrantReflection = new \ReflectionClass($grantMock); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'redirect_uri' => 'http://bar/foo', ]); @@ -307,7 +307,7 @@ public function testValidateClientMalformedRedirectUri() $abstractGrantReflection = new \ReflectionClass($grantMock); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'redirect_uri' => ['not', 'a', 'string'], ]); @@ -331,7 +331,7 @@ public function testValidateClientBadClient() $abstractGrantReflection = new \ReflectionClass($grantMock); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', ]); diff --git a/tests/Grant/AuthCodeGrantTest.php b/tests/Grant/AuthCodeGrantTest.php index 7c2c20d11..248a66ec4 100644 --- a/tests/Grant/AuthCodeGrantTest.php +++ b/tests/Grant/AuthCodeGrantTest.php @@ -76,7 +76,7 @@ public function testCanRespondToAuthorizationRequest() $cookies = [], $queryParams = [ 'response_type' => 'code', - 'client_id' => 'foo', + 'client_id' => 'foo', ] ); @@ -115,8 +115,8 @@ public function testValidateAuthorizationRequest() [], [ 'response_type' => 'code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, ] ); @@ -154,8 +154,8 @@ public function testValidateAuthorizationRequestRedirectUriArray() [], [ 'response_type' => 'code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, ] ); @@ -194,7 +194,7 @@ public function testValidateAuthorizationRequestWithoutRedirectUri() [], [ 'response_type' => 'code', - 'client_id' => 'foo', + 'client_id' => 'foo', ] ); @@ -234,9 +234,9 @@ public function testValidateAuthorizationRequestCodeChallenge() [], [], [ - 'response_type' => 'code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'response_type' => 'code', + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, 'code_challenge' => self::CODE_CHALLENGE, ] ); @@ -260,13 +260,13 @@ public function testValidateAuthorizationRequestCodeChallengeInvalidLengthTooSho $grant->setClientRepository($clientRepositoryMock); $request = (new ServerRequest())->withQueryParams([ - 'response_type' => 'code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'response_type' => 'code', + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, 'code_challenge' => \str_repeat('A', 42), ]); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $grant->validateAuthorizationRequest($request); } @@ -287,13 +287,13 @@ public function testValidateAuthorizationRequestCodeChallengeInvalidLengthTooLon $grant->setClientRepository($clientRepositoryMock); $request = (new ServerRequest())->withQueryParams([ - 'response_type' => 'code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'response_type' => 'code', + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, 'code_challenge' => \str_repeat('A', 129), ]); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $grant->validateAuthorizationRequest($request); } @@ -320,7 +320,7 @@ public function testValidateAuthorizationRequestCodeChallengeInvalidCharacters() 'code_challenge' => \str_repeat('A', 42) . '!', ]); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $grant->validateAuthorizationRequest($request); } @@ -340,7 +340,7 @@ public function testValidateAuthorizationRequestMissingClientId() 'response_type' => 'code', ]); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(3); $grant->validateAuthorizationRequest($request); @@ -360,10 +360,10 @@ public function testValidateAuthorizationRequestInvalidClientId() $request = (new ServerRequest())->withQueryParams([ 'response_type' => 'code', - 'client_id' => 'foo', + 'client_id' => 'foo', ]); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(4); $grant->validateAuthorizationRequest($request); @@ -385,11 +385,11 @@ public function testValidateAuthorizationRequestBadRedirectUriString() $request = (new ServerRequest())->withQueryParams([ 'response_type' => 'code', - 'client_id' => 'foo', - 'redirect_uri' => 'http://bar', + 'client_id' => 'foo', + 'redirect_uri' => 'http://bar', ]); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(4); $grant->validateAuthorizationRequest($request); @@ -411,11 +411,11 @@ public function testValidateAuthorizationRequestBadRedirectUriArray() $request = (new ServerRequest())->withQueryParams([ 'response_type' => 'code', - 'client_id' => 'foo', - 'redirect_uri' => 'http://bar', + 'client_id' => 'foo', + 'redirect_uri' => 'http://bar', ]); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(4); $grant->validateAuthorizationRequest($request); @@ -450,7 +450,7 @@ public function testValidateAuthorizationRequestInvalidCodeChallengeMethod() 'code_challenge_method' => 'foo', ]); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(3); $grant->validateAuthorizationRequest($request); @@ -501,7 +501,7 @@ public function testCompleteAuthorizationRequestDenied() ); $grant->setEncryptionKey($this->cryptStub->getKey()); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(9); $grant->completeAuthorizationRequest($authRequest); @@ -551,17 +551,17 @@ public function testRespondToAccessTokenRequest() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], 'redirect_uri' => self::REDIRECT_URI, ] ) @@ -618,16 +618,16 @@ public function testRespondToAccessTokenRequestUsingHttpBasicAuth() [], [], [ - 'grant_type' => 'authorization_code', + 'grant_type' => 'authorization_code', 'redirect_uri' => self::REDIRECT_URI, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ 'auth_code_id' => \uniqid(), 'client_id' => 'foo', - 'expire_time' => \time() + 3600, - 'user_id' => 123, - 'scopes' => ['foo'], + 'expire_time' => \time() + 3600, + 'user_id' => 123, + 'scopes' => ['foo'], 'redirect_uri' => self::REDIRECT_URI, ] ) @@ -685,17 +685,17 @@ public function testRespondToAccessTokenRequestForPublicClient() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], 'redirect_uri' => self::REDIRECT_URI, ] ) @@ -753,17 +753,17 @@ public function testRespondToAccessTokenRequestNullRefreshToken() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], 'redirect_uri' => self::REDIRECT_URI, ] ) @@ -823,20 +823,20 @@ public function testRespondToAccessTokenRequestCodeChallengePlain() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, 'code_verifier' => self::CODE_VERIFIER, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ - 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], - 'redirect_uri' => self::REDIRECT_URI, - 'code_challenge' => self::CODE_VERIFIER, + 'auth_code_id' => \uniqid(), + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], + 'redirect_uri' => self::REDIRECT_URI, + 'code_challenge' => self::CODE_VERIFIER, 'code_challenge_method' => 'plain', ] ) @@ -896,20 +896,20 @@ public function testRespondToAccessTokenRequestCodeChallengeS256() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, 'code_verifier' => self::CODE_VERIFIER, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ - 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], - 'redirect_uri' => self::REDIRECT_URI, - 'code_challenge' => self::CODE_CHALLENGE, + 'auth_code_id' => \uniqid(), + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], + 'redirect_uri' => self::REDIRECT_URI, + 'code_challenge' => self::CODE_CHALLENGE, 'code_challenge_method' => 'S256', ] ) @@ -969,26 +969,26 @@ public function testPKCEDowngradeBlocked() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, 'code_verifier' => self::CODE_VERIFIER, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ - 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], - 'redirect_uri' => self::REDIRECT_URI, + 'auth_code_id' => \uniqid(), + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], + 'redirect_uri' => self::REDIRECT_URI, ] ) ), ] ); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(3); /* @var StubResponseType $response */ @@ -1022,22 +1022,22 @@ public function testRespondToAccessTokenRequestMissingRedirectUri() [], [], [ - 'client_id' => 'foo', + 'client_id' => 'foo', 'grant_type' => 'authorization_code', - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ - 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'auth_code_id' => \uniqid(), + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, ] ) ), ] ); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(3); $grant->respondToAccessTokenRequest($request, new StubResponseType(), new DateInterval('PT10M')); @@ -1070,23 +1070,23 @@ public function testRespondToAccessTokenRequestRedirectUriMismatch() [], [], [ - 'client_id' => 'foo', + 'client_id' => 'foo', 'grant_type' => 'authorization_code', 'redirect_uri' => 'http://bar/foo', - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ - 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'auth_code_id' => \uniqid(), + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, ] ) ), ] ); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(3); $grant->respondToAccessTokenRequest($request, new StubResponseType(), new DateInterval('PT10M')); @@ -1123,14 +1123,14 @@ public function testRespondToAccessTokenRequestMissingCode() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'client_secret' => 'bar', - 'redirect_uri' => self::REDIRECT_URI, + 'redirect_uri' => self::REDIRECT_URI, ] ); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(3); /* @var StubResponseType $response */ @@ -1164,18 +1164,18 @@ public function testRespondToAccessTokenRequestWithRefreshTokenInsteadOfAuthCode [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ - 'client_id' => 'foo', + 'client_id' => 'foo', 'refresh_token_id' => 'zyxwvu', - 'access_token_id' => 'abcdef', - 'scopes' => ['foo'], - 'user_id' => 123, - 'expire_time' => \time() + 3600, + 'access_token_id' => 'abcdef', + 'scopes' => ['foo'], + 'user_id' => 123, + 'expire_time' => \time() + 3600, ] ) ), @@ -1217,14 +1217,14 @@ public function testRespondToAccessTokenRequestWithAuthCodeNotAString() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => ['not', 'a', 'string'], + 'code' => ['not', 'a', 'string'], ] ); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $grant->respondToAccessTokenRequest($request, new StubResponseType(), new DateInterval('PT10M')); } @@ -1255,17 +1255,17 @@ public function testRespondToAccessTokenRequestExpiredCode() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ 'auth_code_id' => \uniqid(), - 'expire_time' => \time() - 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], + 'expire_time' => \time() - 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], 'redirect_uri' => self::REDIRECT_URI, ] ) @@ -1319,17 +1319,17 @@ public function testRespondToAccessTokenRequestRevokedCode() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], 'redirect_uri' => self::REDIRECT_URI, ] ) @@ -1380,17 +1380,17 @@ public function testRespondToAccessTokenRequestClientMismatch() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'bar', - 'user_id' => 123, - 'scopes' => ['foo'], + 'expire_time' => \time() + 3600, + 'client_id' => 'bar', + 'user_id' => 123, + 'scopes' => ['foo'], 'redirect_uri' => self::REDIRECT_URI, ] ) @@ -1441,10 +1441,10 @@ public function testRespondToAccessTokenRequestBadCodeEncryption() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => 'sdfsfsd', + 'code' => 'sdfsfsd', ] ); @@ -1500,20 +1500,20 @@ public function testRespondToAccessTokenRequestBadCodeVerifierPlain() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, 'code_verifier' => self::CODE_VERIFIER, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ - 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], - 'redirect_uri' => self::REDIRECT_URI, - 'code_challenge' => 'foobar', + 'auth_code_id' => \uniqid(), + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], + 'redirect_uri' => self::REDIRECT_URI, + 'code_challenge' => 'foobar', 'code_challenge_method' => 'plain', ] ) @@ -1573,20 +1573,20 @@ public function testRespondToAccessTokenRequestBadCodeVerifierS256() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, 'code_verifier' => 'nope', - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ - 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], - 'redirect_uri' => self::REDIRECT_URI, - 'code_challenge' => 'foobar', + 'auth_code_id' => \uniqid(), + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], + 'redirect_uri' => self::REDIRECT_URI, + 'code_challenge' => 'foobar', 'code_challenge_method' => 'S256', ] ) @@ -1646,20 +1646,20 @@ public function testRespondToAccessTokenRequestMalformedCodeVerifierS256WithInva [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, 'code_verifier' => 'dqX7C-RbqjHYtytmhGTigKdZCXfxq-+xbsk9_GxUcaE', // Malformed code. Contains `+`. - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ - 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], - 'redirect_uri' => self::REDIRECT_URI, - 'code_challenge' => self::CODE_CHALLENGE, + 'auth_code_id' => \uniqid(), + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], + 'redirect_uri' => self::REDIRECT_URI, + 'code_challenge' => self::CODE_CHALLENGE, 'code_challenge_method' => 'S256', ] ) @@ -1719,20 +1719,20 @@ public function testRespondToAccessTokenRequestMalformedCodeVerifierS256WithInva [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, 'code_verifier' => 'dqX7C-RbqjHY', // Malformed code. Invalid length. - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ - 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], - 'redirect_uri' => self::REDIRECT_URI, - 'code_challenge' => 'R7T1y1HPNFvs1WDCrx4lfoBS6KD2c71pr8OHvULjvv8', + 'auth_code_id' => \uniqid(), + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], + 'redirect_uri' => self::REDIRECT_URI, + 'code_challenge' => 'R7T1y1HPNFvs1WDCrx4lfoBS6KD2c71pr8OHvULjvv8', 'code_challenge_method' => 'S256', ] ) @@ -1792,19 +1792,19 @@ public function testRespondToAccessTokenRequestMissingCodeVerifier() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ - 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], - 'redirect_uri' => self::REDIRECT_URI, - 'code_challenge' => 'foobar', + 'auth_code_id' => \uniqid(), + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], + 'redirect_uri' => self::REDIRECT_URI, + 'code_challenge' => 'foobar', 'code_challenge_method' => 'plain', ] ) @@ -1875,7 +1875,7 @@ public function testAuthCodeRepositoryFailToPersist() ); $grant->setEncryptionKey($this->cryptStub->getKey()); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(7); $this->assertInstanceOf(RedirectResponse::class, $grant->completeAuthorizationRequest($authRequest)); @@ -1899,7 +1899,7 @@ public function testAuthCodeRepositoryFailToPersistUniqueNoInfiniteLoop() new DateInterval('PT10M') ); - $this->expectException(\League\OAuth2\Server\Exception\UniqueTokenIdentifierConstraintViolationException::class); + $this->expectException(UniqueTokenIdentifierConstraintViolationException::class); $this->expectExceptionCode(100); $this->assertInstanceOf(RedirectResponse::class, $grant->completeAuthorizationRequest($authRequest)); @@ -1958,17 +1958,17 @@ public function testRefreshTokenRepositoryUniqueConstraintCheck() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], 'redirect_uri' => self::REDIRECT_URI, ] ) @@ -2026,17 +2026,17 @@ public function testRefreshTokenRepositoryFailToPersist() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], 'redirect_uri' => self::REDIRECT_URI, ] ) @@ -2044,7 +2044,7 @@ public function testRefreshTokenRepositoryFailToPersist() ] ); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(7); /** @var StubResponseType $response */ @@ -2097,17 +2097,17 @@ public function testRefreshTokenRepositoryFailToPersistUniqueNoInfiniteLoop() [], [], [ - 'grant_type' => 'authorization_code', - 'client_id' => 'foo', + 'grant_type' => 'authorization_code', + 'client_id' => 'foo', 'redirect_uri' => self::REDIRECT_URI, - 'code' => $this->cryptStub->doEncrypt( + 'code' => $this->cryptStub->doEncrypt( \json_encode( [ 'auth_code_id' => \uniqid(), - 'expire_time' => \time() + 3600, - 'client_id' => 'foo', - 'user_id' => 123, - 'scopes' => ['foo'], + 'expire_time' => \time() + 3600, + 'client_id' => 'foo', + 'user_id' => 123, + 'scopes' => ['foo'], 'redirect_uri' => self::REDIRECT_URI, ] ) @@ -2115,7 +2115,7 @@ public function testRefreshTokenRepositoryFailToPersistUniqueNoInfiniteLoop() ] ); - $this->expectException(\League\OAuth2\Server\Exception\UniqueTokenIdentifierConstraintViolationException::class); + $this->expectException(UniqueTokenIdentifierConstraintViolationException::class); $this->expectExceptionCode(100); /** @var StubResponseType $response */ @@ -2162,8 +2162,8 @@ public function testPublicClientAuthCodeRequestRejectedWhenCodeChallengeRequired $request = (new ServerRequest())->withQueryParams([ 'response_type' => 'code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, ]); $this->expectException(OAuthServerException::class); diff --git a/tests/Grant/ClientCredentialsGrantTest.php b/tests/Grant/ClientCredentialsGrantTest.php index 13ea78bae..f6e67622d 100644 --- a/tests/Grant/ClientCredentialsGrantTest.php +++ b/tests/Grant/ClientCredentialsGrantTest.php @@ -52,7 +52,7 @@ public function testRespondToRequest() $grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key')); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', ]); diff --git a/tests/Grant/ImplicitGrantTest.php b/tests/Grant/ImplicitGrantTest.php index 5f69242c7..4b8ad838e 100644 --- a/tests/Grant/ImplicitGrantTest.php +++ b/tests/Grant/ImplicitGrantTest.php @@ -71,7 +71,7 @@ public function testCanRespondToAuthorizationRequest() $request = (new ServerRequest())->withQueryParams([ 'response_type' => 'token', - 'client_id' => 'foo', + 'client_id' => 'foo', ]); $this->assertTrue($grant->canRespondToAuthorizationRequest($request)); @@ -95,8 +95,8 @@ public function testValidateAuthorizationRequest() $request = (new ServerRequest())->withQueryParams([ 'response_type' => 'code', - 'client_id' => 'foo', - 'redirect_uri' => self::REDIRECT_URI, + 'client_id' => 'foo', + 'redirect_uri' => self::REDIRECT_URI, ]); $this->assertInstanceOf(AuthorizationRequest::class, $grant->validateAuthorizationRequest($request)); @@ -136,7 +136,7 @@ public function testValidateAuthorizationRequestMissingClientId() $request = (new ServerRequest())->withQueryParams(['response_type' => 'code']); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(3); $grant->validateAuthorizationRequest($request); @@ -152,10 +152,10 @@ public function testValidateAuthorizationRequestInvalidClientId() $request = (new ServerRequest())->withQueryParams([ 'response_type' => 'code', - 'client_id' => 'foo', + 'client_id' => 'foo', ]); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(4); $grant->validateAuthorizationRequest($request); @@ -177,7 +177,7 @@ public function testValidateAuthorizationRequestBadRedirectUriString() 'redirect_uri' => 'http://bar', ]); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(4); $grant->validateAuthorizationRequest($request); @@ -195,11 +195,11 @@ public function testValidateAuthorizationRequestBadRedirectUriArray() $request = (new ServerRequest())->withQueryParams([ 'response_type' => 'code', - 'client_id' => 'foo', - 'redirect_uri' => 'http://bar', + 'client_id' => 'foo', + 'redirect_uri' => 'http://bar', ]); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(4); $grant->validateAuthorizationRequest($request); @@ -258,7 +258,7 @@ public function testCompleteAuthorizationRequestDenied() $grant->setAccessTokenRepository($accessTokenRepositoryMock); $grant->setScopeRepository($scopeRepositoryMock); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(9); $grant->completeAuthorizationRequest($authRequest); @@ -326,7 +326,7 @@ public function testAccessTokenRepositoryFailToPersist() $grant->setAccessTokenRepository($accessTokenRepositoryMock); $grant->setScopeRepository($scopeRepositoryMock); - $this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class); + $this->expectException(OAuthServerException::class); $this->expectExceptionCode(7); $grant->completeAuthorizationRequest($authRequest); @@ -353,7 +353,7 @@ public function testAccessTokenRepositoryFailToPersistUniqueNoInfiniteLoop() $grant->setAccessTokenRepository($accessTokenRepositoryMock); $grant->setScopeRepository($scopeRepositoryMock); - $this->expectException(\League\OAuth2\Server\Exception\UniqueTokenIdentifierConstraintViolationException::class); + $this->expectException(UniqueTokenIdentifierConstraintViolationException::class); $this->expectExceptionCode(100); $grant->completeAuthorizationRequest($authRequest); diff --git a/tests/Grant/PasswordGrantTest.php b/tests/Grant/PasswordGrantTest.php index b53ab2357..01c7288b8 100644 --- a/tests/Grant/PasswordGrantTest.php +++ b/tests/Grant/PasswordGrantTest.php @@ -67,10 +67,10 @@ public function testRespondToRequest() $grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key')); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', - 'username' => 'foo', - 'password' => 'bar', + 'username' => 'foo', + 'password' => 'bar', ]); $responseType = new StubResponseType(); @@ -112,10 +112,10 @@ public function testRespondToRequestNullRefreshToken() $grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key')); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', - 'username' => 'foo', - 'password' => 'bar', + 'username' => 'foo', + 'password' => 'bar', ]); $responseType = new StubResponseType(); @@ -142,7 +142,7 @@ public function testRespondToRequestMissingUsername() $grant->setAccessTokenRepository($accessTokenRepositoryMock); $serverRequest = (new ServerRequest())->withQueryParams([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', ]); @@ -170,9 +170,9 @@ public function testRespondToRequestMissingPassword() $grant->setAccessTokenRepository($accessTokenRepositoryMock); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', - 'username' => 'alex', + 'username' => 'alex', ]); $responseType = new StubResponseType(); diff --git a/tests/Grant/RefreshTokenGrantTest.php b/tests/Grant/RefreshTokenGrantTest.php index 8f56fac4c..24bf8361a 100644 --- a/tests/Grant/RefreshTokenGrantTest.php +++ b/tests/Grant/RefreshTokenGrantTest.php @@ -74,21 +74,21 @@ public function testRespondToRequest() $oldRefreshToken = $this->cryptStub->doEncrypt( \json_encode( [ - 'client_id' => 'foo', + 'client_id' => 'foo', 'refresh_token_id' => 'zyxwvu', - 'access_token_id' => 'abcdef', - 'scopes' => ['foo'], - 'user_id' => 123, - 'expire_time' => \time() + 3600, + 'access_token_id' => 'abcdef', + 'scopes' => ['foo'], + 'user_id' => 123, + 'expire_time' => \time() + 3600, ] ) ); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', 'refresh_token' => $oldRefreshToken, - 'scopes' => ['foo'], + 'scopes' => ['foo'], ]); $responseType = new StubResponseType(); @@ -131,21 +131,21 @@ public function testRespondToRequestNullRefreshToken() $oldRefreshToken = $this->cryptStub->doEncrypt( \json_encode( [ - 'client_id' => 'foo', + 'client_id' => 'foo', 'refresh_token_id' => 'zyxwvu', - 'access_token_id' => 'abcdef', - 'scopes' => ['foo'], - 'user_id' => 123, - 'expire_time' => \time() + 3600, + 'access_token_id' => 'abcdef', + 'scopes' => ['foo'], + 'user_id' => 123, + 'expire_time' => \time() + 3600, ] ) ); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', 'refresh_token' => $oldRefreshToken, - 'scopes' => ['foo'], + 'scopes' => ['foo'], ]); $responseType = new StubResponseType(); @@ -188,21 +188,21 @@ public function testRespondToReducedScopes() $oldRefreshToken = $this->cryptStub->doEncrypt( \json_encode( [ - 'client_id' => 'foo', + 'client_id' => 'foo', 'refresh_token_id' => 'zyxwvu', - 'access_token_id' => 'abcdef', - 'scopes' => ['foo', 'bar'], - 'user_id' => 123, - 'expire_time' => \time() + 3600, + 'access_token_id' => 'abcdef', + 'scopes' => ['foo', 'bar'], + 'user_id' => 123, + 'expire_time' => \time() + 3600, ] ) ); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', 'refresh_token' => $oldRefreshToken, - 'scope' => 'foo', + 'scope' => 'foo', ]); $responseType = new StubResponseType(); @@ -242,21 +242,21 @@ public function testRespondToUnexpectedScope() $oldRefreshToken = $this->cryptStub->doEncrypt( \json_encode( [ - 'client_id' => 'foo', + 'client_id' => 'foo', 'refresh_token_id' => 'zyxwvu', - 'access_token_id' => 'abcdef', - 'scopes' => ['foo', 'bar'], - 'user_id' => 123, - 'expire_time' => \time() + 3600, + 'access_token_id' => 'abcdef', + 'scopes' => ['foo', 'bar'], + 'user_id' => 123, + 'expire_time' => \time() + 3600, ] ) ); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', 'refresh_token' => $oldRefreshToken, - 'scope' => 'foobar', + 'scope' => 'foobar', ]); $responseType = new StubResponseType(); @@ -286,7 +286,7 @@ public function testRespondToRequestMissingOldToken() $grant->setPrivateKey(new CryptKey('file://' . __DIR__ . '/../Stubs/private.key')); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', ]); @@ -319,7 +319,7 @@ public function testRespondToRequestInvalidOldToken() $oldRefreshToken = 'foobar'; $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', 'refresh_token' => $oldRefreshToken, ]); @@ -356,18 +356,18 @@ public function testRespondToRequestClientMismatch() $oldRefreshToken = $this->cryptStub->doEncrypt( \json_encode( [ - 'client_id' => 'bar', + 'client_id' => 'bar', 'refresh_token_id' => 'zyxwvu', - 'access_token_id' => 'abcdef', - 'scopes' => ['foo'], - 'user_id' => 123, - 'expire_time' => \time() + 3600, + 'access_token_id' => 'abcdef', + 'scopes' => ['foo'], + 'user_id' => 123, + 'expire_time' => \time() + 3600, ] ) ); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', 'refresh_token' => $oldRefreshToken, ]); @@ -401,18 +401,18 @@ public function testRespondToRequestExpiredToken() $oldRefreshToken = $this->cryptStub->doEncrypt( \json_encode( [ - 'client_id' => 'foo', + 'client_id' => 'foo', 'refresh_token_id' => 'zyxwvu', - 'access_token_id' => 'abcdef', - 'scopes' => ['foo'], - 'user_id' => 123, - 'expire_time' => \time() - 3600, + 'access_token_id' => 'abcdef', + 'scopes' => ['foo'], + 'user_id' => 123, + 'expire_time' => \time() - 3600, ] ) ); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', 'refresh_token' => $oldRefreshToken, ]); @@ -447,18 +447,18 @@ public function testRespondToRequestRevokedToken() $oldRefreshToken = $this->cryptStub->doEncrypt( \json_encode( [ - 'client_id' => 'foo', + 'client_id' => 'foo', 'refresh_token_id' => 'zyxwvu', - 'access_token_id' => 'abcdef', - 'scopes' => ['foo'], - 'user_id' => 123, - 'expire_time' => \time() + 3600, + 'access_token_id' => 'abcdef', + 'scopes' => ['foo'], + 'user_id' => 123, + 'expire_time' => \time() + 3600, ] ) ); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', 'refresh_token' => $oldRefreshToken, ]); @@ -500,21 +500,21 @@ public function testRevokedRefreshToken() $oldRefreshToken = $this->cryptStub->doEncrypt( \json_encode( [ - 'client_id' => 'foo', + 'client_id' => 'foo', 'refresh_token_id' => $refreshTokenId, - 'access_token_id' => 'abcdef', - 'scopes' => ['foo'], - 'user_id' => 123, - 'expire_time' => \time() + 3600, + 'access_token_id' => 'abcdef', + 'scopes' => ['foo'], + 'user_id' => 123, + 'expire_time' => \time() + 3600, ] ) ); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', 'refresh_token' => $oldRefreshToken, - 'scope' => ['foo'], + 'scope' => ['foo'], ]); $grant = new RefreshTokenGrant($refreshTokenRepositoryMock); @@ -557,21 +557,21 @@ public function testUnrevokedRefreshToken() $oldRefreshToken = $this->cryptStub->doEncrypt( \json_encode( [ - 'client_id' => 'foo', + 'client_id' => 'foo', 'refresh_token_id' => $refreshTokenId, - 'access_token_id' => 'abcdef', - 'scopes' => ['foo'], - 'user_id' => 123, - 'expire_time' => \time() + 3600, + 'access_token_id' => 'abcdef', + 'scopes' => ['foo'], + 'user_id' => 123, + 'expire_time' => \time() + 3600, ] ) ); $serverRequest = (new ServerRequest())->withParsedBody([ - 'client_id' => 'foo', + 'client_id' => 'foo', 'client_secret' => 'bar', 'refresh_token' => $oldRefreshToken, - 'scope' => ['foo'], + 'scope' => ['foo'], ]); $grant = new RefreshTokenGrant($refreshTokenRepositoryMock);