|
45 | 45 | import org.springframework.security.web.webauthn.api.AuthenticatorAttestationResponse;
|
46 | 46 | import org.springframework.security.web.webauthn.api.AuthenticatorAttestationResponse.AuthenticatorAttestationResponseBuilder;
|
47 | 47 | import org.springframework.security.web.webauthn.api.AuthenticatorSelectionCriteria;
|
| 48 | +import org.springframework.security.web.webauthn.api.AuthenticatorTransport; |
48 | 49 | import org.springframework.security.web.webauthn.api.Bytes;
|
49 | 50 | import org.springframework.security.web.webauthn.api.CredentialRecord;
|
50 | 51 | import org.springframework.security.web.webauthn.api.PublicKeyCredential;
|
@@ -224,6 +225,47 @@ void registerCredentialWhenRpRegistrationRequestNullThenIllegalArgumentException
|
224 | 225 | assertThatIllegalArgumentException().isThrownBy(() -> this.rpOperations.registerCredential(null));
|
225 | 226 | }
|
226 | 227 |
|
| 228 | + @Test |
| 229 | + void registerCredentialWhenDefaultTransportsThenSuccess() { |
| 230 | + PublicKeyCredentialCreationOptions creationOptions = TestPublicKeyCredentialCreationOptions |
| 231 | + .createPublicKeyCredentialCreationOptions() |
| 232 | + .build(); |
| 233 | + PublicKeyCredential<AuthenticatorAttestationResponse> publicKeyCredential = TestPublicKeyCredential |
| 234 | + .createPublicKeyCredential() |
| 235 | + .build(); |
| 236 | + RelyingPartyPublicKey rpPublicKey = new RelyingPartyPublicKey(publicKeyCredential, this.label); |
| 237 | + |
| 238 | + ImmutableRelyingPartyRegistrationRequest rpRegistrationRequest = new ImmutableRelyingPartyRegistrationRequest( |
| 239 | + creationOptions, rpPublicKey); |
| 240 | + CredentialRecord credentialRecord = this.rpOperations.registerCredential(rpRegistrationRequest); |
| 241 | + assertThat(credentialRecord).isNotNull(); |
| 242 | + assertThat(credentialRecord.getCredentialId()).isNotNull(); |
| 243 | + assertThat(credentialRecord.getTransports()).containsExactlyInAnyOrder(AuthenticatorTransport.INTERNAL, |
| 244 | + AuthenticatorTransport.HYBRID); |
| 245 | + } |
| 246 | + |
| 247 | + @Test |
| 248 | + void registerCredentialWhenInternalTransportThenCredentialRecordHasTransport() { |
| 249 | + PublicKeyCredentialCreationOptions creationOptions = TestPublicKeyCredentialCreationOptions |
| 250 | + .createPublicKeyCredentialCreationOptions() |
| 251 | + .build(); |
| 252 | + AuthenticatorAttestationResponse response = TestAuthenticatorAttestationResponse |
| 253 | + .createAuthenticatorAttestationResponse() |
| 254 | + .transports(AuthenticatorTransport.INTERNAL) |
| 255 | + .build(); |
| 256 | + PublicKeyCredential<AuthenticatorAttestationResponse> publicKeyCredential = TestPublicKeyCredential |
| 257 | + .createPublicKeyCredential() |
| 258 | + .response(response) |
| 259 | + .build(); |
| 260 | + RelyingPartyPublicKey rpPublicKey = new RelyingPartyPublicKey(publicKeyCredential, this.label); |
| 261 | + |
| 262 | + ImmutableRelyingPartyRegistrationRequest rpRegistrationRequest = new ImmutableRelyingPartyRegistrationRequest( |
| 263 | + creationOptions, rpPublicKey); |
| 264 | + CredentialRecord credentialRecord = this.rpOperations.registerCredential(rpRegistrationRequest); |
| 265 | + assertThat(credentialRecord).isNotNull(); |
| 266 | + assertThat(credentialRecord.getTransports()).containsExactlyInAnyOrder(AuthenticatorTransport.INTERNAL); |
| 267 | + } |
| 268 | + |
227 | 269 | @Test
|
228 | 270 | void registerCredentialWhenExistsThenException() {
|
229 | 271 | PublicKeyCredentialCreationOptions creationOptions = TestPublicKeyCredentialCreationOptions
|
|
0 commit comments