Search in sources :

Example 1 with VirtualAuthenticatorOptions

use of org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions in project keycloak by keycloak.

the class WebAuthnTransportLocaleTest method assertLocalizationIndividual.

private void assertLocalizationIndividual(VirtualAuthenticatorOptions options, String originalName, String localizedText) {
    final Consumer<String> checkTransportName = (requiredName) -> {
        WebAuthnAuthenticatorsList authenticators = webAuthnLoginPage.getAuthenticators();
        assertThat(authenticators, notNullValue());
        assertThat(authenticators.getCount(), is(1));
        assertThat(authenticators.getLabels(), Matchers.contains("authenticator#1"));
        List<WebAuthnAuthenticatorsList.WebAuthnAuthenticatorItem> items = authenticators.getItems();
        assertThat(items, notNullValue());
        assertThat(items.size(), is(1));
        WebAuthnAuthenticatorsList.WebAuthnAuthenticatorItem item = items.get(0);
        assertThat(item, notNullValue());
        assertThat(item.getTransport(), is(requiredName));
    };
    try (Closeable c = setLocalesUpdater(Locale.ENGLISH.getLanguage(), "cs").update()) {
        getWebAuthnManager().useAuthenticator(options);
        addWebAuthnCredential("authenticator#1");
        final int webAuthnCount = webAuthnCredentialType.getUserCredentialsCount();
        assertThat(webAuthnCount, is(1));
        setUpWebAuthnFlow("webAuthnFlow");
        logout();
        signingInPage.navigateTo();
        loginToAccount();
        webAuthnLoginPage.assertCurrent();
        checkTransportName.accept(originalName);
        webAuthnLoginPage.openLanguage("Čeština");
        checkTransportName.accept(localizedText);
        webAuthnLoginPage.clickAuthenticate();
        signingInPage.assertCurrent();
    } catch (IOException e) {
        throw new RuntimeException("Cannot update locale.", e);
    }
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) WebAuthnAuthenticatorsList(org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList) DEFAULT_BLE(org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions.DEFAULT_BLE) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) IgnoreBrowserDriver(org.keycloak.testsuite.arquillian.annotation.IgnoreBrowserDriver) IOException(java.io.IOException) Supplier(java.util.function.Supplier) DEFAULT(org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions.DEFAULT) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) Consumer(java.util.function.Consumer) FirefoxDriver(org.openqa.selenium.firefox.FirefoxDriver) List(java.util.List) DEFAULT_NFC(org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions.DEFAULT_NFC) DefaultVirtualAuthOptions(org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions) Locale(java.util.Locale) DEFAULT_INTERNAL(org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions.DEFAULT_INTERNAL) VirtualAuthenticatorOptions(org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions) Closeable(java.io.Closeable) BiConsumer(java.util.function.BiConsumer) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DEFAULT_USB(org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions.DEFAULT_USB) WebAuthnAuthenticatorsList(org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList) Closeable(java.io.Closeable) WebAuthnAuthenticatorsList(org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList) List(java.util.List) IOException(java.io.IOException)

Example 2 with VirtualAuthenticatorOptions

use of org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions in project keycloak by keycloak.

the class UserVerificationRegisterTest method assertUserVerification.

private void assertUserVerification(boolean shouldSuccess, UserVerificationRequirement requirement, Consumer<VirtualAuthenticatorOptions> authenticator) {
    VirtualAuthenticatorOptions options = getDefaultAuthenticatorOptions();
    authenticator.accept(options);
    getVirtualAuthManager().useAuthenticator(options);
    WaitUtils.pause(200);
    try (Closeable u = getWebAuthnRealmUpdater().setWebAuthnPolicyUserVerificationRequirement(requirement.getValue()).update()) {
        WebAuthnRealmData realmData = new WebAuthnRealmData(testRealm().toRepresentation(), isPasswordless());
        assertThat(realmData.getUserVerificationRequirement(), containsString(requirement.getValue()));
        registerDefaultUser(shouldSuccess);
        displayErrorMessageIfPresent();
        assertThat(webAuthnErrorPage.isCurrent(), is(!shouldSuccess));
    } catch (IOException e) {
        throw new RuntimeException(e.getCause());
    }
}
Also used : Closeable(java.io.Closeable) IOException(java.io.IOException) VirtualAuthenticatorOptions(org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions) WebAuthnRealmData(org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData)

