use of org.keycloak.testsuite.console.page.clients.authorization.policy.AggregatePolicy in project keycloak by keycloak.
the class AggregatePolicyManagementTest method testCreateWithChild.
@Test
public void testCreateWithChild() {
AggregatePolicyRepresentation expected = new AggregatePolicyRepresentation();
expected.setName("Test Child Create Aggregate Policy");
expected.setDescription("description");
AggregatePolicy policy = authorizationPage.authorizationTabs().policies().create(expected, false);
RolePolicyRepresentation childPolicy = new RolePolicyRepresentation();
childPolicy.setName(UUID.randomUUID().toString());
childPolicy.addRole("Role A");
policy.createPolicy(childPolicy);
policy.form().save();
assertAlertSuccess();
expected.addPolicy(childPolicy.getName());
authorizationPage.navigateTo();
AggregatePolicy actual = authorizationPage.authorizationTabs().policies().name(expected.getName());
assertPolicy(expected, actual);
}
use of org.keycloak.testsuite.console.page.clients.authorization.policy.AggregatePolicy in project keycloak by keycloak.
the class AggregatePolicyManagementTest method testCreateWithChildAndSelectedPolicy.
@Test
public void testCreateWithChildAndSelectedPolicy() {
refreshPageAndWaitForLoad();
AggregatePolicyRepresentation expected = new AggregatePolicyRepresentation();
expected.setName("Test Child Create And Select Aggregate Policy");
expected.setDescription("description");
expected.addPolicy("Policy C");
AggregatePolicy policy = authorizationPage.authorizationTabs().policies().create(expected, false);
RolePolicyRepresentation childRolePolicy = new RolePolicyRepresentation();
childRolePolicy.setName(UUID.randomUUID().toString());
childRolePolicy.addRole("Role A");
policy.createPolicy(childRolePolicy);
expected.addPolicy(childRolePolicy.getName());
UserPolicyRepresentation childUserPolicy = new UserPolicyRepresentation();
childUserPolicy.setName(UUID.randomUUID().toString());
childUserPolicy.setDescription("description");
childUserPolicy.addUser("user a");
policy.createPolicy(childUserPolicy);
expected.addPolicy(childUserPolicy.getName());
ClientPolicyRepresentation childClientPolicy = new ClientPolicyRepresentation();
childClientPolicy.setName(UUID.randomUUID().toString());
childClientPolicy.setDescription("description");
childClientPolicy.addClient("client a");
policy.createPolicy(childClientPolicy);
expected.addPolicy(childClientPolicy.getName());
JSPolicyRepresentation childJSPolicy = new JSPolicyRepresentation();
childJSPolicy.setName(UUID.randomUUID().toString());
childJSPolicy.setDescription("description");
childJSPolicy.setCode("$evaluation.grant();");
policy.createPolicy(childJSPolicy);
expected.addPolicy(childJSPolicy.getName());
TimePolicyRepresentation childTimePolicy = new TimePolicyRepresentation();
childTimePolicy.setName(UUID.randomUUID().toString());
childTimePolicy.setDescription("description");
childTimePolicy.setNotBefore("2017-01-01 00:00:00");
childTimePolicy.setNotBefore("2018-01-01 00:00:00");
policy.createPolicy(childTimePolicy);
expected.addPolicy(childTimePolicy.getName());
GroupPolicyRepresentation childGroupPolicy = new GroupPolicyRepresentation();
childGroupPolicy.setName(UUID.randomUUID().toString());
childGroupPolicy.setDescription("description");
childGroupPolicy.setGroupsClaim("groups");
childGroupPolicy.addGroupPath("/Group A", true);
policy.createPolicy(childGroupPolicy);
expected.addPolicy(childGroupPolicy.getName());
policy.form().save();
assertAlertSuccess();
authorizationPage.navigateTo();
AggregatePolicy actual = authorizationPage.authorizationTabs().policies().name(expected.getName());
assertPolicy(expected, actual);
}
use of org.keycloak.testsuite.console.page.clients.authorization.policy.AggregatePolicy in project keycloak by keycloak.
the class AggregatePolicyManagementTest method createPolicy.
private AggregatePolicyRepresentation createPolicy(AggregatePolicyRepresentation expected) {
AggregatePolicy policy = authorizationPage.authorizationTabs().policies().create(expected);
assertAlertSuccess();
return assertPolicy(expected, policy);
}
use of org.keycloak.testsuite.console.page.clients.authorization.policy.AggregatePolicy in project keycloak by keycloak.
the class AggregatePolicyManagementTest method testUpdateWithChild.
@Test
public void testUpdateWithChild() {
AggregatePolicyRepresentation expected = new AggregatePolicyRepresentation();
expected.setName("Test Child Update Aggregate Policy");
expected.setDescription("description");
expected.addPolicy("Policy C");
AggregatePolicy policy = authorizationPage.authorizationTabs().policies().create(expected);
assertAlertSuccess();
assertPolicy(expected, policy);
RolePolicyRepresentation childPolicy = new RolePolicyRepresentation();
childPolicy.setName(UUID.randomUUID().toString());
childPolicy.addRole("Role A");
policy.createPolicy(childPolicy);
policy.form().save();
expected.addPolicy(childPolicy.getName());
authorizationPage.navigateTo();
AggregatePolicy actual = authorizationPage.authorizationTabs().policies().name(expected.getName());
assertPolicy(expected, actual);
}
use of org.keycloak.testsuite.console.page.clients.authorization.policy.AggregatePolicy in project keycloak by keycloak.
the class AggregatePolicyManagementTest method testUpdate.
@Test
public void testUpdate() throws InterruptedException {
authorizationPage.navigateTo();
AggregatePolicyRepresentation expected = new AggregatePolicyRepresentation();
expected.setName("Test Update Aggregate Policy");
expected.setDescription("description");
expected.addPolicy("Policy A");
expected.addPolicy("Policy B");
expected.addPolicy("Policy C");
expected = createPolicy(expected);
String previousName = expected.getName();
expected.setName("Changed Test Update Aggregate Policy");
expected.setDescription("Changed description");
expected.setLogic(Logic.NEGATIVE);
expected.getPolicies().clear();
expected.addPolicy("Policy A", "Policy C");
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().policies().update(previousName, expected);
assertAlertSuccess();
authorizationPage.navigateTo();
AggregatePolicy actual = authorizationPage.authorizationTabs().policies().name(expected.getName());
assertPolicy(expected, actual);
}
Aggregations