diff --git a/module/Rest/src/ApiKey/InitialApiKeyDelegator.php b/module/Rest/src/ApiKey/InitialApiKeyDelegator.php index 9129d7d3..a5aa9d33 100644 --- a/module/Rest/src/ApiKey/InitialApiKeyDelegator.php +++ b/module/Rest/src/ApiKey/InitialApiKeyDelegator.php @@ -15,7 +15,7 @@ class InitialApiKeyDelegator public function __invoke(ContainerInterface $container, string $serviceName, callable $callback): Application { $initialApiKey = $container->get('config')['initial_api_key'] ?? null; - if ($initialApiKey !== null) { + if (! empty($initialApiKey)) { $this->createInitialApiKey($initialApiKey, $container); } diff --git a/module/Rest/test/ApiKey/InitialApiKeyDelegatorTest.php b/module/Rest/test/ApiKey/InitialApiKeyDelegatorTest.php index 7614fc9d..1db53b80 100644 --- a/module/Rest/test/ApiKey/InitialApiKeyDelegatorTest.php +++ b/module/Rest/test/ApiKey/InitialApiKeyDelegatorTest.php @@ -54,8 +54,9 @@ class InitialApiKeyDelegatorTest extends TestCase public function provideConfigs(): iterable { - yield [[], 0]; - yield [['initial_api_key' => null], 0]; - yield [['initial_api_key' => 'the_initial_key'], 1]; + yield 'no api key' => [[], 0]; + yield 'null api key' => [['initial_api_key' => null], 0]; + yield 'empty api key' => [['initial_api_key' => ''], 0]; + yield 'valid api key' => [['initial_api_key' => 'the_initial_key'], 1]; } }