use of org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList 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);
}
}
Aggregations