Search in sources :

Example 1 with AbstractWebAuthnRealmUpdater

use of org.keycloak.testsuite.webauthn.updaters.AbstractWebAuthnRealmUpdater in project keycloak by keycloak.

the class AttestationConveyanceRegisterTest method assertAttestationConveyance.

protected void assertAttestationConveyance(boolean shouldSuccess, AttestationConveyancePreference attestation) {
    Credential credential = getDefaultResidentKeyCredential();
    getVirtualAuthManager().useAuthenticator(getDefaultAuthenticatorOptions().setHasResidentKey(true));
    getVirtualAuthManager().getCurrent().getAuthenticator().addCredential(credential);
    try (AbstractWebAuthnRealmUpdater updater = getWebAuthnRealmUpdater().setWebAuthnPolicyAttestationConveyancePreference(attestation.getValue()).update()) {
        WebAuthnRealmData realmData = new WebAuthnRealmData(testRealm().toRepresentation(), isPasswordless());
        assertThat(realmData.getAttestationConveyancePreference(), is(attestation.getValue()));
        registerDefaultUser(shouldSuccess);
        displayErrorMessageIfPresent();
        final boolean isErrorCurrent = webAuthnErrorPage.isCurrent();
        assertThat(isErrorCurrent, is(!shouldSuccess));
        final String credentialType = getCredentialType();
        getTestingClient().server(TEST_REALM_NAME).run(session -> {
            final WebAuthnDataWrapper dataWrapper = new WebAuthnDataWrapper(session, USERNAME, credentialType);
            assertThat(dataWrapper, notNullValue());
            final WebAuthnCredentialData data = dataWrapper.getWebAuthnData();
            assertThat(data, notNullValue());
            assertThat(data.getAttestationStatementFormat(), is(attestation.getValue()));
        });
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : WebAuthnDataWrapper(org.keycloak.testsuite.webauthn.utils.WebAuthnDataWrapper) Credential(org.openqa.selenium.virtualauthenticator.Credential) WebAuthnCredentialData(org.keycloak.models.credential.dto.WebAuthnCredentialData) AbstractWebAuthnRealmUpdater(org.keycloak.testsuite.webauthn.updaters.AbstractWebAuthnRealmUpdater) IOException(java.io.IOException) WebAuthnRealmData(org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData)

Aggregations

IOException (java.io.IOException)1 WebAuthnCredentialData (org.keycloak.models.credential.dto.WebAuthnCredentialData)1 AbstractWebAuthnRealmUpdater (org.keycloak.testsuite.webauthn.updaters.AbstractWebAuthnRealmUpdater)1 WebAuthnDataWrapper (org.keycloak.testsuite.webauthn.utils.WebAuthnDataWrapper)1 WebAuthnRealmData (org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData)1 Credential (org.openqa.selenium.virtualauthenticator.Credential)1