Ensured empty initial PAI keys are discarded

This commit is contained in:
Alejandro Celaya 2022-09-18 09:29:38 +02:00
parent c7f0d14c1b
commit 3f01fad12f
2 changed files with 5 additions and 4 deletions

View File

@ -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);
}

View File

@ -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];
}
}