use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class WebAuthnPolicySettingsTest method attestationConveyancePreference.
@Test
public void attestationConveyancePreference() {
// default not specified
AttestationConveyancePreference attestation = getPolicyPage().getAttestationConveyancePreference();
assertThat(attestation, nullValue());
// Direct
getPolicyPage().setAttestationConveyancePreference(AttestationConveyancePreference.DIRECT);
getPolicyPage().clickSaveButton();
attestation = getPolicyPage().getAttestationConveyancePreference();
assertThat(attestation, notNullValue());
assertThat(attestation, is(AttestationConveyancePreference.DIRECT));
// Indirect
getPolicyPage().setAttestationConveyancePreference(AttestationConveyancePreference.INDIRECT);
getPolicyPage().clickSaveButton();
attestation = getPolicyPage().getAttestationConveyancePreference();
assertThat(attestation, notNullValue());
assertThat(attestation, is(AttestationConveyancePreference.INDIRECT));
// None
getPolicyPage().setAttestationConveyancePreference(AttestationConveyancePreference.NONE);
getPolicyPage().clickSaveButton();
attestation = getPolicyPage().getAttestationConveyancePreference();
assertThat(attestation, notNullValue());
assertThat(attestation, is(AttestationConveyancePreference.NONE));
try {
getPolicyPage().setAttestationConveyancePreference(AttestationConveyancePreference.ENTERPRISE);
Assert.fail("We don't support 'Enterprise' mode at this moment");
} catch (NoSuchElementException e) {
// Expected - NOP
}
assertDataAfterModification(AttestationConveyancePreference.NONE.getValue(), DEFAULT_WEBAUTHN_POLICY_NOT_SPECIFIED, WebAuthnRealmData::getAttestationConveyancePreference, (builder) -> builder.attestationConveyancePreference(null));
}
use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class WebAuthnPolicySettingsTest method residentKey.
@Test
public void residentKey() {
PropertyRequirement requireResidentKey = getPolicyPage().requireResidentKey();
assertThat(requireResidentKey, notNullValue());
assertThat(requireResidentKey, is(PropertyRequirement.NOT_SPECIFIED));
getPolicyPage().requireResidentKey(YES);
getPolicyPage().clickSaveButton();
// Yes
requireResidentKey = getPolicyPage().requireResidentKey();
assertThat(requireResidentKey, notNullValue());
assertThat(requireResidentKey, is(YES));
getPolicyPage().requireResidentKey(NO);
getPolicyPage().clickSaveButton();
// Null
getPolicyPage().requireResidentKey(null);
assertThat(getPolicyPage().isSaveButtonEnabled(), is(false));
// Not specified
getPolicyPage().requireResidentKey(PropertyRequirement.NOT_SPECIFIED);
assertThat(getPolicyPage().isSaveButtonEnabled(), is(true));
getPolicyPage().clickSaveButton();
// No
getPolicyPage().requireResidentKey(NO);
getPolicyPage().clickSaveButton();
requireResidentKey = getPolicyPage().requireResidentKey();
assertThat(requireResidentKey, notNullValue());
assertThat(requireResidentKey, is(NO));
assertDataAfterModification(NO.getValue(), DEFAULT_WEBAUTHN_POLICY_NOT_SPECIFIED, WebAuthnRealmData::getRequireResidentKey, (builder) -> builder.requireResidentKey(null));
}
use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class WebAuthnPolicySettingsTest method userVerification.
@Test
public void userVerification() {
UserVerificationRequirement userVerification = getPolicyPage().getUserVerification();
assertThat(userVerification, nullValue());
// Preferred
getPolicyPage().setUserVerification(UserVerificationRequirement.PREFERRED);
getPolicyPage().clickSaveButton();
userVerification = getPolicyPage().getUserVerification();
assertThat(userVerification, notNullValue());
assertThat(userVerification, is(UserVerificationRequirement.PREFERRED));
// Required
getPolicyPage().setUserVerification(UserVerificationRequirement.REQUIRED);
getPolicyPage().clickSaveButton();
userVerification = getPolicyPage().getUserVerification();
assertThat(userVerification, notNullValue());
assertThat(userVerification, is(UserVerificationRequirement.REQUIRED));
// Discouraged
getPolicyPage().setUserVerification(UserVerificationRequirement.DISCOURAGED);
getPolicyPage().clickSaveButton();
userVerification = getPolicyPage().getUserVerification();
assertThat(userVerification, notNullValue());
assertThat(userVerification, is(UserVerificationRequirement.DISCOURAGED));
assertDataAfterModification(UserVerificationRequirement.DISCOURAGED.getValue(), DEFAULT_WEBAUTHN_POLICY_NOT_SPECIFIED, WebAuthnRealmData::getUserVerificationRequirement, (builder) -> builder.userVerificationRequirement(null));
}
use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.
the class WebAuthnPolicySettingsTest method signatureAlgorithms.
@Test
public void signatureAlgorithms() {
getPolicyPage().assertCurrent();
final Select algorithms = getPolicyPage().getSignatureAlgorithms();
assertThat(algorithms, notNullValue());
algorithms.selectByValue("ES256");
algorithms.selectByValue("ES384");
algorithms.selectByValue("RS1");
final List<String> selectedAlgs = algorithms.getAllSelectedOptions().stream().map(WebElement::getText).collect(Collectors.toList());
assertThat(selectedAlgs, notNullValue());
assertThat(selectedAlgs, hasSize(3));
try {
algorithms.selectByValue("something-bad");
} catch (NoSuchElementException e) {
assertThat(e.getMessage(), containsString("Cannot locate option with value: something-bad"));
}
assertThat(getPolicyPage().isSaveButtonEnabled(), is(true));
assertThat(getPolicyPage().isCancelButtonEnabled(), is(true));
getPolicyPage().clickSaveButton();
assertThat(getPolicyPage().isSaveButtonEnabled(), is(false));
assertThat(getPolicyPage().isCancelButtonEnabled(), is(false));
final WebAuthnRealmData realm = new WebAuthnRealmData(testRealmResource().toRepresentation(), isPasswordless());
assertThat(realm, notNullValue());
final List<String> realmSignatureAlgs = realm.getSignatureAlgorithms();
assertThat(realmSignatureAlgs, notNullValue());
assertThat(realmSignatureAlgs, hasSize(3));
assertThat(realmSignatureAlgs, contains("ES256", "ES384", "RS1"));
}
Aggregations