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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "enhancement",
"description": "Update identity chain validation to use case-insensitive comparisons for provider names."
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ def _validate_providers(providers: Sequence[ChainIdentityProvider]) -> None:
discovered_standard_slots: dict[StandardProvider, ChainIdentityProvider] = {}

for provider in providers:
if (previous := discovered_names.get(provider.name)) is not None:
normalized_name = provider.name.casefold()
if (previous := discovered_names.get(normalized_name)) is not None:
raise IdentityChainConfigurationError(
f"Credential providers {type(previous).__name__} and "
f"{type(provider).__name__} use the same name: {provider.name}."
)
discovered_names[provider.name] = provider
discovered_names[normalized_name] = provider

ordering = provider.ordering
if isinstance(ordering, Standard):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ def test_validate_rejects_duplicate_names() -> None:
chain_module._validate_providers((first, second))


def test_validate_rejects_case_insensitive_duplicate_names() -> None:
first = _StubProvider("Duplicate", Standard(slot=StandardProvider.ENVIRONMENT))
second = _StubProvider("duplicate", Standard(slot=StandardProvider.SHARED_CONFIG))

with pytest.raises(
IdentityChainConfigurationError,
match="Credential providers _StubProvider and _StubProvider use the "
"same name: duplicate",
):
chain_module._validate_providers((first, second))


def test_validate_rejects_duplicate_standard_slots() -> None:
first = _StubProvider("a", Standard(slot=StandardProvider.ENVIRONMENT))
second = _StubProvider("b", Standard(slot=StandardProvider.ENVIRONMENT))
Expand Down
Loading