Skip to content

Commit c1ac65c

Browse files
committed
Use error_description instead of message field
See thephpleague/oauth2-server#1375
1 parent 329ac3c commit c1ac65c

File tree

3 files changed

+37
-37
lines changed

3 files changed

+37
-37
lines changed

tests/Acceptance/AuthorizationEndpointTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function testAuthCodeRequestWithPublicClientWithoutCodeChallengeWhenTheCh
158158
$jsonResponse = json_decode($response->getContent(), true);
159159

160160
$this->assertSame('invalid_request', $jsonResponse['error']);
161-
$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']);
161+
$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']);
162162
$this->assertSame('Code challenge must be provided for public clients', $jsonResponse['hint']);
163163
}
164164

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

200200
$this->assertSame('invalid_request', $jsonResponse['error']);
201-
$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']);
201+
$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']);
202202
$this->assertSame('Plain code challenge method is not allowed for this client', $jsonResponse['hint']);
203203
}
204204

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

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

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

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

tests/Acceptance/TokenEndpointTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function testFailedTokenRequest(): void
303303
$jsonResponse = json_decode($response->getContent(), true);
304304

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

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

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

341341
$this->assertTrue($wasClientAuthenticationEventDispatched);

tests/Integration/AuthorizationServerTest.php

+31-31
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testMissingAuthorizationCredentials(): void
6565

6666
// Response assertions.
6767
$this->assertSame('invalid_request', $response['error']);
68-
$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']);
68+
$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']);
6969
$this->assertSame('Check the `client_id` parameter', $response['hint']);
7070
}
7171

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

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

8585
public function testMissingClient(): void
@@ -92,7 +92,7 @@ public function testMissingClient(): void
9292

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

9898
public function testInactiveClient(): void
@@ -105,7 +105,7 @@ public function testInactiveClient(): void
105105

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

111111
public function testRestrictedGrantClient(): void
@@ -118,7 +118,7 @@ public function testRestrictedGrantClient(): void
118118

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

124124
public function testRestrictedScopeClient(): void
@@ -132,7 +132,7 @@ public function testRestrictedScopeClient(): void
132132

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

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

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

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

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

@@ -326,7 +326,7 @@ public function testMissingUsernameFieldPasswordGrant(): void
326326

327327
// Response assertions.
328328
$this->assertSame('invalid_request', $response['error']);
329-
$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']);
329+
$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']);
330330
$this->assertSame('Check the `username` parameter', $response['hint']);
331331
}
332332

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

342342
// Response assertions.
343343
$this->assertSame('invalid_request', $response['error']);
344-
$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']);
344+
$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']);
345345
$this->assertSame('Check the `password` parameter', $response['hint']);
346346
}
347347

@@ -388,7 +388,7 @@ public function testDifferentClientRefreshGrant(): void
388388

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

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

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

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

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

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

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

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

455455
// Response assertions.
456456
$this->assertSame('invalid_request', $response['error']);
457-
$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']);
457+
$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']);
458458
$this->assertSame('Check the `refresh_token` parameter', $response['hint']);
459459
}
460460

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

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

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

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

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

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

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

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

634634
public function testSuccessfulAuthorizationWithCode(): void
@@ -665,7 +665,7 @@ public function testFailedAuthorizationWithCodeForOtherClient(): void
665665

666666
// Response assertions.
667667
$this->assertSame('invalid_request', $response['error']);
668-
$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']);
668+
$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']);
669669
$this->assertSame('Authorization code was not issued to this client', $response['hint']);
670670
}
671671

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

684684
// Response assertions.
685685
$this->assertSame('invalid_request', $response['error']);
686-
$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']);
686+
$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']);
687687
$this->assertSame('Authorization code has expired', $response['hint']);
688688
}
689689

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

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

707707
public function testSuccessfulImplicitRequest(): void
@@ -786,7 +786,7 @@ public function testImplicitRequestWithInvalidScope(): void
786786

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

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

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

810810
public function testDeniedImplicitRequest(): void
@@ -821,7 +821,7 @@ public function testDeniedImplicitRequest(): void
821821

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

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

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

844844
public function testImplicitRequestWithInactiveClient(): void
@@ -854,7 +854,7 @@ public function testImplicitRequestWithInactiveClient(): void
854854

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

860860
public function testImplicitRequestWithRestrictedGrantClient(): void
@@ -870,6 +870,6 @@ public function testImplicitRequestWithRestrictedGrantClient(): void
870870

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

0 commit comments

Comments
 (0)