Search in sources :

Example 1 with UserPolicy

use of org.keycloak.testsuite.console.page.clients.authorization.policy.UserPolicy in project keycloak by keycloak.

the class UserPolicyManagementTest method createPolicy.

private UserPolicyRepresentation createPolicy(UserPolicyRepresentation expected) {
    UserPolicy policy = authorizationPage.authorizationTabs().policies().create(expected);
    assertAlertSuccess();
    return assertPolicy(expected, policy);
}
Also used : UserPolicy(org.keycloak.testsuite.console.page.clients.authorization.policy.UserPolicy)

Example 2 with UserPolicy

use of org.keycloak.testsuite.console.page.clients.authorization.policy.UserPolicy in project keycloak by keycloak.

the class UserPolicyManagementTest method testUpdate.

@Test
public void testUpdate() throws InterruptedException {
    authorizationPage.navigateTo();
    UserPolicyRepresentation expected = new UserPolicyRepresentation();
    expected.setName("Test User Policy");
    expected.setDescription("description");
    expected.addUser("user a");
    expected.addUser("user b");
    expected.addUser("user c");
    expected = createPolicy(expected);
    String previousName = expected.getName();
    expected.setName("Changed Test User Policy");
    expected.setDescription("Changed description");
    expected.setLogic(Logic.NEGATIVE);
    expected.setUsers(expected.getUsers().stream().filter(user -> !user.equals("user b")).collect(Collectors.toSet()));
    authorizationPage.navigateTo();
    authorizationPage.authorizationTabs().policies().update(previousName, expected);
    assertAlertSuccess();
    authorizationPage.navigateTo();
    UserPolicy actual = authorizationPage.authorizationTabs().policies().name(expected.getName());
    assertPolicy(expected, actual);
}
Also used : UserPolicyRepresentation(org.keycloak.representations.idm.authorization.UserPolicyRepresentation) UserPolicy(org.keycloak.testsuite.console.page.clients.authorization.policy.UserPolicy) Test(org.junit.Test)

Aggregations

UserPolicy (org.keycloak.testsuite.console.page.clients.authorization.policy.UserPolicy)2 Test (org.junit.Test)1 UserPolicyRepresentation (org.keycloak.representations.idm.authorization.UserPolicyRepresentation)1