Search in sources :

Example 1 with AggregatePolicy

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);
}
Also used : RolePolicyRepresentation(org.keycloak.representations.idm.authorization.RolePolicyRepresentation) AggregatePolicy(org.keycloak.testsuite.console.page.clients.authorization.policy.AggregatePolicy) AggregatePolicyRepresentation(org.keycloak.representations.idm.authorization.AggregatePolicyRepresentation) Test(org.junit.Test)

Example 2 with AggregatePolicy

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);
}
Also used : RolePolicyRepresentation(org.keycloak.representations.idm.authorization.RolePolicyRepresentation) ClientPolicyRepresentation(org.keycloak.representations.idm.authorization.ClientPolicyRepresentation) UserPolicyRepresentation(org.keycloak.representations.idm.authorization.UserPolicyRepresentation) JSPolicyRepresentation(org.keycloak.representations.idm.authorization.JSPolicyRepresentation) TimePolicyRepresentation(org.keycloak.representations.idm.authorization.TimePolicyRepresentation) AggregatePolicy(org.keycloak.testsuite.console.page.clients.authorization.policy.AggregatePolicy) GroupPolicyRepresentation(org.keycloak.representations.idm.authorization.GroupPolicyRepresentation) AggregatePolicyRepresentation(org.keycloak.representations.idm.authorization.AggregatePolicyRepresentation) Test(org.junit.Test)

Example 3 with AggregatePolicy

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);
}
Also used : AggregatePolicy(org.keycloak.testsuite.console.page.clients.authorization.policy.AggregatePolicy)

Example 4 with AggregatePolicy

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);
}
Also used : RolePolicyRepresentation(org.keycloak.representations.idm.authorization.RolePolicyRepresentation) AggregatePolicy(org.keycloak.testsuite.console.page.clients.authorization.policy.AggregatePolicy) AggregatePolicyRepresentation(org.keycloak.representations.idm.authorization.AggregatePolicyRepresentation) Test(org.junit.Test)

Example 5 with AggregatePolicy

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);
}
Also used : AggregatePolicy(org.keycloak.testsuite.console.page.clients.authorization.policy.AggregatePolicy) AggregatePolicyRepresentation(org.keycloak.representations.idm.authorization.AggregatePolicyRepresentation) Test(org.junit.Test)

Aggregations

AggregatePolicy (org.keycloak.testsuite.console.page.clients.authorization.policy.AggregatePolicy)5 Test (org.junit.Test)4 AggregatePolicyRepresentation (org.keycloak.representations.idm.authorization.AggregatePolicyRepresentation)4 RolePolicyRepresentation (org.keycloak.representations.idm.authorization.RolePolicyRepresentation)3 ClientPolicyRepresentation (org.keycloak.representations.idm.authorization.ClientPolicyRepresentation)1 GroupPolicyRepresentation (org.keycloak.representations.idm.authorization.GroupPolicyRepresentation)1 JSPolicyRepresentation (org.keycloak.representations.idm.authorization.JSPolicyRepresentation)1 TimePolicyRepresentation (org.keycloak.representations.idm.authorization.TimePolicyRepresentation)1 UserPolicyRepresentation (org.keycloak.representations.idm.authorization.UserPolicyRepresentation)1