Search in sources :

Example 1 with WebAuthnRealmAttributeUpdater

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

the class WebAuthnErrorTest method errorPageWithTimeout.

@Test
@IgnoreBrowserDriver(FirefoxDriver.class)
public void errorPageWithTimeout() throws IOException {
    final int timeoutSec = 3;
    final String authenticatorLabel = "authenticator";
    addWebAuthnCredential(authenticatorLabel);
    try (RealmAttributeUpdater u = new WebAuthnRealmAttributeUpdater(testRealmResource()).setWebAuthnPolicyCreateTimeout(timeoutSec).update()) {
        RealmRepresentation realm = testRealmResource().toRepresentation();
        assertThat(realm, notNullValue());
        assertThat(realm.getWebAuthnPolicyCreateTimeout(), is(timeoutSec));
        final int webAuthnCount = webAuthnCredentialType.getUserCredentialsCount();
        assertThat(webAuthnCount, is(1));
        getWebAuthnManager().getCurrent().getAuthenticator().removeAllCredentials();
        setUpWebAuthnFlow("webAuthnFlow");
        logout();
        signingInPage.navigateTo();
        loginToAccount();
        webAuthnLoginPage.assertCurrent();
        final WebAuthnAuthenticatorsList authenticators = webAuthnLoginPage.getAuthenticators();
        assertThat(authenticators.getCount(), is(1));
        assertThat(authenticators.getLabels(), Matchers.contains(authenticatorLabel));
        webAuthnLoginPage.clickAuthenticate();
        // Should fail after this time
        WaitUtils.pause((timeoutSec + 1) * 1000);
        webAuthnErrorPage.assertCurrent();
        assertThat(webAuthnErrorPage.getError(), is("Failed to authenticate by the Security key."));
    }
}
Also used : WebAuthnAuthenticatorsList(org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList) WebAuthnRealmAttributeUpdater(org.keycloak.testsuite.webauthn.updaters.WebAuthnRealmAttributeUpdater) RealmRepresentation(org.keycloak.representations.idm.RealmRepresentation) WebAuthnRealmAttributeUpdater(org.keycloak.testsuite.webauthn.updaters.WebAuthnRealmAttributeUpdater) RealmAttributeUpdater(org.keycloak.testsuite.updaters.RealmAttributeUpdater) Test(org.junit.Test) IgnoreBrowserDriver(org.keycloak.testsuite.arquillian.annotation.IgnoreBrowserDriver)

Aggregations

Test (org.junit.Test)1 RealmRepresentation (org.keycloak.representations.idm.RealmRepresentation)1 IgnoreBrowserDriver (org.keycloak.testsuite.arquillian.annotation.IgnoreBrowserDriver)1 RealmAttributeUpdater (org.keycloak.testsuite.updaters.RealmAttributeUpdater)1 WebAuthnAuthenticatorsList (org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList)1 WebAuthnRealmAttributeUpdater (org.keycloak.testsuite.webauthn.updaters.WebAuthnRealmAttributeUpdater)1