Skip to content

Commit

Permalink
Use error_description instead of message field
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgarlag committed Apr 22, 2024
1 parent 329ac3c commit c1ac65c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions tests/Acceptance/AuthorizationEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function testAuthCodeRequestWithPublicClientWithoutCodeChallengeWhenTheCh
$jsonResponse = json_decode($response->getContent(), true);

$this->assertSame('invalid_request', $jsonResponse['error']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $jsonResponse['message']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $jsonResponse['error_description']);
$this->assertSame('Code challenge must be provided for public clients', $jsonResponse['hint']);
}

Expand Down Expand Up @@ -198,7 +198,7 @@ public function testAuthCodeRequestWithClientWhoIsNotAllowedToMakeARequestWithPl
$jsonResponse = json_decode($response->getContent(), true);

$this->assertSame('invalid_request', $jsonResponse['error']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $jsonResponse['message']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $jsonResponse['error_description']);
$this->assertSame('Plain code challenge method is not allowed for this client', $jsonResponse['hint']);
}

Expand Down Expand Up @@ -425,7 +425,7 @@ public function testFailedCodeRequestRedirectWithFakedRedirectUri(): void
$jsonResponse = json_decode($response->getContent(), true);

$this->assertSame('invalid_client', $jsonResponse['error']);
$this->assertSame('Client authentication failed', $jsonResponse['message']);
$this->assertSame('Client authentication failed', $jsonResponse['error_description']);
}

public function testFailedAuthorizeRequest(): void
Expand All @@ -443,7 +443,7 @@ public function testFailedAuthorizeRequest(): void
$jsonResponse = json_decode($response->getContent(), true);

$this->assertSame('unsupported_grant_type', $jsonResponse['error']);
$this->assertSame('The authorization grant type is not supported by the authorization server.', $jsonResponse['message']);
$this->assertSame('The authorization grant type is not supported by the authorization server.', $jsonResponse['error_description']);
$this->assertSame('Check that all required parameters have been provided', $jsonResponse['hint']);
}
}
4 changes: 2 additions & 2 deletions tests/Acceptance/TokenEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public function testFailedTokenRequest(): void
$jsonResponse = json_decode($response->getContent(), true);

$this->assertSame('unsupported_grant_type', $jsonResponse['error']);
$this->assertSame('The authorization grant type is not supported by the authorization server.', $jsonResponse['message']);
$this->assertSame('The authorization grant type is not supported by the authorization server.', $jsonResponse['error_description']);
$this->assertSame('Check that all required parameters have been provided', $jsonResponse['hint']);
}

Expand Down Expand Up @@ -335,7 +335,7 @@ public function testFailedClientCredentialsTokenRequest(): void
$jsonResponse = json_decode($response->getContent(), true);

$this->assertSame('invalid_client', $jsonResponse['error']);
$this->assertSame('Client authentication failed', $jsonResponse['message']);
$this->assertSame('Client authentication failed', $jsonResponse['error_description']);
$this->assertSame('bar', $response->headers->get('foo'));

$this->assertTrue($wasClientAuthenticationEventDispatched);
Expand Down
62 changes: 31 additions & 31 deletions tests/Integration/AuthorizationServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testMissingAuthorizationCredentials(): void

// Response assertions.
$this->assertSame('invalid_request', $response['error']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $response['message']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $response['error_description']);
$this->assertSame('Check the `client_id` parameter', $response['hint']);
}

Expand All @@ -79,7 +79,7 @@ public function testInvalidAuthorizationCredentials(): void

// Response assertions.
$this->assertSame('invalid_client', $response['error']);
$this->assertSame('Client authentication failed', $response['message']);
$this->assertSame('Client authentication failed', $response['error_description']);
}

public function testMissingClient(): void
Expand All @@ -92,7 +92,7 @@ public function testMissingClient(): void

// Response assertions.
$this->assertSame('invalid_client', $response['error']);
$this->assertSame('Client authentication failed', $response['message']);
$this->assertSame('Client authentication failed', $response['error_description']);
}

public function testInactiveClient(): void
Expand All @@ -105,7 +105,7 @@ public function testInactiveClient(): void

// Response assertions.
$this->assertSame('invalid_client', $response['error']);
$this->assertSame('Client authentication failed', $response['message']);
$this->assertSame('Client authentication failed', $response['error_description']);
}

public function testRestrictedGrantClient(): void
Expand All @@ -118,7 +118,7 @@ public function testRestrictedGrantClient(): void

// Response assertions.
$this->assertSame('invalid_client', $response['error']);
$this->assertSame('Client authentication failed', $response['message']);
$this->assertSame('Client authentication failed', $response['error_description']);
}

public function testRestrictedScopeClient(): void
Expand All @@ -132,7 +132,7 @@ public function testRestrictedScopeClient(): void

// Response assertions.
$this->assertSame('invalid_scope', $response['error']);
$this->assertSame('The requested scope is invalid, unknown, or malformed', $response['message']);
$this->assertSame('The requested scope is invalid, unknown, or malformed', $response['error_description']);
$this->assertSame('Check the `fancy` scope', $response['hint']);
}

