diff --git a/api/config/packages/api_platform.yaml b/api/config/packages/api_platform.yaml index f1a21f3a9..68ef972eb 100644 --- a/api/config/packages/api_platform.yaml +++ b/api/config/packages/api_platform.yaml @@ -21,6 +21,7 @@ api_platform: vary: ['Content-Type', 'Authorization', 'Origin'] extra_properties: standard_put: true + rfc_7807_compliant_errors: true oauth: enabled: true clientId: '%env(OIDC_SWAGGER_CLIENT_ID)%' diff --git a/api/src/Entity/Book.php b/api/src/Entity/Book.php index 0c7a97c1e..25dee0858 100644 --- a/api/src/Entity/Book.php +++ b/api/src/Entity/Book.php @@ -35,7 +35,6 @@ #[ApiResource( uriTemplate: '/admin/books{._format}', types: ['https://schema.org/Book', 'https://schema.org/Offer'], - extraProperties: ['rfc_7807_compliant_errors' => true], operations: [ new GetCollection( itemUriTemplate: '/admin/books/{id}{._format}', @@ -74,7 +73,6 @@ )] #[ApiResource( types: ['https://schema.org/Book', 'https://schema.org/Offer'], - extraProperties: ['rfc_7807_compliant_errors' => true], operations: [ new GetCollection( itemUriTemplate: '/books/{id}{._format}' diff --git a/api/src/Entity/Bookmark.php b/api/src/Entity/Bookmark.php index 98126de86..14bc11c61 100644 --- a/api/src/Entity/Bookmark.php +++ b/api/src/Entity/Bookmark.php @@ -30,7 +30,6 @@ #[ApiResource( types: ['https://schema.org/BookmarkAction'], order: ['bookmarkedAt' => 'DESC'], - extraProperties: ['rfc_7807_compliant_errors' => true], operations: [ new GetCollection(), new Delete( diff --git a/api/src/Entity/Review.php b/api/src/Entity/Review.php index d118c0ed2..1c78b3aab 100644 --- a/api/src/Entity/Review.php +++ b/api/src/Entity/Review.php @@ -35,7 +35,6 @@ #[ApiResource( types: ['https://schema.org/Review'], order: ['publishedAt' => 'DESC'], - extraProperties: ['rfc_7807_compliant_errors' => true], operations: [ new GetCollection( uriTemplate: '/admin/reviews{._format}', @@ -80,7 +79,6 @@ #[ApiResource( types: ['https://schema.org/Review'], order: ['publishedAt' => 'DESC'], - extraProperties: ['rfc_7807_compliant_errors' => true], uriTemplate: '/books/{bookId}/reviews{._format}', uriVariables: [ 'bookId' => new Link(toProperty: 'book', fromClass: Book::class), diff --git a/api/src/Entity/User.php b/api/src/Entity/User.php index c1af0722b..bc84bf169 100644 --- a/api/src/Entity/User.php +++ b/api/src/Entity/User.php @@ -23,7 +23,6 @@ */ #[ApiResource( types: ['https://schema.org/Person'], - extraProperties: ['rfc_7807_compliant_errors' => true], operations: [ new GetCollection( uriTemplate: '/admin/users{._format}', 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.', diff --git a/helm/api-platform/values.yaml b/helm/api-platform/values.yaml index f34167902..8d0e8ef27 100644 --- a/helm/api-platform/values.yaml +++ b/helm/api-platform/values.yaml @@ -125,9 +125,7 @@ keycloak: postgresql: auth: postgresPassword: "!ThisMustBeChanged!" -# username: "example" password: "!ChangeMe!" -# database: "api" primary: persistence: enabled: true