From ded06b38e31b76bd4c0dc7ee4e1422a5da257fee Mon Sep 17 00:00:00 2001 From: Jonathan LELIEVRE Date: Mon, 20 Jan 2025 19:07:10 +0100 Subject: [PATCH] Update ApiClient enabled constraint --- .../Resources/ApiClient/ApiClient.php | 2 +- .../ApiPlatform/ApiClientEndpointTest.php | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/ApiPlatform/Resources/ApiClient/ApiClient.php b/src/ApiPlatform/Resources/ApiClient/ApiClient.php index 2fadf80..45fb564 100644 --- a/src/ApiPlatform/Resources/ApiClient/ApiClient.php +++ b/src/ApiPlatform/Resources/ApiClient/ApiClient.php @@ -91,7 +91,7 @@ class ApiClient public ?string $externalIssuer; - #[Assert\NotBlank(groups: ['Create'])] + #[Assert\NotNull(groups: ['Create'])] public bool $enabled; #[Assert\NotBlank(groups: ['Create'])] diff --git a/tests/Integration/ApiPlatform/ApiClientEndpointTest.php b/tests/Integration/ApiPlatform/ApiClientEndpointTest.php index dc8f28f..b55dc5c 100644 --- a/tests/Integration/ApiPlatform/ApiClientEndpointTest.php +++ b/tests/Integration/ApiPlatform/ApiClientEndpointTest.php @@ -71,7 +71,8 @@ public function testAddApiClient(): int 'clientId' => 'client_id_test', 'clientName' => 'Client name test', 'description' => 'Client description test', - 'enabled' => true, + // Check that false can be used (previously bug because of a NotBlank constraint) + 'enabled' => false, 'lifetime' => 3600, 'scopes' => [ 'api_client_read', @@ -121,7 +122,7 @@ public function testGetApiClient(int $apiClientId): int 'clientName' => 'Client name test', 'description' => 'Client description test', 'externalIssuer' => null, - 'enabled' => true, + 'enabled' => false, 'lifetime' => 3600, 'scopes' => [ 'api_client_read', @@ -152,7 +153,7 @@ public function testUpdateApiClient(int $apiClientId): int 'clientId' => 'client_id_test_updated', 'clientName' => 'Client name test updated', 'description' => 'Client description test updated', - 'enabled' => false, + 'enabled' => true, 'lifetime' => 1800, 'scopes' => [ 'api_client_write', @@ -172,7 +173,7 @@ public function testUpdateApiClient(int $apiClientId): int 'clientName' => 'Client name test updated', 'description' => 'Client description test updated', 'externalIssuer' => null, - 'enabled' => false, + 'enabled' => true, 'lifetime' => 1800, 'scopes' => [ 'api_client_write', @@ -203,7 +204,7 @@ public function testUpdateApiClient(int $apiClientId): int 'clientName' => 'Client name test updated', 'description' => 'Client description test partially updated', 'externalIssuer' => null, - 'enabled' => false, + 'enabled' => true, 'lifetime' => 900, 'scopes' => [ 'api_client_write', @@ -240,7 +241,7 @@ public function testGetUpdatedApiClient(int $apiClientId): int 'clientName' => 'Client name test updated', 'description' => 'Client description test partially updated', 'externalIssuer' => null, - 'enabled' => false, + 'enabled' => true, 'lifetime' => 900, 'scopes' => [ 'api_client_write', @@ -274,7 +275,7 @@ public function testListApiClients(int $apiClientId): int 'clientName' => 'Client name test updated', 'description' => 'Client description test partially updated', 'externalIssuer' => null, - 'enabled' => false, + 'enabled' => true, 'lifetime' => 900, ], $apiClients['items'][1], @@ -368,7 +369,7 @@ public function testCreateInvalidApiClient(): void ], [ 'propertyPath' => 'enabled', - 'message' => 'This value should not be blank.', + 'message' => 'This value should not be null.', ], [ 'propertyPath' => 'description',