Expand All @@ -146,7 +146,7 @@ public function testInvalidGrantType(): void

// Response assertions.
$this->assertSame('unsupported_grant_type', $response['error']);
$this->assertSame('The authorization grant type is not supported by the authorization server.', $response['message']);
$this->assertSame('The authorization grant type is not supported by the authorization server.', $response['error_description']);
$this->assertSame('Check that all required parameters have been provided', $response['hint']);
}

Expand All @@ -161,7 +161,7 @@ public function testInvalidScope(): void

// Response assertions.
$this->assertSame('invalid_scope', $response['error']);
$this->assertSame('The requested scope is invalid, unknown, or malformed', $response['message']);
$this->assertSame('The requested scope is invalid, unknown, or malformed', $response['error_description']);
$this->assertSame('Check the `non_existing` scope', $response['hint']);
}

Expand Down Expand Up @@ -326,7 +326,7 @@ public function testMissingUsernameFieldPasswordGrant(): void

// Response assertions.
$this->assertSame('invalid_request', $response['error']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $response['message']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $response['error_description']);
$this->assertSame('Check the `username` parameter', $response['hint']);
}

Expand All @@ -341,7 +341,7 @@ public function testMissingPasswordFieldPasswordGrant(): void

// Response assertions.
$this->assertSame('invalid_request', $response['error']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $response['message']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $response['error_description']);
$this->assertSame('Check the `password` parameter', $response['hint']);
}

Expand Down Expand Up @@ -388,7 +388,7 @@ public function testDifferentClientRefreshGrant(): void

// Response assertions.
$this->assertSame('invalid_request', $response['error']);
$this->assertSame('The refresh token is invalid.', $response['message']);
$this->assertSame('The refresh token is invalid.', $response['error_description']);
$this->assertSame('Token is not linked to client', $response['hint']);
}

Expand All @@ -406,7 +406,7 @@ public function testDifferentScopeRefreshGrant(): void

// Response assertions.
$this->assertSame('invalid_scope', $response['error']);
$this->assertSame('The requested scope is invalid, unknown, or malformed', $response['message']);
$this->assertSame('The requested scope is invalid, unknown, or malformed', $response['error_description']);
$this->assertSame('Check the `rock` scope', $response['hint']);
}

Expand All @@ -423,7 +423,7 @@ public function testExpiredRefreshGrant(): void

// Response assertions.
$this->assertSame('invalid_request', $response['error']);
$this->assertSame('The refresh token is invalid.', $response['message']);
$this->assertSame('The refresh token is invalid.', $response['error_description']);
$this->assertSame('Token has expired', $response['hint']);
}

Expand All @@ -440,7 +440,7 @@ public function testRevokedRefreshGrant(): void

// Response assertions.
$this->assertSame('invalid_request', $response['error']);
$this->assertSame('The refresh token is invalid.', $response['message']);
$this->assertSame('The refresh token is invalid.', $response['error_description']);
$this->assertSame('Token has been revoked', $response['hint']);
}

Expand All @@ -454,7 +454,7 @@ public function testMissingPayloadRefreshGrant(): void

// Response assertions.
$this->assertSame('invalid_request', $response['error']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $response['message']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $response['error_description']);
$this->assertSame('Check the `refresh_token` parameter', $response['hint']);
}

Expand All @@ -469,7 +469,7 @@ public function testInvalidPayloadRefreshGrant(): void

// Response assertions.
$this->assertSame('invalid_request', $response['error']);
$this->assertSame('The refresh token is invalid.', $response['message']);
$this->assertSame('The refresh token is invalid.', $response['error_description']);
$this->assertSame('Cannot decrypt the refresh token', $response['hint']);
}

Expand Down Expand Up @@ -543,7 +543,7 @@ public function testCodeRequestWithInvalidScope(): void
$this->assertStringStartsWith(FixtureFactory::FIXTURE_CLIENT_FIRST_REDIRECT_URI, $response->getHeaderLine('Location'));
$queryData = $this->extractQueryDataFromUri($response->getHeaderLine('Location'));
$this->assertSame('invalid_scope', $queryData['error']);
$this->assertSame('The requested scope is invalid, unknown, or malformed', $queryData['message']);
$this->assertSame('The requested scope is invalid, unknown, or malformed', $queryData['error_description']);
$this->assertSame('Check the `non_existing` scope', $queryData['hint']);
}

Expand All @@ -561,7 +561,7 @@ public function testCodeRequestWithInvalidRedirectUri(): void
$this->assertSame(401, $response->getStatusCode());
$responseData = json_decode((string) $response->getBody(), true);
$this->assertSame('invalid_client', $responseData['error']);
$this->assertSame('Client authentication failed', $responseData['message']);
$this->assertSame('Client authentication failed', $responseData['error_description']);
}

public function testDeniedCodeRequest(): void
Expand All @@ -579,7 +579,7 @@ public function testDeniedCodeRequest(): void
$this->assertStringStartsWith(FixtureFactory::FIXTURE_CLIENT_FIRST_REDIRECT_URI, $response->getHeaderLine('Location'));
$queryData = $this->extractQueryDataFromUri($response->getHeaderLine('Location'));
$this->assertSame('access_denied', $queryData['error']);
$this->assertSame('The resource owner or authorization server denied the request.', $queryData['message']);
$this->assertSame('The resource owner or authorization server denied the request.', $queryData['error_description']);
$this->assertSame('The user denied the request', $queryData['hint']);
}

