use of org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList 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);
}
}
use of org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList in project keycloak by keycloak.
the class WebAuthnSigningInTest method checkAuthenticatorTimeLocale.
@Test
public void checkAuthenticatorTimeLocale() throws ParseException, IOException {
addWebAuthnCredential("authenticator#1");
final int webAuthnCount = webAuthnCredentialType.getUserCredentialsCount();
assertThat(webAuthnCount, is(1));
setUpWebAuthnFlow("webAuthnFlow");
logout();
signingInPage.navigateTo();
loginToAccount();
webAuthnLoginPage.assertCurrent();
WebAuthnAuthenticatorsList authenticators = webAuthnLoginPage.getAuthenticators();
assertThat(authenticators.getCount(), is(1));
assertThat(authenticators.getLabels(), Matchers.contains("authenticator#1"));
WebAuthnAuthenticatorsList.WebAuthnAuthenticatorItem item = authenticators.getItems().get(0);
assertThat(item, notNullValue());
assertThat(item.getName(), is("authenticator#1"));
final String dateEnglishString = item.getCreatedDate();
assertThat(dateEnglishString, notNullValue());
DateFormat format = DateTimeFormatterUtil.getDefaultDateFormat(Locale.ENGLISH);
final Date dateEnglish = format.parse(dateEnglishString);
assertThat(dateEnglish, notNullValue());
webAuthnLoginPage.clickAuthenticate();
signingInPage.assertCurrent();
logout();
try (Closeable c = setLocalesUpdater(Locale.CHINA.getLanguage()).update()) {
signingInPage.navigateTo();
loginToAccount();
webAuthnLoginPage.assertCurrent();
authenticators = webAuthnLoginPage.getAuthenticators();
assertThat(authenticators.getCount(), is(1));
item = webAuthnLoginPage.getAuthenticators().getItems().get(0);
final String dateChineseString = item.getCreatedDate();
assertThat(dateChineseString, notNullValue());
format = DateTimeFormatterUtil.getDefaultDateFormat(Locale.CHINA);
final Date dateChinese = format.parse(dateChineseString);
assertThat(dateChinese, notNullValue());
assertThat(dateEnglishString, is(not(dateChineseString)));
assertThat(dateEnglish, is(dateChinese));
webAuthnLoginPage.clickAuthenticate();
signingInPage.assertCurrent();
logout();
}
try (Closeable c = setLocalesUpdater("xx", Locale.ENGLISH.getLanguage()).update()) {
signingInPage.navigateTo();
loginToAccount();
webAuthnLoginPage.assertCurrent();
authenticators = webAuthnLoginPage.getAuthenticators();
assertThat(authenticators.getCount(), is(1));
item = webAuthnLoginPage.getAuthenticators().getItems().get(0);
final String dateInvalidString = item.getCreatedDate();
assertThat(dateInvalidString, notNullValue());
assertThat(dateInvalidString, is(dateEnglishString));
}
}
use of org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList in project keycloak by keycloak.
the class WebAuthnSigningInTest method userAuthenticatorTimeLocale.
@Test
public void userAuthenticatorTimeLocale() throws IOException {
Consumer<String> checkCreatedAtLabels = (requiredLabel) -> webAuthnLoginPage.getAuthenticators().getItems().stream().map(WebAuthnAuthenticatorsList.WebAuthnAuthenticatorItem::getCreatedLabel).forEach(f -> assertThat(f, is(requiredLabel)));
try (Closeable c = setLocalesUpdater(Locale.ENGLISH.getLanguage(), "cs").update()) {
addWebAuthnCredential("authenticator#1");
addWebAuthnCredential("authenticator#2");
final int webAuthnCount = webAuthnCredentialType.getUserCredentialsCount();
assertThat(webAuthnCount, is(2));
setUpWebAuthnFlow("webAuthnFlow");
logout();
signingInPage.navigateTo();
loginToAccount();
webAuthnLoginPage.assertCurrent();
WebAuthnAuthenticatorsList authenticators = webAuthnLoginPage.getAuthenticators();
assertThat(authenticators.getCount(), is(2));
assertThat(authenticators.getLabels(), Matchers.contains("authenticator#1", "authenticator#2"));
checkCreatedAtLabels.accept("Created");
webAuthnLoginPage.openLanguage("Čeština");
checkCreatedAtLabels.accept("Vytvořeno");
webAuthnLoginPage.clickAuthenticate();
signingInPage.assertCurrent();
}
}
use of org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList in project keycloak by keycloak.
the class PolicyJsInjectionTest method injectUserLabel.
@Test
public void injectUserLabel() {
final String originalLabel = "label'`;window.prompt(\"another\");'";
registerDefaultUser(originalLabel);
appPage.assertCurrent();
final CredentialRepresentation credential = userResource().credentials().stream().filter(f -> f.getType().equals(getCredentialType())).findFirst().orElse(null);
assertThat(credential, notNullValue());
assertThat(credential.getUserLabel(), is(originalLabel));
if (!isPasswordless()) {
logout();
loginPage.open();
loginPage.assertCurrent(TEST_REALM_NAME);
loginPage.login(USERNAME, PASSWORD);
webAuthnLoginPage.assertCurrent();
WebAuthnAuthenticatorsList authenticators = webAuthnLoginPage.getAuthenticators();
assertThat(authenticators, notNullValue());
assertThat(authenticators.getItems(), not(Matchers.empty()));
assertThat(authenticators.getLabels().get(0), is("label`;window.prompt(\"another\");"));
}
}
use of org.keycloak.testsuite.webauthn.pages.WebAuthnAuthenticatorsList in project keycloak by keycloak.
the class WebAuthnSigningInTest method displayAvailableAuthenticators.
@Test
public void displayAvailableAuthenticators() {
addWebAuthnCredential("authenticator#1");
addWebAuthnCredential("authenticator#2");
final int webAuthnCount = webAuthnCredentialType.getUserCredentialsCount();
assertThat(webAuthnCount, is(2));
setUpWebAuthnFlow("webAuthnFlow");
logout();
signingInPage.navigateTo();
loginToAccount();
webAuthnLoginPage.assertCurrent();
WebAuthnAuthenticatorsList authenticators = webAuthnLoginPage.getAuthenticators();
assertThat(authenticators.getCount(), is(2));
assertThat(authenticators.getLabels(), Matchers.contains("authenticator#1", "authenticator#2"));
webAuthnLoginPage.clickAuthenticate();
signingInPage.assertCurrent();
}
Aggregations