Search in sources :

Example 26 with GroupPolicyRepresentation

use of org.keycloak.representations.idm.authorization.GroupPolicyRepresentation in project keycloak by keycloak.

the class GroupPathPolicyTest method createGroupPolicy.

private void createGroupPolicy(String name, String groupPath, boolean extendChildren) {
    GroupPolicyRepresentation policy = new GroupPolicyRepresentation();
    policy.setName(name);
    policy.setGroupsClaim("groups");
    policy.addGroupPath(groupPath, extendChildren);
    getClient().authorization().policies().group().create(policy).close();
}
Also used : GroupPolicyRepresentation(org.keycloak.representations.idm.authorization.GroupPolicyRepresentation)

Example 27 with GroupPolicyRepresentation

use of org.keycloak.representations.idm.authorization.GroupPolicyRepresentation in project keycloak by keycloak.

the class GroupPolicyManagementTest method testUpdate.

@Test
public void testUpdate() throws InterruptedException {
    authorizationPage.navigateTo();
    GroupPolicyRepresentation expected = new GroupPolicyRepresentation();
    expected.setName("Test Group Policy");
    expected.setDescription("description");
    expected.setGroupsClaim("groups");
    expected.addGroupPath("/Group A", true);
    expected.addGroupPath("/Group A/Group B/Group D");
    expected.addGroupPath("Group F");
    expected = createPolicy(expected);
    String previousName = expected.getName();
    expected.setName("Changed Test Group Policy");
    expected.setDescription("Changed description");
    expected.setLogic(Logic.NEGATIVE);
    expected.setGroupsClaim(null);
    authorizationPage.navigateTo();
    authorizationPage.authorizationTabs().policies().update(previousName, expected);
    assertAlertSuccess();
    authorizationPage.navigateTo();
    GroupPolicy actual = authorizationPage.authorizationTabs().policies().name(expected.getName());
    assertPolicy(expected, actual);
    expected.getGroups().clear();
    expected.addGroupPath("/Group A", false);
    expected.addGroupPath("/Group A/Group B/Group D");
    authorizationPage.navigateTo();
    authorizationPage.authorizationTabs().policies().update(expected.getName(), expected);
    assertAlertSuccess();
    authorizationPage.navigateTo();
    actual = authorizationPage.authorizationTabs().policies().name(expected.getName());
    assertPolicy(expected, actual);
    expected.getGroups().clear();
    expected.addGroupPath("/Group E");
    expected.addGroupPath("/Group A/Group B", true);
    expected.addGroupPath("/Group A/Group C");
    authorizationPage.navigateTo();
    authorizationPage.authorizationTabs().policies().update(expected.getName(), expected);
    assertAlertSuccess();
    authorizationPage.navigateTo();
    actual = authorizationPage.authorizationTabs().policies().name(expected.getName());
    assertPolicy(expected, actual);
}
Also used : GroupPolicy(org.keycloak.testsuite.console.page.clients.authorization.policy.GroupPolicy) GroupPolicyRepresentation(org.keycloak.representations.idm.authorization.GroupPolicyRepresentation) Test(org.junit.Test)

Example 28 with GroupPolicyRepresentation

use of org.keycloak.representations.idm.authorization.GroupPolicyRepresentation in project keycloak by keycloak.

the class GroupPolicyManagementTest method testSaveWithInInvalidGroup.

@Test
public void testSaveWithInInvalidGroup() throws InterruptedException {
    authorizationPage.navigateTo();
    GroupPolicyRepresentation expected = new GroupPolicyRepresentation();
    expected.setName("Test Invalid Group Policy");
    expected.setDescription("description");
    expected.addGroupPath("/Groups", true);
    authorizationPage.authorizationTabs().policies().create(expected, false);
    alert.assertDanger("Error! You must choose a group");
}
Also used : GroupPolicyRepresentation(org.keycloak.representations.idm.authorization.GroupPolicyRepresentation) Test(org.junit.Test)

Aggregations

GroupPolicyRepresentation (org.keycloak.representations.idm.authorization.GroupPolicyRepresentation)28 Test (org.junit.Test)13 AuthorizationResource (org.keycloak.admin.client.resource.AuthorizationResource)6 GroupPoliciesResource (org.keycloak.admin.client.resource.GroupPoliciesResource)4 GroupPolicyResource (org.keycloak.admin.client.resource.GroupPolicyResource)4 Policy (org.keycloak.authorization.model.Policy)4 ClientPolicyRepresentation (org.keycloak.representations.idm.authorization.ClientPolicyRepresentation)4 JSPolicyRepresentation (org.keycloak.representations.idm.authorization.JSPolicyRepresentation)4 RolePolicyRepresentation (org.keycloak.representations.idm.authorization.RolePolicyRepresentation)4 UserPolicyRepresentation (org.keycloak.representations.idm.authorization.UserPolicyRepresentation)4 HashSet (java.util.HashSet)3 Response (javax.ws.rs.core.Response)3 GroupModel (org.keycloak.models.GroupModel)3 AbstractPolicyRepresentation (org.keycloak.representations.idm.authorization.AbstractPolicyRepresentation)3 WebElement (org.openqa.selenium.WebElement)3 IOException (java.io.IOException)2 List (java.util.List)2 NotFoundException (javax.ws.rs.NotFoundException)2 Drone (org.jboss.arquillian.drone.api.annotation.Drone)2 Page (org.jboss.arquillian.graphene.page.Page)2