Search in sources :

Example 11 with RequiredActionProviderRepresentation

use of org.keycloak.representations.idm.RequiredActionProviderRepresentation in project keycloak by keycloak.

the class SigningInPageUtils method testSetUpLink.

public static void testSetUpLink(RealmResource realmResource, SigningInPage.CredentialType credentialType, String requiredActionProviderId) {
    assertThat("Set up link for \"" + credentialType.getType() + "\" is not visible", credentialType.isSetUpLinkVisible(), is(true));
    RequiredActionProviderRepresentation requiredAction = new RequiredActionProviderRepresentation();
    requiredAction.setEnabled(false);
    realmResource.flows().updateRequiredAction(requiredActionProviderId, requiredAction);
    refreshPageAndWaitForLoad();
    assertThat("Set up link for \"" + credentialType.getType() + "\" is visible", credentialType.isSetUpLinkVisible(), is(false));
    assertThat("Title for \"" + credentialType.getType() + "\" is visible", credentialType.isTitleVisible(), is(false));
    assertThat("Set up link for \"" + credentialType.getType() + "\" is visible", credentialType.isNotSetUpLabelVisible(), is(false));
}
Also used : RequiredActionProviderRepresentation(org.keycloak.representations.idm.RequiredActionProviderRepresentation)

Example 12 with RequiredActionProviderRepresentation

use of org.keycloak.representations.idm.RequiredActionProviderRepresentation in project keycloak by keycloak.

the class DeleteAccountTest method enableDeleteAccountRequiredAction.

private void enableDeleteAccountRequiredAction() {
    RequiredActionProviderRepresentation deleteAccount = testRealmResource().flows().getRequiredAction("delete_account");
    deleteAccount.setEnabled(true);
    testRealmResource().flows().updateRequiredAction("delete_account", deleteAccount);
}
Also used : RequiredActionProviderRepresentation(org.keycloak.representations.idm.RequiredActionProviderRepresentation)

Example 13 with RequiredActionProviderRepresentation

use of org.keycloak.representations.idm.RequiredActionProviderRepresentation in project keycloak by keycloak.

the class DeleteAccountTest method disableDeleteAccountRequiredAction.

private void disableDeleteAccountRequiredAction() {
    RequiredActionProviderRepresentation deleteAccount = testRealmResource().flows().getRequiredAction("delete_account");
    deleteAccount.setEnabled(false);
    testRealmResource().flows().updateRequiredAction("delete_account", deleteAccount);
}
Also used : RequiredActionProviderRepresentation(org.keycloak.representations.idm.RequiredActionProviderRepresentation)

Example 14 with RequiredActionProviderRepresentation

use of org.keycloak.representations.idm.RequiredActionProviderRepresentation in project keycloak by keycloak.

the class RequiredActionsTest method termsAndConditions.

@Test
public void termsAndConditions() {
    RequiredActionProviderRepresentation termsAndCondRep = testRealmResource().flows().getRequiredAction(termsAndConditionsPage.getActionId());
    termsAndCondRep.setEnabled(true);
    testRealmResource().flows().updateRequiredAction(termsAndConditionsPage.getActionId(), termsAndCondRep);
    initiateRequiredAction(termsAndConditionsPage);
    termsAndConditionsPage.localeDropdown().selectAndAssert(CUSTOM_LOCALE_NAME);
    termsAndConditionsPage.acceptTerms();
    assertLoginSuccessful();
    deleteAllSessionsInTestRealm();
    initiateRequiredAction(termsAndConditionsPage);
    assertEquals("[TEST LOCALE] souhlas s podmínkami", termsAndConditionsPage.getText());
    termsAndConditionsPage.declineTerms();
    loginErrorPage.assertCurrent();
    assertNoAccess();
}
Also used : RequiredActionProviderRepresentation(org.keycloak.representations.idm.RequiredActionProviderRepresentation) Test(org.junit.Test)

Example 15 with RequiredActionProviderRepresentation

