Skip to content

Commit

Permalink
fix: remove '@context' response key when using rfc_7807_compliant_errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon committed Sep 22, 2023
1 parent d2df072 commit 1169242
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 34 deletions.
11 changes: 0 additions & 11 deletions api/tests/Api/Admin/BookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public function testAsNonAdminUserICannotGetACollectionOfBooks(int $expectedCode
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -197,7 +196,6 @@ public function testAsNonAdminUserICannotGetABook(int $expectedCode, string $hyd
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -253,7 +251,6 @@ public function testAsNonAdminUserICannotCreateABook(int $expectedCode, string $
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -286,7 +283,6 @@ public function getInvalidDataOnCreate(): iterable
[],
Response::HTTP_UNPROCESSABLE_ENTITY,
[
'@context' => '/contexts/ConstraintViolationList',
'@type' => 'ConstraintViolationList',
'hydra:title' => 'An error occurred',
'violations' => [
Expand Down Expand Up @@ -315,12 +311,10 @@ public function getInvalidData(): iterable
// todo waiting for https://github.com/api-platform/core/pull/5844
// Response::HTTP_UNPROCESSABLE_ENTITY,
[
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'The data must belong to a backed enumeration of type '.BookCondition::class,
// todo waiting for https://github.com/api-platform/core/pull/5844[
// '@context' => '/contexts/ConstraintViolationList',
// '@type' => 'ConstraintViolationList',
// 'hydra:title' => 'An error occurred',
// 'hydra:description' => 'book: This value should not be blank.\ncondition: This value should be of type '.BookCondition::class.'.',
Expand All @@ -345,12 +339,10 @@ public function getInvalidData(): iterable
// todo waiting for https://github.com/api-platform/core/pull/5844
// Response::HTTP_UNPROCESSABLE_ENTITY,
[
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'The data must belong to a backed enumeration of type '.BookCondition::class,
// todo waiting for https://github.com/api-platform/core/pull/5844
// '@context' => '/contexts/ConstraintViolationList',
// '@type' => 'ConstraintViolationList',
// 'hydra:title' => 'An error occurred',
// 'hydra:description' => 'condition: This value should be of type '.BookCondition::class.'.',
Expand All @@ -369,7 +361,6 @@ public function getInvalidData(): iterable
],
Response::HTTP_UNPROCESSABLE_ENTITY,
[
'@context' => '/contexts/ConstraintViolationList',
'@type' => 'ConstraintViolationList',
'hydra:title' => 'An error occurred',
'violations' => [
Expand Down Expand Up @@ -463,7 +454,6 @@ public function testAsNonAdminUserICannotUpdateBook(int $expectedCode, string $h
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -591,7 +581,6 @@ public function testAsNonAdminUserICannotDeleteABook(int $expectedCode, string $
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down
4 changes: 0 additions & 4 deletions api/tests/Api/Admin/ReviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function testAsNonAdminUserICannotGetACollectionOfReviews(int $expectedCo
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -165,7 +164,6 @@ public function testAsNonAdminUserICannotGetAReview(int $expectedCode, string $h
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -224,7 +222,6 @@ public function testAsNonAdminUserICannotUpdateAReview(int $expectedCode, string
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -327,7 +324,6 @@ public function testAsNonAdminUserICannotDeleteAReview(int $expectedCode, string
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down
2 changes: 0 additions & 2 deletions api/tests/Api/Admin/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public function testAsNonAdminUserICannotGetACollectionOfUsers(int $expectedCode
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down Expand Up @@ -127,7 +126,6 @@ public function testAsNonAdminUserICannotGetAUser(int $expectedCode, string $hyd
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => $hydraDescription,
Expand Down
7 changes: 0 additions & 7 deletions api/tests/Api/BookmarkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function testAsAnonymousICannotGetACollectionOfBookmarks(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Full authentication is required to access this resource.',
Expand Down Expand Up @@ -88,7 +87,6 @@ public function testAsAnonymousICannotCreateABookmark(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Full authentication is required to access this resource.',
Expand Down Expand Up @@ -116,14 +114,12 @@ public function testAsAUserICannotCreateABookmarkWithInvalidData(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Item not found for "/books/'.$uuid.'".',
]);
// todo waiting for https://github.com/api-platform/core/pull/5844
// self::assertJsonContains([
// '@context' => '/contexts/ConstraintViolationList',
// '@type' => 'ConstraintViolationList',
// 'hydra:title' => 'An error occurred',
// 'hydra:description' => 'book: This value should be of type '.Book::class.'.',
Expand Down Expand Up @@ -201,7 +197,6 @@ public function testAsAUserICannotCreateADuplicateBookmark(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/ConstraintViolationList',
'@type' => 'ConstraintViolationList',
'hydra:title' => 'An error occurred',
'hydra:description' => 'You have already bookmarked this book.',
Expand All @@ -218,7 +213,6 @@ public function testAsAnonymousICannotDeleteABookmark(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Full authentication is required to access this resource.',
Expand All @@ -241,7 +235,6 @@ public function testAsAUserICannotDeleteABookmarkOfAnotherUser(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Access Denied.',
Expand Down
10 changes: 0 additions & 10 deletions api/tests/Api/ReviewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public function testAsAnonymousICannotAddAReviewOnABook(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Full authentication is required to access this resource.',
Expand Down Expand Up @@ -178,7 +177,6 @@ public function getInvalidData(): iterable
[],
Response::HTTP_UNPROCESSABLE_ENTITY,
[
'@context' => '/contexts/ConstraintViolationList',
'@type' => 'ConstraintViolationList',
'hydra:title' => 'An error occurred',
'violations' => [
Expand Down Expand Up @@ -217,7 +215,6 @@ public function testAsAUserICannotAddAReviewWithValidDataOnAnInvalidBook(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Invalid identifier value or configuration.',
Expand Down Expand Up @@ -299,7 +296,6 @@ public function testAsAUserICannotAddADuplicateReviewOnABook(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/ConstraintViolationList',
'@type' => 'ConstraintViolationList',
'hydra:title' => 'An error occurred',
'hydra:description' => 'You have already reviewed this book.',
Expand All @@ -316,7 +312,6 @@ public function testAsAnonymousICannotGetAnInvalidReview(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'This route does not aim to be called.',
Expand All @@ -333,7 +328,6 @@ public function testAsAnonymousICanGetABookReview(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'This route does not aim to be called.',
Expand All @@ -358,7 +352,6 @@ public function testAsAnonymousICannotUpdateABookReview(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Full authentication is required to access this resource.',
Expand Down Expand Up @@ -388,7 +381,6 @@ public function testAsAUserICannotUpdateABookReviewOfAnotherUser(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Access Denied.',
Expand Down Expand Up @@ -470,7 +462,6 @@ public function testAsAnonymousICannotDeleteABookReview(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Full authentication is required to access this resource.',
Expand All @@ -493,7 +484,6 @@ public function testAsAUserICannotDeleteABookReviewOfAnotherUser(): void
self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8');
self::assertResponseHeaderSame('link', '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error",<http://localhost/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"');
self::assertJsonContains([
'@context' => '/contexts/Error',
'@type' => 'hydra:Error',
'hydra:title' => 'An error occurred',
'hydra:description' => 'Access Denied.',
Expand Down

0 comments on commit 1169242

Please sign in to comment.