Search in sources :

Example 6 with WebAuthnRealmData

use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.

the class WebAuthnPolicySettingsTest method timeout.

@Test
public void timeout() {
    int timeout = getPolicyPage().getTimeout();
    assertThat(timeout, is(0));
    getPolicyPage().setTimeout(10);
    getPolicyPage().clickSaveButton();
    timeout = getPolicyPage().getTimeout();
    assertThat(timeout, is(10));
    getPolicyPage().setTimeout(-10);
    getPolicyPage().clickSaveButton();
    assertAlertDanger();
    timeout = getPolicyPage().getTimeout();
    assertThat(timeout, is(-10));
    getPolicyPage().navigateTo();
    waitForPageToLoad();
    timeout = getPolicyPage().getTimeout();
    assertThat(timeout, is(10));
    getPolicyPage().setTimeout(1000000);
    getPolicyPage().clickSaveButton();
    assertAlertDanger();
    getPolicyPage().setTimeout(500);
    getPolicyPage().clickSaveButton();
    timeout = getPolicyPage().getTimeout();
    assertThat(timeout, is(500));
    final WebAuthnRealmData realm = new WebAuthnRealmData(testRealmResource().toRepresentation(), isPasswordless());
    assertThat(realm, notNullValue());
    assertThat(realm.getCreateTimeout(), is(500));
}
Also used : WebAuthnRealmData(org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData) AbstractConsoleTest(org.keycloak.testsuite.console.AbstractConsoleTest) Test(org.junit.Test)

Example 7 with WebAuthnRealmData

use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.

the class WebAuthnPolicySettingsTest method acceptableAaguid.

@Test
public void acceptableAaguid() {
    WebAuthnPolicyPage.MultivaluedAcceptableAaguid acceptableAaguid = getPolicyPage().getAcceptableAaguid();
    assertThat(acceptableAaguid, notNullValue());
    List<String> items = getAcceptableAaguid(getPolicyPage().getAcceptableAaguid());
    assertThat(items, notNullValue());
    acceptableAaguid.addItem(ALL_ONE_AAGUID);
    getPolicyPage().clickSaveButton();
    items = getAcceptableAaguid(getPolicyPage().getAcceptableAaguid());
    assertThat(items, notNullValue());
    assertThat(items.isEmpty(), is(false));
    assertThat(items.contains(ALL_ONE_AAGUID), is(true));
    final String YUBIKEY_5_AAGUID = "cb69481e-8ff7-4039-93ec-0a2729a154a8";
    final String YUBICO_AAGUID = "f8a011f3-8c0a-4d15-8006-17111f9edc7d";
    acceptableAaguid.addItem(YUBIKEY_5_AAGUID);
    acceptableAaguid.addItem(YUBICO_AAGUID);
    items = getAcceptableAaguid(getPolicyPage().getAcceptableAaguid());
    assertThat(items, notNullValue());
    assertThat(items, hasSize(3));
    getPolicyPage().clickSaveButton();
    acceptableAaguid.removeItem(0);
    items = getAcceptableAaguid(getPolicyPage().getAcceptableAaguid());
    assertThat(items, notNullValue());
    assertThat(items, hasSize(2));
    assertThat(items.contains(YUBICO_AAGUID), is(true));
    assertThat(items.contains(YUBIKEY_5_AAGUID), is(true));
    assertThat(items.contains(ALL_ONE_AAGUID), is(false));
    assertThat(getPolicyPage().isSaveButtonEnabled(), is(true));
    getPolicyPage().clickSaveButton();
    pause(100);
    WebAuthnRealmData realm = new WebAuthnRealmData(testRealmResource().toRepresentation(), isPasswordless());
    assertThat(realm, notNullValue());
    assertThat(realm.getAcceptableAaguids(), is(getAcceptableAaguid(getPolicyPage().getAcceptableAaguid())));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WebAuthnPolicyPage(org.keycloak.testsuite.webauthn.pages.WebAuthnPolicyPage) WebAuthnRealmData(org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData) AbstractConsoleTest(org.keycloak.testsuite.console.AbstractConsoleTest) Test(org.junit.Test)

Example 8 with WebAuthnRealmData

use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.

the class PolicyJsInjectionTest method relyingPartyId.

@Test
public void relyingPartyId() throws IOException {
    try (Closeable u = getWebAuthnRealmUpdater().setWebAuthnPolicyRpId(PROMPT_SCRIPT).update()) {
        WebAuthnRealmData data = new WebAuthnRealmData(testRealm().toRepresentation(), isPasswordless());
        assertThat(data.getRpId(), is(PROMPT_SCRIPT));
        registerDefaultUser(false);
        webAuthnErrorPage.assertCurrent();
        final String expectedMessage = getExpectedMessageByDriver("SecurityError: The operation is insecure.", "The relying party ID is not a registrable domain suffix of, nor equal to the current domain.");
        assertThat(webAuthnErrorPage.getError(), containsString(expectedMessage));
    }
}
Also used : Closeable(java.io.Closeable) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WebAuthnRealmData(org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData) Test(org.junit.Test) AbstractWebAuthnVirtualTest(org.keycloak.testsuite.webauthn.AbstractWebAuthnVirtualTest)

Example 9 with WebAuthnRealmData

use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.

the class PolicyJsInjectionTest method userVerificationRequirement.

@Test
public void userVerificationRequirement() {
    String expectedMessage = getExpectedMessageByDriver("(value of 'userVerification' member of AuthenticatorSelectionCriteria) is not a valid value for enumeration UserVerificationRequirement.", "The provided value 'required\"; window.prompt('Injection'); \"<img id=\"image-inject\" src='none'/> ' is not a valid enum value of type UserVerificationRequirement.");
    verifyInjection((updater) -> updater.setWebAuthnPolicyUserVerificationRequirement(PROMPT_SCRIPT), WebAuthnRealmData::getUserVerificationRequirement, PROMPT_SCRIPT, expectedMessage);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WebAuthnRealmData(org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData) Test(org.junit.Test) AbstractWebAuthnVirtualTest(org.keycloak.testsuite.webauthn.AbstractWebAuthnVirtualTest)

Example 10 with WebAuthnRealmData

use of org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData in project keycloak by keycloak.

the class PolicyJsInjectionTest method authenticatorAttachment.

@Test
public void authenticatorAttachment() {
    final String expectedMessage = getExpectedMessageByDriver("(value of 'authenticatorAttachment' member of AuthenticatorSelectionCriteria) is not a valid value for enumeration AuthenticatorAttachment.", "The provided value 'required\"; window.location.href = \"http://www.keycloak.org\";\"' is not a valid enum value of type AuthenticatorAttachment.");
    verifyInjection((updater) -> updater.setWebAuthnPolicyAuthenticatorAttachment(REDIRECT_SCRIPT), WebAuthnRealmData::getAuthenticatorAttachment, REDIRECT_SCRIPT, expectedMessage);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) WebAuthnRealmData(org.keycloak.testsuite.webauthn.utils.WebAuthnRealmData) Test(org.junit.Test) AbstractWebAuthnVirtualTest(org.keycloak.testsuite.webauthn.AbstractWebAuthnVirtualTest)

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