use of com.webauthn4j.WebAuthnManager in project webauthn4j by webauthn4j.
the class FIDOU2FAuthenticatorRegistrationValidationTest method validate_with_bad_attestationStatement_test.
@Test
void validate_with_bad_attestationStatement_test() {
String rpId = "example.com";
Challenge challenge = new DefaultChallenge();
PublicKeyCredentialParameters publicKeyCredentialParameters = new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256);
PublicKeyCredentialCreationOptions credentialCreationOptions = new PublicKeyCredentialCreationOptions(new PublicKeyCredentialRpEntity(rpId, "example.com"), new PublicKeyCredentialUserEntity(new byte[32], "username", "displayName"), challenge, Collections.singletonList(publicKeyCredentialParameters));
AuthenticatorAttestationResponse authenticatorAttestationResponse = clientPlatform.create(credentialCreationOptions).getAuthenticatorResponse();
Set<String> transports = authenticatorTransportConverter.convertSetToStringSet(authenticatorAttestationResponse.getTransports());
ServerProperty serverProperty = new ServerProperty(origin, rpId, challenge, null);
RegistrationRequest registrationRequest = new RegistrationRequest(authenticatorAttestationResponse.getAttestationObject(), authenticatorAttestationResponse.getClientDataJSON(), transports);
RegistrationParameters registrationParameters = new RegistrationParameters(serverProperty, null, false, true);
WebAuthnManager target = new WebAuthnManager(Collections.singletonList(fidoU2FAttestationStatementValidator), new TrustAnchorCertPathTrustworthinessValidator(mock(TrustAnchorsResolver.class)), new DefaultSelfAttestationTrustworthinessValidator());
assertThrows(BadAttestationStatementException.class, () -> target.validate(registrationRequest, registrationParameters));
}
Aggregations