Example 3 with VirtualAuthenticatorOptions

use of org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions in project keycloak by keycloak.

the class VirtualAuthenticatorsManagerTest method singleResponsibleAuthOptions.

@Test
public void singleResponsibleAuthOptions() {
    VirtualAuthenticatorOptions options = DefaultVirtualAuthOptions.DEFAULT_BLE.getOptions();
    options.setTransport(VirtualAuthenticatorOptions.Transport.NFC);
    final VirtualAuthenticatorManager manager = new VirtualAuthenticatorManager(driver);
    assertThat(manager, notNullValue());
    manager.useAuthenticator(options);
    assertThat(manager.getCurrent().getOptions().getTransport(), is(VirtualAuthenticatorOptions.Transport.NFC));
    options = DefaultVirtualAuthOptions.DEFAULT_BLE.getOptions();
    manager.useAuthenticator(options);
    assertThat(manager.getCurrent().getOptions().getTransport(), is(VirtualAuthenticatorOptions.Transport.BLE));
}
Also used : VirtualAuthenticatorManager(org.keycloak.testsuite.webauthn.authenticators.VirtualAuthenticatorManager) VirtualAuthenticatorOptions(org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions) Test(org.junit.Test)

Example 4 with VirtualAuthenticatorOptions

use of org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions in project keycloak by keycloak.

the class VirtualAuthenticatorsManagerTest method overrideUsedAuthenticator.

@Test
public void overrideUsedAuthenticator() {
    final VirtualAuthenticatorManager manager = new VirtualAuthenticatorManager(driver);
    assertThat(manager, notNullValue());
    KcVirtualAuthenticator defaultTesting = useDefaultTestingAuthenticator(manager);
    assertAuthenticatorOptions(defaultTesting);
    assertThat(manager.getCurrent(), is(defaultTesting));
    VirtualAuthenticatorOptions defaultBleOptions = DefaultVirtualAuthOptions.DEFAULT_BLE.getOptions();
    assertThat(defaultBleOptions, notNullValue());
    KcVirtualAuthenticator defaultBLE = manager.useAuthenticator(defaultBleOptions);
    assertThat(defaultBLE, notNullValue());
    assertAuthenticatorOptions(defaultTesting);
    assertThat(manager.getCurrent(), is(defaultBLE));
    assertThat(manager.getCurrent().getOptions().clone(), is(defaultBleOptions));
}
Also used : KcVirtualAuthenticator(org.keycloak.testsuite.webauthn.authenticators.KcVirtualAuthenticator) VirtualAuthenticatorManager(org.keycloak.testsuite.webauthn.authenticators.VirtualAuthenticatorManager) VirtualAuthenticatorOptions(org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions) Test(org.junit.Test)

Aggregations

VirtualAuthenticatorOptions (org.openqa.selenium.virtualauthenticator.VirtualAuthenticatorOptions)4 Test (org.junit.Test)3 Closeable (java.io.Closeable)2 IOException (java.io.IOException)2 VirtualAuthenticatorManager (org.keycloak.testsuite.webauthn.authenticators.VirtualAuthenticatorManager)2 List (java.util.List)1 Locale (java.util.Locale)1 BiConsumer (java.util.function.BiConsumer)1 Consumer (java.util.function.Consumer)1 Supplier (java.util.function.Supplier)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1 CoreMatchers.notNullValue (org.hamcrest.CoreMatchers.notNullValue)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers (org.hamcrest.Matchers)1 IgnoreBrowserDriver (org.keycloak.testsuite.arquillian.annotation.IgnoreBrowserDriver)1 DefaultVirtualAuthOptions (org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions)1 DEFAULT (org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions.DEFAULT)1 DEFAULT_BLE (org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions.DEFAULT_BLE)1 DEFAULT_INTERNAL (org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions.DEFAULT_INTERNAL)1 DEFAULT_NFC (org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions.DEFAULT_NFC)1