use of org.keycloak.representations.idm.RequiredActionProviderRepresentation in project keycloak by keycloak.

the class WebAuthnSigningInTest method testWebAuthn.

private void testWebAuthn(boolean passwordless) {
    testContext.setTestRealmReps(emptyList());
    SigningInPage.CredentialType credentialType;
    final String expectedHelpText;
    final String providerId;
    if (passwordless) {
        credentialType = webAuthnPwdlessCredentialType;
        expectedHelpText = "Use your security key for passwordless sign in.";
        providerId = WebAuthnPasswordlessRegisterFactory.PROVIDER_ID;
    } else {
        credentialType = webAuthnCredentialType;
        expectedHelpText = "Use your security key to sign in.";
        providerId = WebAuthnRegisterFactory.PROVIDER_ID;
    }
    assertThat(credentialType.isSetUp(), is(false));
    // no way to simulate registration cancellation
    assertThat("Set up link for \"" + credentialType.getType() + "\" is not visible", credentialType.isSetUpLinkVisible(), is(true));
    assertThat(credentialType.getTitle(), is("Security Key"));
    assertThat(credentialType.getHelpText(), is(expectedHelpText));
    final String label1 = "WebAuthn is convenient";
    final String label2 = "but not yet widely adopted";
    SigningInPage.UserCredential webAuthn1 = addWebAuthnCredential(label1, passwordless);
    assertThat(credentialType.isSetUp(), is(true));
    assertThat(credentialType.getUserCredentialsCount(), is(1));
    assertUserCredential(label1, true, webAuthn1);
    SigningInPage.UserCredential webAuthn2 = addWebAuthnCredential(label2, passwordless);
    assertThat(credentialType.getUserCredentialsCount(), is(2));
    assertUserCredential(label2, true, webAuthn2);
    RequiredActionProviderRepresentation requiredAction = new RequiredActionProviderRepresentation();
    requiredAction.setEnabled(false);
    testRealmResource().flows().updateRequiredAction(providerId, requiredAction);
    refreshPageAndWaitForLoad();
    assertThat("Set up link for \"" + credentialType.getType() + "\" is visible", credentialType.isSetUpLinkVisible(), is(false));
    assertThat("Not set up link for \"" + credentialType.getType() + "\" is visible", credentialType.isNotSetUpLabelVisible(), is(false));
    assertThat("Title for \"" + credentialType.getType() + "\" is not visible", credentialType.isTitleVisible(), is(true));
    assertThat(credentialType.getUserCredentialsCount(), is(2));
    testRemoveCredential(webAuthn1);
}
Also used : RequiredActionProviderRepresentation(org.keycloak.representations.idm.RequiredActionProviderRepresentation) SigningInPage(org.keycloak.testsuite.ui.account2.page.SigningInPage)

Aggregations

RequiredActionProviderRepresentation (org.keycloak.representations.idm.RequiredActionProviderRepresentation)33 Test (org.junit.Test)13 AbstractTestRealmKeycloakTest (org.keycloak.testsuite.AbstractTestRealmKeycloakTest)6 UserRepresentation (org.keycloak.representations.idm.UserRepresentation)5 ArrayList (java.util.ArrayList)4 RealmResource (org.keycloak.admin.client.resource.RealmResource)4 RequiredActionProviderSimpleRepresentation (org.keycloak.representations.idm.RequiredActionProviderSimpleRepresentation)4 AbstractAuthenticationTest (org.keycloak.testsuite.admin.authentication.AbstractAuthenticationTest)4 LinkedList (java.util.LinkedList)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 Before (org.junit.Before)3 AuthServerContainerExclude (org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude)3 SocialLoginTest (org.keycloak.testsuite.broker.SocialLoginTest)3 HashMap (java.util.HashMap)2 NotFoundException (javax.ws.rs.NotFoundException)2 SigningInPage (org.keycloak.testsuite.ui.account2.page.SigningInPage)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Response (javax.ws.rs.core.Response)1