Expand All @@ -596,7 +596,7 @@ public function testCodeRequestWithMissingClient(): void
$this->assertSame(401, $response->getStatusCode());
$responseData = json_decode((string) $response->getBody(), true);
$this->assertSame('invalid_client', $responseData['error']);
$this->assertSame('Client authentication failed', $responseData['message']);
$this->assertSame('Client authentication failed', $responseData['error_description']);
}

public function testCodeRequestWithInactiveClient(): void
Expand All @@ -612,7 +612,7 @@ public function testCodeRequestWithInactiveClient(): void
$this->assertSame(401, $response->getStatusCode());
$responseData = json_decode((string) $response->getBody(), true);
$this->assertSame('invalid_client', $responseData['error']);
$this->assertSame('Client authentication failed', $responseData['message']);
$this->assertSame('Client authentication failed', $responseData['error_description']);
}

public function testCodeRequestWithRestrictedGrantClient(): void
Expand All @@ -628,7 +628,7 @@ public function testCodeRequestWithRestrictedGrantClient(): void
$this->assertSame(401, $response->getStatusCode());
$responseData = json_decode((string) $response->getBody(), true);
$this->assertSame('invalid_client', $responseData['error']);
$this->assertSame('Client authentication failed', $responseData['message']);
$this->assertSame('Client authentication failed', $responseData['error_description']);
}

public function testSuccessfulAuthorizationWithCode(): void
Expand Down Expand Up @@ -665,7 +665,7 @@ public function testFailedAuthorizationWithCodeForOtherClient(): void

// Response assertions.
$this->assertSame('invalid_request', $response['error']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $response['message']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $response['error_description']);
$this->assertSame('Authorization code was not issued to this client', $response['hint']);
}

Expand All @@ -683,7 +683,7 @@ public function testFailedAuthorizationWithExpiredCode(): void

// Response assertions.
$this->assertSame('invalid_request', $response['error']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $response['message']);
$this->assertSame('The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.', $response['error_description']);
$this->assertSame('Authorization code has expired', $response['hint']);
}

Expand All @@ -701,7 +701,7 @@ public function testFailedAuthorizationWithInvalidRedirectUri(): void

// Response assertions.
$this->assertSame('invalid_client', $response['error']);
$this->assertSame('Client authentication failed', $response['message']);
$this->assertSame('Client authentication failed', $response['error_description']);
}

public function testSuccessfulImplicitRequest(): void
Expand Down Expand Up @@ -786,7 +786,7 @@ public function testImplicitRequestWithInvalidScope(): void

// Response assertions.
$this->assertSame('invalid_scope', $responseData['error']);
$this->assertSame('The requested scope is invalid, unknown, or malformed', $responseData['message']);
$this->assertSame('The requested scope is invalid, unknown, or malformed', $responseData['error_description']);
$this->assertSame('Check the `non_existing` scope', $responseData['hint']);
}

Expand All @@ -804,7 +804,7 @@ public function testImplicitRequestWithInvalidRedirectUri(): void

// Response assertions.
$this->assertSame('invalid_client', $responseData['error']);
$this->assertSame('Client authentication failed', $responseData['message']);
$this->assertSame('Client authentication failed', $responseData['error_description']);
}

public function testDeniedImplicitRequest(): void
Expand All @@ -821,7 +821,7 @@ public function testDeniedImplicitRequest(): void

// Response assertions.
$this->assertSame('access_denied', $responseData['error']);
$this->assertSame('The resource owner or authorization server denied the request.', $responseData['message']);
$this->assertSame('The resource owner or authorization server denied the request.', $responseData['error_description']);
$this->assertSame('The user denied the request', $responseData['hint']);
}

Expand All @@ -838,7 +838,7 @@ public function testImplicitRequestWithMissingClient(): void

// Response assertions.
$this->assertSame('invalid_client', $responseData['error']);
$this->assertSame('Client authentication failed', $responseData['message']);
$this->assertSame('Client authentication failed', $responseData['error_description']);
}

public function testImplicitRequestWithInactiveClient(): void
Expand All @@ -854,7 +854,7 @@ public function testImplicitRequestWithInactiveClient(): void

// Response assertions.
$this->assertSame('invalid_client', $responseData['error']);
$this->assertSame('Client authentication failed', $responseData['message']);
$this->assertSame('Client authentication failed', $responseData['error_description']);
}

public function testImplicitRequestWithRestrictedGrantClient(): void
Expand All @@ -870,6 +870,6 @@ public function testImplicitRequestWithRestrictedGrantClient(): void

// Response assertions.
$this->assertSame('invalid_client', $responseData['error']);
$this->assertSame('Client authentication failed', $responseData['message']);
$this->assertSame('Client authentication failed', $responseData['error_description']);
}
}

0 comments on commit c1ac65c

Please sign in to comment.