Search in sources :

Example 21 with RequiredActionProviderRepresentation

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

the class AbstractMigrationTest method testNameOfOTPRequiredAction.

protected void testNameOfOTPRequiredAction(RealmResource... realms) {
    log.info("testing OTP Required Action");
    for (RealmResource realm : realms) {
        RequiredActionProviderRepresentation otpAction = realm.flows().getRequiredAction(UserModel.RequiredAction.CONFIGURE_TOTP.name());
        assertEquals("The name of CONFIGURE_TOTP required action should be 'Configure OTP'.", "Configure OTP", otpAction.getName());
    }
}
Also used : RequiredActionProviderRepresentation(org.keycloak.representations.idm.RequiredActionProviderRepresentation) RealmResource(org.keycloak.admin.client.resource.RealmResource)

Example 22 with RequiredActionProviderRepresentation

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

the class SigningInTest method otpTest.

@Test
public void otpTest() {
    testContext.setTestRealmReps(emptyList());
    assertThat(otpCredentialType.isSetUp(), is(false));
    otpCredentialType.clickSetUpLink();
    otpSetupPage.cancel();
    signingInPage.assertCurrent();
    assertThat(otpCredentialType.isSetUp(), is(false));
    assertThat(otpCredentialType.getTitle(), is("Authenticator Application"));
    final String label1 = "OTP is secure";
    final String label2 = "OTP is inconvenient";
    SigningInPage.UserCredential otp1 = addOtpCredential(label1);
    assertThat(otpCredentialType.isSetUp(), is(true));
    assertThat(otpCredentialType.getUserCredentialsCount(), is(1));
    assertUserCredential(label1, true, otp1);
    SigningInPage.UserCredential otp2 = addOtpCredential(label2);
    assertThat(otpCredentialType.getUserCredentialsCount(), is(2));
    assertUserCredential(label2, true, otp2);
    assertThat("Set up link is not visible", otpCredentialType.isSetUpLinkVisible(), is(true));
    RequiredActionProviderRepresentation requiredAction = new RequiredActionProviderRepresentation();
    requiredAction.setEnabled(false);
    testRealmResource().flows().updateRequiredAction(CONFIGURE_TOTP.name(), requiredAction);
    refreshPageAndWaitForLoad();
    assertThat("Set up link for \"otp\" is visible", otpCredentialType.isSetUpLinkVisible(), is(false));
    assertThat("Not set up link for \"otp\" is visible", otpCredentialType.isNotSetUpLabelVisible(), is(false));
    assertThat("Title for \"otp\" is not visible", otpCredentialType.isTitleVisible(), is(true));
    assertThat(otpCredentialType.getUserCredentialsCount(), is(2));
    testRemoveCredential(otp1);
}
Also used : RequiredActionProviderRepresentation(org.keycloak.representations.idm.RequiredActionProviderRepresentation) SigningInPage(org.keycloak.testsuite.ui.account2.page.SigningInPage) Test(org.junit.Test)

Example 23 with RequiredActionProviderRepresentation

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

the class TermsAndConditionsTest method termsDisabled.

@Test
public // KEYCLOAK-3192
void termsDisabled() {
    RequiredActionProviderRepresentation rep = adminClient.realm("test").flows().getRequiredAction("terms_and_conditions");
    rep.setEnabled(false);
    adminClient.realm("test").flows().updateRequiredAction("terms_and_conditions", rep);
    loginPage.open();
    loginPage.login("test-user@localhost", "password");
    assertTrue(appPage.isCurrent());
    events.expectLogin().assertEvent();
}
Also used : RequiredActionProviderRepresentation(org.keycloak.representations.idm.RequiredActionProviderRepresentation) Test(org.junit.Test) AbstractTestRealmKeycloakTest(org.keycloak.testsuite.AbstractTestRealmKeycloakTest)

Example 24 with RequiredActionProviderRepresentation

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

the class RequiredActionTotpSetupTest method configureTestRealm.

@Override
public void configureTestRealm(RealmRepresentation testRealm) {
    RequiredActionProviderRepresentation requiredAction = new RequiredActionProviderRepresentation();
    requiredAction.setAlias(UserModel.RequiredAction.CONFIGURE_TOTP.name());
    requiredAction.setProviderId(UserModel.RequiredAction.CONFIGURE_TOTP.name());
    requiredAction.setName("Configure Totp");
    requiredAction.setEnabled(true);
    requiredAction.setDefaultAction(true);
    List<RequiredActionProviderRepresentation> requiredActions = new LinkedList<>();
    requiredActions.add(requiredAction);
    testRealm.setRequiredActions(requiredActions);
    testRealm.setResetPasswordAllowed(Boolean.TRUE);
}
Also used : RequiredActionProviderRepresentation(org.keycloak.representations.idm.RequiredActionProviderRepresentation) LinkedList(java.util.LinkedList)

Example 25 with RequiredActionProviderRepresentation

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

the class ActionUtil method addRequiredActionForRealm.

public static void addRequiredActionForRealm(RealmRepresentation testRealm, String providerId) {
    List<RequiredActionProviderRepresentation> requiredActions = testRealm.getRequiredActions();
    if (requiredActions == null)
        requiredActions = new LinkedList();
    RequiredActionProviderRepresentation last = requiredActions.get(requiredActions.size() - 1);
    RequiredActionProviderRepresentation action = new RequiredActionProviderRepresentation();
    action.setAlias(providerId);
    action.setProviderId(providerId);
    action.setEnabled(true);
    action.setDefaultAction(true);
    action.setPriority(last.getPriority() + 1);
    requiredActions.add(action);
    testRealm.setRequiredActions(requiredActions);
}
Also used : RequiredActionProviderRepresentation(org.keycloak.representations.idm.RequiredActionProviderRepresentation) LinkedList(java.util.LinkedList)

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