Search in sources :

Example 26 with WebAuthnRealmData

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));
}
Also used : AttestationConveyancePreference(com.webauthn4j.data.AttestationConveyancePreference) NoSuchElementException(org.openqa.selenium.NoSuchElementException) WebAuthnRealmData(org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData) AbstractConsoleTest(org.keycloak.testsuite.console.AbstractConsoleTest) Test(org.junit.Test)

Example 27 with WebAuthnRealmData

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));
}
Also used : PropertyRequirement(org.keycloak.testsuite.webauthn.utils.PropertyRequirement) WebAuthnRealmData(org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData) AbstractConsoleTest(org.keycloak.testsuite.console.AbstractConsoleTest) Test(org.junit.Test)

Example 28 with WebAuthnRealmData

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));
}
Also used : UserVerificationRequirement(com.webauthn4j.data.UserVerificationRequirement) WebAuthnRealmData(org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData) AbstractConsoleTest(org.keycloak.testsuite.console.AbstractConsoleTest) Test(org.junit.Test)

Example 29 with WebAuthnRealmData

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"));
}
Also used : Select(org.openqa.selenium.support.ui.Select) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NoSuchElementException(org.openqa.selenium.NoSuchElementException) WebAuthnRealmData(org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData) AbstractConsoleTest(org.keycloak.testsuite.console.AbstractConsoleTest) Test(org.junit.Test)

Aggregations

WebAuthnRealmData (org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData)29 Test (org.junit.Test)22 Closeable (java.io.Closeable)12 AbstractConsoleTest (org.keycloak.testsuite.console.AbstractConsoleTest)10 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)9 AbstractWebAuthnVirtualTest (org.keycloak.testsuite.webauthn.AbstractWebAuthnVirtualTest)9 IOException (java.io.IOException)6 IgnoreBrowserDriver (org.keycloak.testsuite.arquillian.annotation.IgnoreBrowserDriver)4 WebAuthnCredentialData (org.keycloak.models.credential.dto.WebAuthnCredentialData)3 WebAuthnDataWrapper (org.keycloak.testsuite.webauthn.utils.WebAuthnDataWrapper)3 NoSuchElementException (org.openqa.selenium.NoSuchElementException)2 Credential (org.openqa.selenium.virtualauthenticator.Credential)2 AttestationConveyancePreference (com.webauthn4j.data.AttestationConveyancePreference)1 AuthenticatorAttachment (com.webauthn4j.data.AuthenticatorAttachment)1 UserVerificationRequirement (com.webauthn4j.data.UserVerificationRequirement)1 COSEKey (com.webauthn4j.data.attestation.authenticator.COSEKey)1 RealmRepresentation (org.keycloak.representations.idm.RealmRepresentation)1 UserRepresentation (org.keycloak.representations.idm.UserRepresentation)1 RealmAttributeUpdater (org.keycloak.testsuite.updaters.RealmAttributeUpdater)1 WebAuthnPolicyPage (org.keycloak.testsuite.webauthn.pages.WebAuthnPolicyPage)1