From 116924293e406b53a0d32d771cfa7953e94c43d3 Mon Sep 17 00:00:00 2001 From: Vincent Chalamon <407859+vincentchalamon@users.noreply.github.com> Date: Fri, 22 Sep 2023 13:41:47 +0200 Subject: [PATCH] fix: remove '@context' response key when using rfc_7807_compliant_errors --- api/tests/Api/Admin/BookTest.php | 11 ----------- api/tests/Api/Admin/ReviewTest.php | 4 ---- api/tests/Api/Admin/UserTest.php | 2 -- api/tests/Api/BookmarkTest.php | 7 ------- api/tests/Api/ReviewTest.php | 10 ---------- 5 files changed, 34 deletions(-) diff --git a/api/tests/Api/Admin/BookTest.php b/api/tests/Api/Admin/BookTest.php index bea13c04c..8b6a5e5a0 100644 --- a/api/tests/Api/Admin/BookTest.php +++ b/api/tests/Api/Admin/BookTest.php @@ -54,7 +54,6 @@ public function testAsNonAdminUserICannotGetACollectionOfBooks(int $expectedCode self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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, @@ -197,7 +196,6 @@ public function testAsNonAdminUserICannotGetABook(int $expectedCode, string $hyd self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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, @@ -253,7 +251,6 @@ public function testAsNonAdminUserICannotCreateABook(int $expectedCode, string $ self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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, @@ -286,7 +283,6 @@ public function getInvalidDataOnCreate(): iterable [], Response::HTTP_UNPROCESSABLE_ENTITY, [ - '@context' => '/contexts/ConstraintViolationList', '@type' => 'ConstraintViolationList', 'hydra:title' => 'An error occurred', 'violations' => [ @@ -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.'.', @@ -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.'.', @@ -369,7 +361,6 @@ public function getInvalidData(): iterable ], Response::HTTP_UNPROCESSABLE_ENTITY, [ - '@context' => '/contexts/ConstraintViolationList', '@type' => 'ConstraintViolationList', 'hydra:title' => 'An error occurred', 'violations' => [ @@ -463,7 +454,6 @@ public function testAsNonAdminUserICannotUpdateBook(int $expectedCode, string $h self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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, @@ -591,7 +581,6 @@ public function testAsNonAdminUserICannotDeleteABook(int $expectedCode, string $ self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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, diff --git a/api/tests/Api/Admin/ReviewTest.php b/api/tests/Api/Admin/ReviewTest.php index ca39e9c86..afcd703b4 100644 --- a/api/tests/Api/Admin/ReviewTest.php +++ b/api/tests/Api/Admin/ReviewTest.php @@ -55,7 +55,6 @@ public function testAsNonAdminUserICannotGetACollectionOfReviews(int $expectedCo self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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, @@ -165,7 +164,6 @@ public function testAsNonAdminUserICannotGetAReview(int $expectedCode, string $h self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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, @@ -224,7 +222,6 @@ public function testAsNonAdminUserICannotUpdateAReview(int $expectedCode, string self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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, @@ -327,7 +324,6 @@ public function testAsNonAdminUserICannotDeleteAReview(int $expectedCode, string self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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, diff --git a/api/tests/Api/Admin/UserTest.php b/api/tests/Api/Admin/UserTest.php index 083eb1ddc..abfa156ac 100644 --- a/api/tests/Api/Admin/UserTest.php +++ b/api/tests/Api/Admin/UserTest.php @@ -48,7 +48,6 @@ public function testAsNonAdminUserICannotGetACollectionOfUsers(int $expectedCode self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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, @@ -127,7 +126,6 @@ public function testAsNonAdminUserICannotGetAUser(int $expectedCode, string $hyd self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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, diff --git a/api/tests/Api/BookmarkTest.php b/api/tests/Api/BookmarkTest.php index 20d51f451..e4aa3de08 100644 --- a/api/tests/Api/BookmarkTest.php +++ b/api/tests/Api/BookmarkTest.php @@ -43,7 +43,6 @@ public function testAsAnonymousICannotGetACollectionOfBookmarks(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', @@ -88,7 +87,6 @@ public function testAsAnonymousICannotCreateABookmark(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', @@ -116,14 +114,12 @@ public function testAsAUserICannotCreateABookmarkWithInvalidData(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.'.', @@ -201,7 +197,6 @@ public function testAsAUserICannotCreateADuplicateBookmark(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', @@ -218,7 +213,6 @@ public function testAsAnonymousICannotDeleteABookmark(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', @@ -241,7 +235,6 @@ public function testAsAUserICannotDeleteABookmarkOfAnotherUser(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', diff --git a/api/tests/Api/ReviewTest.php b/api/tests/Api/ReviewTest.php index fe8a432b1..6602f3f8c 100644 --- a/api/tests/Api/ReviewTest.php +++ b/api/tests/Api/ReviewTest.php @@ -143,7 +143,6 @@ public function testAsAnonymousICannotAddAReviewOnABook(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', @@ -178,7 +177,6 @@ public function getInvalidData(): iterable [], Response::HTTP_UNPROCESSABLE_ENTITY, [ - '@context' => '/contexts/ConstraintViolationList', '@type' => 'ConstraintViolationList', 'hydra:title' => 'An error occurred', 'violations' => [ @@ -217,7 +215,6 @@ public function testAsAUserICannotAddAReviewWithValidDataOnAnInvalidBook(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', @@ -299,7 +296,6 @@ public function testAsAUserICannotAddADuplicateReviewOnABook(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', @@ -316,7 +312,6 @@ public function testAsAnonymousICannotGetAnInvalidReview(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', @@ -333,7 +328,6 @@ public function testAsAnonymousICanGetABookReview(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', @@ -358,7 +352,6 @@ public function testAsAnonymousICannotUpdateABookReview(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', @@ -388,7 +381,6 @@ public function testAsAUserICannotUpdateABookReviewOfAnotherUser(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', @@ -470,7 +462,6 @@ public function testAsAnonymousICannotDeleteABookReview(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.', @@ -493,7 +484,6 @@ public function testAsAUserICannotDeleteABookReviewOfAnotherUser(): void self::assertResponseHeaderSame('content-type', 'application/problem+json; charset=utf-8'); self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; 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.',