Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Dev: strengthened DependencyInjection tests based on mutation testing
findings — the extension's container wiring (cache pool reference,
provider options mapping, CLI login route arguments) is now asserted
explicitly, and the documented invariant that provider keys are not
normalized (`my-provider` ≠ `my_provider`) is covered by a test. No
effect on the published package.

- CI: bumped `codecov/codecov-action` from `v5` to `v7` (restores Codecov's
GPG signing key after the `codecovsecurity` account was removed, and moves
the bundled `github-script` to Node 24) and set `fail_ci_if_error: false`
Expand Down
18 changes: 18 additions & 0 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,24 @@ public function testHttpClientOptionsRejectsUnknownKey(): void
);
}

public function testProviderKeysAreNotNormalized(): void
{
$input = $this->getMinimalConfig();
$input['openid_providers']['my-provider'] = $input['openid_providers']['provider1'];
unset($input['openid_providers']['provider1']);

$config = $this->processor->processConfiguration(
$this->configuration,
[$input]
);

// Provider keys are part of the public contract ('my-provider' and
// 'my_provider' are distinct providers), so dashes must survive
// config processing instead of being normalized to underscores.
$this->assertArrayHasKey('my-provider', $config['openid_providers']);
$this->assertArrayNotHasKey('my_provider', $config['openid_providers']);
}

public function testMultipleProviders(): void
{
$input = $this->getMinimalConfig();
Expand Down
42 changes: 42 additions & 0 deletions tests/DependencyInjection/ItkDevOpenIdConnectExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,48 @@ public function testLoad(): void
$this->assertTrue($container->hasDefinition(CliLoginTokenAuthenticator::class));
}

public function testLoadWiresProviderManagerConfig(): void
{
$extension = new ItkDevOpenIdConnectExtension();
$container = new ContainerBuilder();

$extension->load([$this->getBaseConfig()], $container);

$config = $container->getDefinition(OpenIdConfigurationProviderManager::class)->getArgument('$config');
$this->assertIsArray($config);

$defaultOptions = $config['default_providers_options'] ?? null;
$this->assertIsArray($defaultOptions);
$cacheItemPool = $defaultOptions['cacheItemPool'] ?? null;
$this->assertInstanceOf(Reference::class, $cacheItemPool);
$this->assertSame('cache.app', (string) $cacheItemPool);

// Provider options must be keyed by provider name with the
// intermediate 'options' level stripped.
$providers = $config['providers'] ?? null;
$this->assertIsArray($providers);
$this->assertSame(['test_provider'], array_keys($providers));
$provider = $providers['test_provider'];
$this->assertIsArray($provider);
$this->assertArrayNotHasKey('options', $provider);
$this->assertSame('test_id', $provider['client_id']);
}

public function testLoadWiresCacheAndCliLoginRoute(): void
{
$extension = new ItkDevOpenIdConnectExtension();
$container = new ContainerBuilder();

$extension->load([$this->getBaseConfig()], $container);

$cache = $container->getDefinition(CliLoginHelper::class)->getArgument('$cache');
$this->assertInstanceOf(Reference::class, $cache);
$this->assertSame('cache.app', (string) $cache);

$this->assertSame('test_route', $container->getDefinition(UserLoginCommand::class)->getArgument('$cliLoginRoute'));
$this->assertSame('test_route', $container->getDefinition(CliLoginTokenAuthenticator::class)->getArgument('$cliLoginRoute'));
}

public function testLoadWithUserProvider(): void
{
$extension = new ItkDevOpenIdConnectExtension();
Expand Down
Loading