diff --git a/tests/E2E/Controller/v1/Profile/GroupsControllerTest.php b/tests/E2E/Controller/v1/Profile/GroupsControllerTest.php index 0cb2b71b3..0985f0c2a 100644 --- a/tests/E2E/Controller/v1/Profile/GroupsControllerTest.php +++ b/tests/E2E/Controller/v1/Profile/GroupsControllerTest.php @@ -141,10 +141,12 @@ static function (stdClass $userGroup): string { * @throws JsonException */ #[DataProvider('dataProviderTestThatGroupsActionReturnExpectedWithValidApiKey')] - #[TestDox('Test that `GET /v1/profile/groups` request returns `401` with valid `$token` API key token')] - public function testThatGroupsActionReturnExpectedWithValidApiKey(string $token): void + #[TestDox( + 'Test that `GET /v1/profile/groups` request returns `401` with valid `$token` API key token ($role - role)' + )] + public function testThatGroupsActionReturnExpectedWithValidApiKey(string $token, string $role): void { - $client = $this->getApiKeyClient($token); + $client = $this->getApiKeyClient($role); $client->request('GET', $this->baseUrl); $response = $client->getResponse(); @@ -163,7 +165,7 @@ public function testThatGroupsActionReturnExpectedWithValidApiKey(string $token) self::assertSame(401, $responseContent->code, 'Response code was not expected' . $info); self::assertTrue(property_exists($responseContent, 'message'), 'Response does not contain "message"' . $info); self::assertSame( - 'JWT Token not found', + 'Invalid API key', $responseContent->message, 'Response message was not expected' . $info, ); @@ -192,9 +194,9 @@ public static function dataProviderTestThatGroupsActionReturnExpected(): Generat } /** - * @return Generator - * * @throws Throwable + * + * @return Generator */ public static function dataProviderTestThatGroupsActionReturnExpectedWithValidApiKey(): Generator { @@ -202,10 +204,10 @@ public static function dataProviderTestThatGroupsActionReturnExpectedWithValidAp if (getenv('USE_ALL_USER_COMBINATIONS') === 'yes') { foreach ($rolesService->getRoles() as $role) { - yield [str_pad($rolesService->getShort($role), 40, '_')]; + yield [str_pad($rolesService->getShort($role), 40, '_'), $role]; } } else { - yield [str_pad($rolesService->getShort(Role::LOGGED->value), 40, '_')]; + yield [str_pad($rolesService->getShort(Role::LOGGED->value), 40, '_'), Role::LOGGED->value]; } } diff --git a/tests/E2E/Controller/v1/Profile/IndexControllerTest.php b/tests/E2E/Controller/v1/Profile/IndexControllerTest.php index 1f998e211..61da92c9c 100644 --- a/tests/E2E/Controller/v1/Profile/IndexControllerTest.php +++ b/tests/E2E/Controller/v1/Profile/IndexControllerTest.php @@ -112,10 +112,11 @@ public function testThatProfileActionReturns401WithInvalidApiKey(): void * @throws JsonException */ #[DataProvider('dataProviderTestThatProfileActionReturnsExpectedWithValidApiKeyToken')] - #[TestDox('Test that `GET /v1/profile` request returns `401` with valid `$token` API key token')] - public function testThatProfileActionReturnsExpectedWithValidApiKeyToken(string $token): void + #[TestDox('Test that `GET /v1/profile` request returns `401` with valid `$token` API key token ($role - role)')] + public function testThatProfileActionReturnsExpectedWithValidApiKeyToken(string $token, string $role): void { - $client = $this->getApiKeyClient($token); + + $client = $this->getApiKeyClient($role); $client->request('GET', $this->baseUrl); $response = $client->getResponse(); @@ -134,7 +135,7 @@ public function testThatProfileActionReturnsExpectedWithValidApiKeyToken(string self::assertSame(401, $responseContent->code, 'Response code was not expected' . $info); self::assertTrue(property_exists($responseContent, 'message'), 'Response does not contain "message"' . $info); self::assertSame( - 'JWT Token not found', + 'Invalid API key', $responseContent->message, 'Response message was not expected' . $info, ); @@ -167,9 +168,9 @@ public static function dataProviderTestThatProfileActionReturnExpectedWithValidU } /** - * @return Generator - * * @throws Throwable + * + * @return Generator */ public static function dataProviderTestThatProfileActionReturnsExpectedWithValidApiKeyToken(): Generator { @@ -177,10 +178,10 @@ public static function dataProviderTestThatProfileActionReturnsExpectedWithValid if (getenv('USE_ALL_USER_COMBINATIONS') === 'yes') { foreach ($rolesService->getRoles() as $role) { - yield [str_pad($rolesService->getShort($role), 40, '_')]; + yield [str_pad($rolesService->getShort($role), 40, '_'), $role]; } } else { - yield [str_pad($rolesService->getShort(Role::LOGGED->value), 40, '_')]; + yield [str_pad($rolesService->getShort(Role::LOGGED->value), 40, '_'), Role::LOGGED->value]; } } diff --git a/tests/E2E/Controller/v1/Profile/RolesControllerTest.php b/tests/E2E/Controller/v1/Profile/RolesControllerTest.php index 5351ba334..aa240fe7a 100644 --- a/tests/E2E/Controller/v1/Profile/RolesControllerTest.php +++ b/tests/E2E/Controller/v1/Profile/RolesControllerTest.php @@ -113,10 +113,12 @@ public function testThatRolesActionReturnsExpected(string $u, string $p, Stringa * @throws JsonException */ #[DataProvider('dataProviderTestThatRolesActionReturnsExpectedWithValidApiKey')] - #[TestDox('Test that `GET /v1/profile/roles` request returns `401` with valid API key `$token` token')] - public function testThatRolesActionReturnsExpectedWithValidApiKey(string $token): void + #[TestDox( + 'Test that `GET /v1/profile/roles` request returns `401` with valid API key `$token` token ($role - role)' + )] + public function testThatRolesActionReturnsExpectedWithValidApiKey(string $token, string $role): void { - $client = $this->getApiKeyClient($token); + $client = $this->getApiKeyClient($role); $client->request('GET', $this->baseUrl); $response = $client->getResponse(); @@ -135,7 +137,7 @@ public function testThatRolesActionReturnsExpectedWithValidApiKey(string $token) self::assertSame(401, $responseContent->code, 'Response code was not expected' . $info); self::assertTrue(property_exists($responseContent, 'message'), 'Response does not contain "message"' . $info); self::assertSame( - 'JWT Token not found', + 'Invalid API key', $responseContent->message, 'Response message was not expected' . $info, ); @@ -212,7 +214,7 @@ public static function dataProviderTestThatRolesActionReturnsExpected(): Generat } /** - * @return Generator + * @return Generator * * @throws Throwable */ @@ -222,10 +224,10 @@ public static function dataProviderTestThatRolesActionReturnsExpectedWithValidAp if (getenv('USE_ALL_USER_COMBINATIONS') === 'yes') { foreach ($rolesService->getRoles() as $role) { - yield [str_pad($rolesService->getShort($role), 40, '_')]; + yield [str_pad($rolesService->getShort($role), 40, '_'), $role]; } } else { - yield [str_pad($rolesService->getShort(Role::LOGGED->value), 40, '_')]; + yield [str_pad($rolesService->getShort(Role::LOGGED->value), 40, '_'), Role::LOGGED->value]; } } diff --git a/tests/E2E/TestCase/Auth.php b/tests/E2E/TestCase/Auth.php index 6d5225392..8adec49f0 100644 --- a/tests/E2E/TestCase/Auth.php +++ b/tests/E2E/TestCase/Auth.php @@ -8,6 +8,7 @@ namespace App\Tests\E2E\TestCase; +use App\Enum\Role; use App\Utils\JSON; use JsonException; use Symfony\Bundle\FrameworkBundle\KernelBrowser;