From 8efcb2f7896f23cbc487af9853a1b890febf5bff Mon Sep 17 00:00:00 2001 From: Vincent Chalamon <407859+vincentchalamon@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:26:12 +0200 Subject: [PATCH] fix: remove hydra prefix from error responses --- api/tests/Api/Admin/BookTest.php | 42 +++++++++++------------ api/tests/Api/Admin/ReviewTest.php | 24 ++++++------- api/tests/Api/Admin/UserTest.php | 12 +++---- api/tests/Api/BookmarkTest.php | 32 +++++++++--------- api/tests/Api/ReviewTest.php | 54 +++++++++++++++--------------- 5 files changed, 82 insertions(+), 82 deletions(-) diff --git a/api/tests/Api/Admin/BookTest.php b/api/tests/Api/Admin/BookTest.php index 74a605a12..929388686 100644 --- a/api/tests/Api/Admin/BookTest.php +++ b/api/tests/Api/Admin/BookTest.php @@ -54,9 +54,9 @@ public function asNonAdminUserICannotGetACollectionOfBooks(int $expectedCode, st 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -196,9 +196,9 @@ public function asNonAdminUserICannotGetABook(int $expectedCode, string $hydraDe 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -254,9 +254,9 @@ public function asNonAdminUserICannotCreateABook(int $expectedCode, string $hydr 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -290,7 +290,7 @@ public static function getInvalidDataOnCreate(): iterable Response::HTTP_UNPROCESSABLE_ENTITY, [ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', + 'title' => 'An error occurred', 'violations' => [ [ 'propertyPath' => 'book', @@ -316,8 +316,8 @@ public static function getInvalidData(): iterable Response::HTTP_UNPROCESSABLE_ENTITY, [ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'condition: This value should be of type ' . BookCondition::class . '.', + 'title' => 'An error occurred', + 'description' => 'condition: This value should be of type ' . BookCondition::class . '.', 'violations' => [ [ 'propertyPath' => 'condition', @@ -334,8 +334,8 @@ public static function getInvalidData(): iterable Response::HTTP_UNPROCESSABLE_ENTITY, [ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'condition: This value should be of type ' . BookCondition::class . '.', + 'title' => 'An error occurred', + 'description' => 'condition: This value should be of type ' . BookCondition::class . '.', 'violations' => [ [ 'propertyPath' => 'condition', @@ -352,7 +352,7 @@ public static function getInvalidData(): iterable Response::HTTP_UNPROCESSABLE_ENTITY, [ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', + 'title' => 'An error occurred', 'violations' => [ [ 'propertyPath' => 'book', @@ -442,9 +442,9 @@ public function asNonAdminUserICannotUpdateBook(int $expectedCode, string $hydra 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -570,9 +570,9 @@ public function asNonAdminUserICannotDeleteABook(int $expectedCode, string $hydr 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } diff --git a/api/tests/Api/Admin/ReviewTest.php b/api/tests/Api/Admin/ReviewTest.php index b8b87ec3d..ee36e0a37 100644 --- a/api/tests/Api/Admin/ReviewTest.php +++ b/api/tests/Api/Admin/ReviewTest.php @@ -55,9 +55,9 @@ public function asNonAdminUserICannotGetACollectionOfReviews(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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -163,9 +163,9 @@ public function asNonAdminUserICannotGetAReview(int $expectedCode, string $hydra 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -227,9 +227,9 @@ public function asNonAdminUserICannotUpdateAReview(int $expectedCode, string $hy 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -334,9 +334,9 @@ public function asNonAdminUserICannotDeleteAReview(int $expectedCode, string $hy 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } diff --git a/api/tests/Api/Admin/UserTest.php b/api/tests/Api/Admin/UserTest.php index cc5825d53..0e1f4c5b0 100644 --- a/api/tests/Api/Admin/UserTest.php +++ b/api/tests/Api/Admin/UserTest.php @@ -47,9 +47,9 @@ public function asNonAdminUserICannotGetACollectionOfUsers(int $expectedCode, st 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } @@ -123,9 +123,9 @@ public function asNonAdminUserICannotGetAUser(int $expectedCode, string $hydraDe 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => $hydraDescription, + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => $hydraDescription, ]); } diff --git a/api/tests/Api/BookmarkTest.php b/api/tests/Api/BookmarkTest.php index f668dbd41..61105e668 100644 --- a/api/tests/Api/BookmarkTest.php +++ b/api/tests/Api/BookmarkTest.php @@ -45,9 +45,9 @@ public function asAnonymousICannotGetACollectionOfBookmarks(): 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Full authentication is required to access this resource.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Full authentication is required to access this resource.', ]); } @@ -97,9 +97,9 @@ public function asAnonymousICannotCreateABookmark(): 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Full authentication is required to access this resource.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Full authentication is required to access this resource.', ]); } @@ -129,8 +129,8 @@ public function asAUserICannotCreateABookmarkWithInvalidData(): void self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'book: This value should be of type ' . Book::class . '.', + 'title' => 'An error occurred', + 'description' => 'book: This value should be of type ' . Book::class . '.', 'violations' => [ [ 'propertyPath' => 'book', @@ -219,8 +219,8 @@ public function asAUserICannotCreateADuplicateBookmark(): void self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'You have already bookmarked this book.', + 'title' => 'An error occurred', + 'description' => 'You have already bookmarked this book.', ]); } @@ -235,9 +235,9 @@ public function asAnonymousICannotDeleteABookmark(): 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Full authentication is required to access this resource.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Full authentication is required to access this resource.', ]); } @@ -259,9 +259,9 @@ public function asAUserICannotDeleteABookmarkOfAnotherUser(): 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Access Denied.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Access Denied.', ]); } diff --git a/api/tests/Api/ReviewTest.php b/api/tests/Api/ReviewTest.php index 26dcc203b..59fd20f0b 100644 --- a/api/tests/Api/ReviewTest.php +++ b/api/tests/Api/ReviewTest.php @@ -150,9 +150,9 @@ public function asAnonymousICannotAddAReviewOnABook(): 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Full authentication is required to access this resource.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Full authentication is required to access this resource.', ]); } @@ -189,7 +189,7 @@ public static function getInvalidData(): iterable Response::HTTP_UNPROCESSABLE_ENTITY, [ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', + 'title' => 'An error occurred', 'violations' => [ [ 'propertyPath' => 'body', @@ -231,9 +231,9 @@ public function asAUserICannotAddAReviewWithValidDataOnAnInvalidBook(): 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Invalid uri variables.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Invalid uri variables.', ]); } @@ -326,8 +326,8 @@ public function asAUserICannotAddADuplicateReviewOnABook(): void self::assertResponseHeaderSame('link', '; rel="http://www.w3.org/ns/json-ld#error",; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); self::assertJsonContains([ '@type' => 'ConstraintViolationList', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'You have already reviewed this book.', + 'title' => 'An error occurred', + 'description' => 'You have already reviewed this book.', ]); } @@ -342,9 +342,9 @@ public function asAnonymousICannotGetAnInvalidReview(): 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'This route does not aim to be called.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'This route does not aim to be called.', ]); } @@ -359,9 +359,9 @@ public function asAnonymousICanGetABookReview(): 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'This route does not aim to be called.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'This route does not aim to be called.', ]); } @@ -384,9 +384,9 @@ public function asAnonymousICannotUpdateABookReview(): 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Full authentication is required to access this resource.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Full authentication is required to access this resource.', ]); } @@ -415,9 +415,9 @@ public function asAUserICannotUpdateABookReviewOfAnotherUser(): 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Access Denied.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Access Denied.', ]); } @@ -501,9 +501,9 @@ public function asAnonymousICannotDeleteABookReview(): 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Full authentication is required to access this resource.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Full authentication is required to access this resource.', ]); } @@ -525,9 +525,9 @@ public function asAUserICannotDeleteABookReviewOfAnotherUser(): 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([ - '@type' => 'hydra:Error', - 'hydra:title' => 'An error occurred', - 'hydra:description' => 'Access Denied.', + '@type' => 'Error', + 'title' => 'An error occurred', + 'description' => 'Access Denied.', ]); }