@@ -53,81 +53,86 @@ class RelyingPartyCeremoniesSpec
53
53
.credentialRepository(credentialRepo)
54
54
.build()
55
55
56
- testWithEachProvider { it =>
57
- describe(" The default RelyingParty settings" ) {
56
+ private def createCheck (
57
+ modRp : RelyingParty => RelyingParty = identity
58
+ )(testData : RealExamples .Example ): Unit = {
59
+ val registrationRp =
60
+ modRp(newRp(testData, Helpers .CredentialRepository .empty))
58
61
59
- describe(" can register and then authenticate" ) {
60
- def check (testData : RealExamples .Example ): Unit = {
61
- val registrationRp =
62
- newRp(testData, Helpers .CredentialRepository .empty)
63
-
64
- val registrationResult = registrationRp.finishRegistration(
65
- FinishRegistrationOptions
66
- .builder()
67
- .request(
68
- PublicKeyCredentialCreationOptions
69
- .builder()
70
- .rp(testData.rp)
71
- .user(testData.user)
72
- .challenge(testData.attestation.challenge)
73
- .pubKeyCredParams(
74
- List (PublicKeyCredentialParameters .ES256 ).asJava
75
- )
76
- .build()
77
- )
78
- .response(testData.attestation.credential)
79
- .build()
80
- );
81
-
82
- registrationResult.getKeyId.getId should equal(
83
- testData.attestation.credential.getId
84
- )
85
- registrationResult.isAttestationTrusted should be(false )
86
- registrationResult.getAttestationMetadata.isPresent should be(false )
87
-
88
- val assertionRp = newRp(
89
- testData,
90
- Helpers .CredentialRepository .withUser(
91
- testData.user,
92
- Helpers .toRegisteredCredential(testData.user, registrationResult),
93
- ),
94
- )
95
-
96
- val assertionResult = assertionRp.finishAssertion(
97
- FinishAssertionOptions
98
- .builder()
99
- .request(
100
- AssertionRequest
101
- .builder()
102
- .publicKeyCredentialRequestOptions(
103
- PublicKeyCredentialRequestOptions
62
+ val registrationResult = registrationRp.finishRegistration(
63
+ FinishRegistrationOptions
64
+ .builder()
65
+ .request(
66
+ PublicKeyCredentialCreationOptions
67
+ .builder()
68
+ .rp(testData.rp)
69
+ .user(testData.user)
70
+ .challenge(testData.attestation.challenge)
71
+ .pubKeyCredParams(
72
+ List (PublicKeyCredentialParameters .ES256 ).asJava
73
+ )
74
+ .build()
75
+ )
76
+ .response(testData.attestation.credential)
77
+ .build()
78
+ );
79
+
80
+ registrationResult.getKeyId.getId should equal(
81
+ testData.attestation.credential.getId
82
+ )
83
+ registrationResult.isAttestationTrusted should be(false )
84
+ registrationResult.getAttestationMetadata.isPresent should be(false )
85
+
86
+ val assertionRp = newRp(
87
+ testData,
88
+ Helpers .CredentialRepository .withUser(
89
+ testData.user,
90
+ Helpers .toRegisteredCredential(testData.user, registrationResult),
91
+ ),
92
+ ).toBuilder
93
+ .allowUnrequestedExtensions(true )
94
+ .build()
95
+
96
+ val assertionResult = assertionRp.finishAssertion(
97
+ FinishAssertionOptions
98
+ .builder()
99
+ .request(
100
+ AssertionRequest
101
+ .builder()
102
+ .publicKeyCredentialRequestOptions(
103
+ PublicKeyCredentialRequestOptions
104
+ .builder()
105
+ .challenge(testData.assertion.challenge)
106
+ .allowCredentials(
107
+ List (
108
+ PublicKeyCredentialDescriptor
104
109
.builder()
105
- .challenge(testData.assertion.challenge)
106
- .allowCredentials(
107
- List (
108
- PublicKeyCredentialDescriptor
109
- .builder()
110
- .id(testData.assertion.id)
111
- .build()
112
- ).asJava
113
- )
110
+ .id(testData.assertion.id)
114
111
.build()
115
- )
116
- .username(testData.user.getName)
117
- .build()
118
- )
119
- .response(testData.assertion.credential)
120
- .build()
121
- )
122
-
123
- assertionResult.isSuccess should be(true )
124
- assertionResult.getCredentialId should equal(testData.assertion.id)
125
- assertionResult.getUserHandle should equal(testData.user.getId)
126
- assertionResult.getUsername should equal(testData.user.getName)
127
- assertionResult.getSignatureCount should be >= testData.attestation.authenticatorData.getSignatureCounter
128
- assertionResult.isSignatureCounterValid should be(true )
129
- }
112
+ ).asJava
113
+ )
114
+ .build()
115
+ )
116
+ .username(testData.user.getName)
117
+ .build()
118
+ )
119
+ .response(testData.assertion.credential)
120
+ .build()
121
+ )
122
+
123
+ assertionResult.isSuccess should be(true )
124
+ assertionResult.getCredentialId should equal(testData.assertion.id)
125
+ assertionResult.getUserHandle should equal(testData.user.getId)
126
+ assertionResult.getUsername should equal(testData.user.getName)
127
+ assertionResult.getSignatureCount should be >= testData.attestation.authenticatorData.getSignatureCounter
128
+ assertionResult.isSignatureCounterValid should be(true )
129
+ }
130
+
131
+ testWithEachProvider { it =>
132
+ describe(" The default RelyingParty settings" ) {
133
+ val check = createCheck()(_)
130
134
135
+ describe(" can register and then authenticate" ) {
131
136
it(" a YubiKey NEO." ) {
132
137
check(RealExamples .YubiKeyNeo )
133
138
}
@@ -161,9 +166,11 @@ class RelyingPartyCeremoniesSpec
161
166
it(" a Security Key NFC by Yubico." ) {
162
167
check(RealExamples .SecurityKeyNfc )
163
168
}
164
- it(" a YubiKey 5 NFC FIPS." ) {
169
+
170
+ ignore(" a YubiKey 5 NFC FIPS." ) { // TODO Un-ignore when allowUnrequestedExtensions default changes to true
165
171
check(RealExamples .YubikeyFips5Nfc )
166
172
}
173
+
167
174
it(" a YubiKey 5Ci FIPS." ) {
168
175
check(RealExamples .Yubikey5ciFips )
169
176
}
@@ -176,5 +183,18 @@ class RelyingPartyCeremoniesSpec
176
183
}
177
184
}
178
185
}
186
+
187
+ describe(" The default RelyingParty settings, but with allowUnrequestedExtensions(true)" ) {
188
+
189
+ describe(" can register and then authenticate" ) {
190
+ val check = createCheck(rp =>
191
+ rp.toBuilder.allowUnrequestedExtensions(true ).build()
192
+ )(_)
193
+
194
+ it(" a YubiKey 5 NFC FIPS." ) { // TODO Delete when allowUnrequestedExtensions default changes to true
195
+ check(RealExamples .YubikeyFips5Nfc )
196
+ }
197
+ }
198
+ }
179
199
}
180
200
}
0 commit comments