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."));
}
}
Aggregations