use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class WebAuthnPropertyTest method changeAuthenticatorProperties.
@Test
@IgnoreBrowserDriver(FirefoxDriver.class)
public void changeAuthenticatorProperties() 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();
logout();
getVirtualAuthManager().useAuthenticator(DEFAULT.getOptions());
WaitUtils.pause(500);
authenticateDefaultUser(false);
webAuthnErrorPage.assertCurrent();
}
}
use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class WebAuthnPolicySettingsTest method policySettingsWithExternalProperties.
@Test
public void policySettingsWithExternalProperties() throws IOException {
try (RealmAttributeUpdater rau = updateWebAuthnPolicy("rpName", Collections.singletonList("ES256"), INDIRECT.getValue(), CROSS_PLATFORM.getValue(), "No", null, PREFERRED.getValue(), Collections.singletonList(ALL_ZERO_AAGUID))) {
WebAuthnRealmData realm = new WebAuthnRealmData(testRealmResource().toRepresentation(), isPasswordless());
assertThat(realm, notNullValue());
assertThat(realm.getSignatureAlgorithms(), hasItems("ES256"));
assertThat(realm.getAttestationConveyancePreference(), is(INDIRECT.getValue()));
assertThat(realm.getAuthenticatorAttachment(), is(CROSS_PLATFORM.getValue()));
assertThat(realm.getRequireResidentKey(), is("No"));
assertThat(realm.getRpId(), is(""));
assertThat(realm.getUserVerificationRequirement(), is(PREFERRED.getValue()));
assertThat(realm.getAcceptableAaguids(), hasItems(ALL_ZERO_AAGUID));
}
}
use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class WebAuthnPolicySettingsTest method assertDataAfterModification.
/**
* Assert WebAuthn Realm data before and after modification
*
* @param actualValue actual value before modification
* @param expectedValue expected value after modification
* @param getCurrentValue get updated value
* @param setData exact approach, how to change the realm data
*/
private <T> void assertDataAfterModification(T actualValue, T expectedValue, Function<WebAuthnRealmData, T> getCurrentValue, Consumer<WebAuthnRealmData.Builder> setData) {
WebAuthnRealmData realm = new WebAuthnRealmData(testRealmResource().toRepresentation(), isPasswordless());
assertThat(realm, notNullValue());
assertThat(getCurrentValue.apply(realm), is(actualValue));
WebAuthnRealmData.Builder builder = realm.builder();
assertThat(builder, notNullValue());
setData.accept(builder);
final RealmRepresentation newRealm = builder.build();
assertThat(newRealm, notNullValue());
testRealmResource().update(newRealm);
realm = new WebAuthnRealmData(testRealmResource().toRepresentation(), isPasswordless());
assertThat(realm, notNullValue());
assertThat(getCurrentValue.apply(realm), is(expectedValue));
}
use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class WebAuthnPolicySettingsTest method authenticatorAttachment.
@Test
public void authenticatorAttachment() {
AuthenticatorAttachment attachment = getPolicyPage().getAuthenticatorAttachment();
assertThat(attachment, nullValue());
// Cross-platform
getPolicyPage().setAuthenticatorAttachment(AuthenticatorAttachment.CROSS_PLATFORM);
getPolicyPage().clickSaveButton();
attachment = getPolicyPage().getAuthenticatorAttachment();
assertThat(attachment, notNullValue());
assertThat(attachment, is(AuthenticatorAttachment.CROSS_PLATFORM));
// Platform
getPolicyPage().setAuthenticatorAttachment(AuthenticatorAttachment.PLATFORM);
getPolicyPage().clickSaveButton();
attachment = getPolicyPage().getAuthenticatorAttachment();
assertThat(attachment, notNullValue());
assertThat(attachment, is(AuthenticatorAttachment.PLATFORM));
assertDataAfterModification(AuthenticatorAttachment.PLATFORM.getValue(), DEFAULT_WEBAUTHN_POLICY_NOT_SPECIFIED, WebAuthnRealmData::getAuthenticatorAttachment, (builder) -> builder.authenticatorAttachment(null));
}
use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class WebAuthnPolicySettingsTest method avoidSameAuthenticatorRegistration.
@Test
public void avoidSameAuthenticatorRegistration() {
boolean avoidSameAuthenticatorRegistration = getPolicyPage().avoidSameAuthenticatorRegistration();
assertThat(avoidSameAuthenticatorRegistration, is(false));
getPolicyPage().avoidSameAuthenticatorRegister(true);
assertThat(getPolicyPage().isSaveButtonEnabled(), is(true));
getPolicyPage().clickSaveButton();
avoidSameAuthenticatorRegistration = getPolicyPage().avoidSameAuthenticatorRegistration();
assertThat(avoidSameAuthenticatorRegistration, is(true));
getPolicyPage().avoidSameAuthenticatorRegister(false);
getPolicyPage().clickSaveButton();
avoidSameAuthenticatorRegistration = getPolicyPage().avoidSameAuthenticatorRegistration();
assertThat(avoidSameAuthenticatorRegistration, is(false));
final WebAuthnRealmData realm = new WebAuthnRealmData(testRealmResource().toRepresentation(), isPasswordless());
assertThat(realm, notNullValue());
assertThat(realm.isAvoidSameAuthenticatorRegister(), is(false));
}
Aggregations