use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class AuthAttachmentRegisterTest method assertAuthenticatorAttachment.
private void assertAuthenticatorAttachment(boolean shouldSuccess, AuthenticatorAttachment attachment) {
try (Closeable u = getWebAuthnRealmUpdater().setWebAuthnPolicyAuthenticatorAttachment(attachment.getValue()).update()) {
WebAuthnRealmData realmData = new WebAuthnRealmData(testRealm().toRepresentation(), isPasswordless());
assertThat(realmData.getAuthenticatorAttachment(), is(attachment.getValue()));
registerDefaultUser(shouldSuccess);
displayErrorMessageIfPresent();
assertThat(webAuthnErrorPage.isCurrent(), is(!shouldSuccess));
} catch (IOException e) {
throw new RuntimeException(e.getCause());
}
}
use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class PubKeySignRegisterTest method assertPublicKeyAlgorithms.
private void assertPublicKeyAlgorithms(boolean shouldSuccess, COSEAlgorithmIdentifier selectedAlgorithm, List<String> algorithms) {
assertThat(algorithms, notNullValue());
try (Closeable u = getWebAuthnRealmUpdater().setWebAuthnPolicySignatureAlgorithms(algorithms).update()) {
if (!algorithms.isEmpty()) {
WebAuthnRealmData realmData = new WebAuthnRealmData(testRealm().toRepresentation(), isPasswordless());
assertThat(realmData.getSignatureAlgorithms(), is(algorithms));
}
registerDefaultUser(shouldSuccess);
assertThat(webAuthnErrorPage.isCurrent(), is(!shouldSuccess));
if (!shouldSuccess) {
final String expectedMessage = getExpectedMessageByDriver("NotSupportedError: Operation is not supported", "The operation either timed out or was not allowed");
assertThat(webAuthnErrorPage.getError(), containsString(expectedMessage));
return;
}
final String credentialType = getCredentialType();
getTestingClient().server(TEST_REALM_NAME).run(session -> {
final WebAuthnDataWrapper dataWrapper = new WebAuthnDataWrapper(session, USERNAME, credentialType);
assertThat(dataWrapper, notNullValue());
final WebAuthnCredentialData data = dataWrapper.getWebAuthnData();
assertThat(data, notNullValue());
final COSEKey pubKey = dataWrapper.getKey();
assertThat(pubKey, notNullValue());
assertThat(pubKey.getAlgorithm(), notNullValue());
assertThat(pubKey.getAlgorithm().getValue(), is(selectedAlgorithm.getValue()));
assertThat(pubKey.hasPublicKey(), is(true));
});
} catch (IOException e) {
throw new RuntimeException(e.getCause());
}
}
use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData 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();
}
}
use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class WebAuthnPropertyTest method timeout.
@Test
@IgnoreBrowserDriver(FirefoxDriver.class)
public void timeout() throws IOException {
// seconds
final Integer TIMEOUT = 3;
registerDefaultUser();
logout();
getVirtualAuthManager().removeAuthenticator();
try (Closeable u = getWebAuthnRealmUpdater().setWebAuthnPolicyCreateTimeout(TIMEOUT).update()) {
WebAuthnRealmData realmData = new WebAuthnRealmData(testRealm().toRepresentation(), isPasswordless());
assertThat(realmData.getCreateTimeout(), is(TIMEOUT));
authenticateDefaultUser(false);
WaitUtils.pause((TIMEOUT + 2) * 1000);
webAuthnErrorPage.assertCurrent();
assertThat(webAuthnErrorPage.getError(), containsString("Failed to authenticate by the Security key."));
}
}
use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class WebAuthnPolicySettingsTest method rpEntityValues.
@Test
public void rpEntityValues() {
String rpEntityName = getPolicyPage().getRpEntityName();
assertThat(rpEntityName, notNullValue());
assertThat(rpEntityName, is(Constants.DEFAULT_WEBAUTHN_POLICY_RP_ENTITY_NAME));
getPolicyPage().setRpEntityName("newEntityName");
getPolicyPage().clickSaveButton();
AbstractPatternFlyAlert.waitUntilHidden();
rpEntityName = getPolicyPage().getRpEntityName();
assertThat(rpEntityName, notNullValue());
assertThat(rpEntityName, is("newEntityName"));
getPolicyPage().setRpEntityName("");
getPolicyPage().clickSaveButton();
AbstractPatternFlyAlert.waitUntilHidden();
rpEntityName = getPolicyPage().getRpEntityName();
assertThat(rpEntityName, notNullValue());
assertThat(rpEntityName, is(Constants.DEFAULT_WEBAUTHN_POLICY_RP_ENTITY_NAME));
String rpEntityId = getPolicyPage().getRpEntityId();
assertThat(rpEntityId, notNullValue());
assertThat(rpEntityId, is(""));
getPolicyPage().setRpEntityId("rpId123");
getPolicyPage().clickSaveButton();
AbstractPatternFlyAlert.waitUntilHidden();
rpEntityId = getPolicyPage().getRpEntityId();
assertThat(rpEntityId, notNullValue());
assertThat(rpEntityId, is("rpId123"));
final WebAuthnRealmData realm = new WebAuthnRealmData(testRealmResource().toRepresentation(), isPasswordless());
assertThat(realm, notNullValue());
assertThat(realm.getRpEntityName(), is(Constants.DEFAULT_WEBAUTHN_POLICY_RP_ENTITY_NAME));
assertThat(realm.getRpId(), is("rpId123"));
}
Aggregations