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();
}
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);
}
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");
}
Aggregations