use of org.keycloak.testsuite.arquillian.annotation.IgnoreBrowserDriver in project keycloak by keycloak.
the class WebAuthnPropertyTest method changeAuthenticatorProperties.
@Test
@IgnoreBrowserDriver(FirefoxDriver.class)
public void changeAuthenticatorProperties() throws IOException {
getVirtualAuthManager().useAuthenticator(DEFAULT_RESIDENT_KEY.getOptions());
try (Closeable c = getWebAuthnRealmUpdater().setWebAuthnPolicyRpEntityName("localhost").setWebAuthnPolicyRequireResidentKey(YES.getValue()).setWebAuthnPolicyUserVerificationRequirement(OPTION_REQUIRED).update()) {
WebAuthnRealmData realmData = new WebAuthnRealmData(testRealm().toRepresentation(), isPasswordless());
assertThat(realmData, notNullValue());
assertThat(realmData.getRpEntityName(), is("localhost"));
assertThat(realmData.getRequireResidentKey(), is(YES.getValue()));
assertThat(realmData.getUserVerificationRequirement(), is(OPTION_REQUIRED));
registerDefaultUser();
logout();
getVirtualAuthManager().useAuthenticator(DEFAULT.getOptions());
WaitUtils.pause(500);
authenticateDefaultUser(false);
webAuthnErrorPage.assertCurrent();
}
}
use of org.keycloak.testsuite.arquillian.annotation.IgnoreBrowserDriver 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."));
}
}
use of org.keycloak.testsuite.arquillian.annotation.IgnoreBrowserDriver in project keycloak by keycloak.
the class WebAuthnOtherSettingsTest method timeout.
@Test
@IgnoreBrowserDriver(FirefoxDriver.class)
public void timeout() throws IOException {
// seconds
final Integer TIMEOUT = 3;
getVirtualAuthManager().removeAuthenticator();
try (Closeable u = getWebAuthnRealmUpdater().setWebAuthnPolicyCreateTimeout(TIMEOUT).update()) {
WebAuthnRealmData realmData = new WebAuthnRealmData(testRealm().toRepresentation(), isPasswordless());
assertThat(realmData.getCreateTimeout(), is(TIMEOUT));
loginPage.open();
loginPage.clickRegister();
registerPage.assertCurrent();
registerPage.register("firstName", "lastName", EMAIL, USERNAME, PASSWORD, PASSWORD);
// User was registered. Now he needs to register WebAuthn credential
webAuthnRegisterPage.assertCurrent();
webAuthnRegisterPage.clickRegister();
pause((TIMEOUT + 2) * 1000);
webAuthnErrorPage.assertCurrent();
assertThat(webAuthnErrorPage.getError(), containsString("The operation either timed out or was not allowed"));
webAuthnErrorPage.clickTryAgain();
waitForPageToLoad();
webAuthnRegisterPage.assertCurrent();
webAuthnRegisterPage.clickRegister();
assertThat(webAuthnErrorPage.isCurrent(), is(false));
}
}
use of org.keycloak.testsuite.arquillian.annotation.IgnoreBrowserDriver in project keycloak by keycloak.
the class BrowserDriverIgnoreDecider method decideIgnoring.
private ExecutionDecision decideIgnoring(AnnotatedElement element) {
final WebDriver webDriver = driver.get();
Predicate<IgnoreBrowserDriver> shouldBeIgnored = (item) -> {
return webDriver != null && (isDriverInstanceOf(webDriver, item.value()) ^ item.negate());
};
return Arrays.stream(element.getAnnotationsByType(IgnoreBrowserDriver.class)).filter(shouldBeIgnored).findAny().map(f -> ExecutionDecision.dontExecute("This test should not be executed with this browser.")).orElse(ExecutionDecision.execute());
}
use of org.keycloak.testsuite.arquillian.annotation.IgnoreBrowserDriver in project keycloak by keycloak.
the class WebAuthnPropertyTest method residentKey.
@Test
@IgnoreBrowserDriver(FirefoxDriver.class)
public void residentKey() throws IOException {
getVirtualAuthManager().useAuthenticator(DEFAULT_RESIDENT_KEY.getOptions());
try (Closeable c = getWebAuthnRealmUpdater().setWebAuthnPolicyRpEntityName("localhost").setWebAuthnPolicyRequireResidentKey(YES.getValue()).setWebAuthnPolicyUserVerificationRequirement(OPTION_REQUIRED).update()) {
WebAuthnRealmData realmData = new WebAuthnRealmData(testRealm().toRepresentation(), isPasswordless());
assertThat(realmData, notNullValue());
assertThat(realmData.getRpEntityName(), is("localhost"));
assertThat(realmData.getRequireResidentKey(), is(YES.getValue()));
assertThat(realmData.getUserVerificationRequirement(), is(OPTION_REQUIRED));
registerDefaultUser();
UserRepresentation user = userResource().toRepresentation();
assertThat(user, notNullValue());
logout();
events.clear();
authenticateDefaultUser();
// confirm that authentication is successfully completed
events.expectLogin().user(user.getId()).detail(WebAuthnConstants.USER_VERIFICATION_CHECKED, "true").assertEvent();
}
}
Aggregations