Search in sources :

Example 1 with DEFAULT_INTERNAL

use of org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions.DEFAULT_INTERNAL in project keycloak by keycloak.

the class WebAuthnTransportLocaleTest method multipleTransports.

@Test
public void multipleTransports() throws IOException {
    final String AUTHENTICATOR_LABEL = "authenticator#";
    final Integer EXPECTED_COUNT = 5;
    final BiConsumer<DefaultVirtualAuthOptions, Integer> addAndVerifyAuthenticator = (options, number) -> {
        getWebAuthnManager().useAuthenticator(options.getOptions());
        addWebAuthnCredential(AUTHENTICATOR_LABEL + number);
        int webAuthnCount = webAuthnCredentialType.getUserCredentialsCount();
        assertThat(webAuthnCount, is(number));
    };
    addAndVerifyAuthenticator.accept(DEFAULT_INTERNAL, 1);
    addAndVerifyAuthenticator.accept(DEFAULT_BLE, 2);
    addAndVerifyAuthenticator.accept(DEFAULT_NFC, 3);
    addAndVerifyAuthenticator.accept(DEFAULT_USB, 4);
    addAndVerifyAuthenticator.accept(DEFAULT, 5);
    setUpWebAuthnFlow("webAuthnFlow");
    logout();
    signingInPage.navigateTo();
    loginToAccount();
    webAuthnLoginPage.assertCurrent();
    final Supplier<List<WebAuthnAuthenticatorsList.WebAuthnAuthenticatorItem>> getItems = () -> {
        final WebAuthnAuthenticatorsList authenticators = webAuthnLoginPage.getAuthenticators();
        assertThat(authenticators, notNullValue());
        assertThat(authenticators.getCount(), is(EXPECTED_COUNT));
        final List<WebAuthnAuthenticatorsList.WebAuthnAuthenticatorItem> list = authenticators.getItems();
        assertThat(list, notNullValue());
        assertThat(list.size(), is(EXPECTED_COUNT));
        return list;
    };
    final BiConsumer<String, Integer> assertAuthenticatorTransport = (transport, number) -> {
        List<WebAuthnAuthenticatorsList.WebAuthnAuthenticatorItem> list = getItems.get();
        assertThat(list, notNullValue());
        WebAuthnAuthenticatorsList.WebAuthnAuthenticatorItem item = list.get(number - 1);
        assertThat(item, notNullValue());
        assertThat(item.getName(), is(AUTHENTICATOR_LABEL + number));
        assertThat(item.getTransport(), is(transport));
    };
    assertAuthenticatorTransport.accept("Internal", 1);
    assertAuthenticatorTransport.accept("Bluetooth", 2);
    assertAuthenticatorTransport.accept("NFC", 3);
    assertAuthenticatorTransport.accept("USB", 4);
    assertAuthenticatorTransport.accept("USB", 5);
    webAuthnLoginPage.assertCurrent();
    webAuthnLoginPage.clickAuthenticate();
    logout();
    signingInPage.navigateTo();
    loginToAccount();
    webAuthnLoginPage.assertCurrent();
    try (Closeable c = setLocalesUpdater(Locale.ENGLISH.getLanguage(), "cs").update()) {
        driver.navigate().refresh();
        webAuthnLoginPage.openLanguage("Čeština");
        assertAuthenticatorTransport.accept("Interní", 1);
        assertAuthenticatorTransport.accept("Bluetooth", 2);
        assertAuthenticatorTransport.accept("NFC", 3);
        assertAuthenticatorTransport.accept("USB", 4);
        assertAuthenticatorTransport.accept("USB", 5);
    }
}
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) DefaultVirtualAuthOptions(org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions) WebAuthnAuthenticatorsList(org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList) List(java.util.List) Test(org.junit.Test)

Aggregations

Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 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 Test (org.junit.Test)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 DEFAULT_USB (org.keycloak.testsuite.webauthn.authenticators.DefaultVirtualAuthOptions.DEFAULT_USB)1 WebAuthnAuthenticatorsList (org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList)1