From 611f3808dd94bc05ce54b5fee0c7fe935482e686 Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Fri, 12 Jul 2024 19:10:21 +0200 Subject: [PATCH] Add excludeCredentials field to various test cases The "excludeCredentials" field has been added to PublicKeyCredentialCreationOptionsTest.php, SerializerTest.php, and AdditionalAuthenticatorTest.php. This change ensures these tests are accurately testing all elements of authenticator credentials, including the 'excludeCredentials' field. --- tests/library/Unit/PublicKeyCredentialCreationOptionsTest.php | 2 +- tests/library/Unit/SerializerTest.php | 1 + .../functional/Attestation/AdditionalAuthenticatorTest.php | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/library/Unit/PublicKeyCredentialCreationOptionsTest.php b/tests/library/Unit/PublicKeyCredentialCreationOptionsTest.php index 7a44dbf22..e686c09b5 100644 --- a/tests/library/Unit/PublicKeyCredentialCreationOptionsTest.php +++ b/tests/library/Unit/PublicKeyCredentialCreationOptionsTest.php @@ -90,7 +90,7 @@ public function anPublicKeyCredentialCreationOptionsWithoutExcludeCredentialsCan AbstractObjectNormalizer::SKIP_NULL_VALUES => true, ]); static::assertJsonStringEqualsJsonString( - '{"rp":{"name":"RP"},"user":{"name":"USER","id":"aWQ","displayName":"FOO BAR"},"challenge":"Y2hhbGxlbmdl","pubKeyCredParams":[{"type":"type","alg":-100}],"timeout":1000,"attestation":"indirect"}', + '{"rp":{"name":"RP"},"user":{"name":"USER","id":"aWQ","displayName":"FOO BAR"},"excludeCredentials": [],"challenge":"Y2hhbGxlbmdl","pubKeyCredParams":[{"type":"type","alg":-100}],"timeout":1000,"attestation":"indirect"}', $json ); diff --git a/tests/library/Unit/SerializerTest.php b/tests/library/Unit/SerializerTest.php index bfcae69c9..f79bf02b7 100644 --- a/tests/library/Unit/SerializerTest.php +++ b/tests/library/Unit/SerializerTest.php @@ -75,6 +75,7 @@ public function theCredentialCanBeDeserialized(): void "authenticatorAttachment": "cross-platform", "userVerification": "required" }, + "excludeCredentials": [], "attestation": "none" }', $json, diff --git a/tests/symfony/functional/Attestation/AdditionalAuthenticatorTest.php b/tests/symfony/functional/Attestation/AdditionalAuthenticatorTest.php index bea5a8ec1..76b12ab5a 100644 --- a/tests/symfony/functional/Attestation/AdditionalAuthenticatorTest.php +++ b/tests/symfony/functional/Attestation/AdditionalAuthenticatorTest.php @@ -58,12 +58,13 @@ public function anExistingUserCanAskForOptionsUsingTheDedicatedController(): voi 'attestation', 'user', 'authenticatorSelection', + 'excludeCredentials', ]; foreach ($expectedKeys as $expectedKey) { static::assertArrayHasKey($expectedKey, $data); } static::assertSame('ok', $data['status']); - static::assertArrayNotHasKey('excludeCredentials', $data); // username enumeration prevention is enabled + static::assertSame($data['excludeCredentials'], []); // username enumeration prevention is enabled } #[Test]