use of org.keycloak.testsuite.console.page.clients.authorization.policy.RolePolicy in project keycloak by keycloak.
the class RolePolicyManagementTest method createPolicy.
private RolePolicyRepresentation createPolicy(RolePolicyRepresentation expected) {
RolePolicy policy = authorizationPage.authorizationTabs().policies().create(expected);
assertAlertSuccess();
return assertPolicy(expected, policy);
}
use of org.keycloak.testsuite.console.page.clients.authorization.policy.RolePolicy in project keycloak by keycloak.
the class RolePolicyManagementTest method testUpdateClientRoles.
@Test
public void testUpdateClientRoles() throws InterruptedException {
authorizationPage.navigateTo();
RolePolicyRepresentation expected = new RolePolicyRepresentation();
expected.setName("Test Update Client Role Policy");
expected.setDescription("description");
String clientId = newClient.getClientId();
expected.addClientRole(clientId, "Client Role A");
expected.addClientRole(clientId, "Client Role B");
expected.addClientRole(clientId, "Client Role C");
expected = createPolicy(expected);
String previousName = expected.getName();
expected.setName("Changed Test Update Client Role Policy");
expected.setDescription("Changed description");
expected.setRoles(expected.getRoles().stream().filter(roleDefinition -> !roleDefinition.getId().contains("Client Role B")).collect(Collectors.toSet()));
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().policies().update(previousName, expected);
assertAlertSuccess();
authorizationPage.navigateTo();
RolePolicy actual = authorizationPage.authorizationTabs().policies().name(expected.getName());
expected = assertPolicy(expected, actual);
expected.getRoles().iterator().next().setRequired(true);
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().policies().update(expected.getName(), expected);
assertAlertSuccess();
expected = assertPolicy(expected, actual);
expected.getRoles().clear();
expected.addClientRole(clientId, "Client Role B", true);
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().policies().update(expected.getName(), expected);
assertAlertSuccess();
assertPolicy(expected, actual);
}
use of org.keycloak.testsuite.console.page.clients.authorization.policy.RolePolicy in project keycloak by keycloak.
the class RolePolicyManagementTest method testRealmAndClientRoles.
@Test
public void testRealmAndClientRoles() throws InterruptedException {
authorizationPage.navigateTo();
RolePolicyRepresentation expected = new RolePolicyRepresentation();
expected.setName("Test Realm And Client Role Policy");
expected.setDescription("description");
String clientId = newClient.getClientId();
expected.addRole("Realm Role A");
expected.addRole("Realm Role C");
expected.addClientRole(clientId, "Client Role A");
expected.addClientRole(clientId, "Client Role B");
expected.addClientRole(clientId, "Client Role C");
expected = createPolicy(expected);
expected.setRoles(expected.getRoles().stream().filter(roleDefinition -> !roleDefinition.getId().contains("Client Role B") && !roleDefinition.getId().contains("Realm Role A")).collect(Collectors.toSet()));
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().policies().update(expected.getName(), expected);
assertAlertSuccess();
authorizationPage.navigateTo();
RolePolicy actual = authorizationPage.authorizationTabs().policies().name(expected.getName());
expected = assertPolicy(expected, actual);
expected.getRoles().forEach(roleDefinition -> {
if (roleDefinition.getId().equals("Realm Role C")) {
roleDefinition.setRequired(true);
}
});
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().policies().update(expected.getName(), expected);
assertAlertSuccess();
expected = assertPolicy(expected, actual);
expected.getRoles().clear();
expected.addClientRole(clientId, "Client Role B", true);
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().policies().update(expected.getName(), expected);
assertAlertSuccess();
assertPolicy(expected, actual);
}
use of org.keycloak.testsuite.console.page.clients.authorization.policy.RolePolicy in project keycloak by keycloak.
the class RolePolicyManagementTest method testUpdateRealmRoles.
@Test
public void testUpdateRealmRoles() throws InterruptedException {
authorizationPage.navigateTo();
RolePolicyRepresentation expected = new RolePolicyRepresentation();
expected.setName("Test Update Realm Role Policy");
expected.setDescription("description");
expected.addRole("Realm Role A");
expected.addRole("Realm Role B");
expected.addRole("Realm Role C");
expected = createPolicy(expected);
String previousName = expected.getName();
expected.setName("Changed Test Realm Role Policy");
expected.setDescription("Changed description");
expected.setLogic(Logic.NEGATIVE);
expected.setRoles(expected.getRoles().stream().filter(roleDefinition -> !roleDefinition.getId().equals("Realm Role B")).collect(Collectors.toSet()));
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().policies().update(previousName, expected);
assertAlertSuccess();
authorizationPage.navigateTo();
RolePolicy actual = authorizationPage.authorizationTabs().policies().name(expected.getName());
expected = assertPolicy(expected, actual);
expected.getRoles().iterator().next().setRequired(true);
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().policies().update(expected.getName(), expected);
assertAlertSuccess();
expected = assertPolicy(expected, actual);
expected.getRoles().clear();
expected.addRole("Realm Role B", true);
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().policies().update(expected.getName(), expected);
assertAlertSuccess();
assertPolicy(expected, actual);
}
Aggregations