Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message on duplicate SP entityID in PUSH #1317

Merged
merged 2 commits into from
Sep 4, 2024
Merged
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
12 changes: 10 additions & 2 deletions src/OpenConext/EngineBlock/Metadata/MfaEntityCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public static function fromMetadataPush(array $data): MfaEntityCollection
foreach ($data as $mfaEntityData) {
$entityId = (string) $mfaEntityData['name'];
$level = (string) $mfaEntityData['level'];
Assertion::keyNotExists($entities, $entityId, 'Duplicate SP entity ids are not allowed');
Assertion::keyNotExists(
$entities,
$entityId,
sprintf('Duplicate SP entity ids are not allowed in MFA list: %s', $entityId)
);
$entities[$entityId] = MfaEntityFactory::from($entityId, $level);
}
return new self($entities);
Expand All @@ -59,7 +63,11 @@ public static function fromCoin(array $data): MfaEntityCollection
$entities = [];
foreach ($data as $mfaEntityData) {
$entity = MfaEntityFactory::fromJson($mfaEntityData);
Assertion::keyNotExists($entities, $entity->entityId(), 'Duplicate SP entity ids are not allowed');
Assertion::keyNotExists(
$entities,
$entity->entityId(),
sprintf('Duplicate SP entity ids are not allowed in coin MFA list: %s', $entity->entityId())
);
$entities[$entity->entityId()] = $entity;
}
return new self($entities);
Expand Down