use of org.keycloak.testsuite.console.page.clients.authorization.permission.ResourcePermission in project keycloak by keycloak.
the class ResourcePermissionManagementTest method testUpdateResourceType.
@Test
public void testUpdateResourceType() throws InterruptedException {
authorizationPage.navigateTo();
ResourcePermissionRepresentation expected = new ResourcePermissionRepresentation();
expected.setName("testUpdateResourceType Permission");
expected.setDescription("description");
expected.setResourceType("test-resource-type");
expected.addPolicy("Policy A");
expected.addPolicy("Policy B");
expected.addPolicy("Policy C");
expected = createPermission(expected);
String previousName = expected.getName();
expected.setName(expected.getName() + " Changed");
expected.setDescription("Changed description");
expected.setDecisionStrategy(DecisionStrategy.CONSENSUS);
expected.setResourceType("changed-resource-type");
expected.setPolicies(expected.getPolicies().stream().filter(policy -> !policy.equals("Policy B")).collect(Collectors.toSet()));
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().permissions().update(previousName, expected);
assertAlertSuccess();
authorizationPage.navigateTo();
ResourcePermission actual = authorizationPage.authorizationTabs().permissions().name(expected.getName());
assertPolicy(expected, actual);
expected.setResourceType(null);
expected.addResource("Resource A");
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().permissions().update(expected.getName(), expected);
assertAlertSuccess();
ResourcePermissionsResource resourcePermission = testRealmResource().clients().get(newClient.getId()).authorization().permissions().resource();
ResourcePermissionRepresentation permission = resourcePermission.findByName(expected.getName());
assertFalse(resourcePermission.findById(permission.getId()).resources().isEmpty());
expected.setResourceType("test");
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().permissions().update(expected.getName(), expected);
assertAlertSuccess();
assertTrue(resourcePermission.findById(permission.getId()).resources().isEmpty());
}
use of org.keycloak.testsuite.console.page.clients.authorization.permission.ResourcePermission in project keycloak by keycloak.
the class ResourcePermissionManagementTest method createPermission.
private ResourcePermissionRepresentation createPermission(ResourcePermissionRepresentation expected) {
ResourcePermission policy = authorizationPage.authorizationTabs().permissions().create(expected, true);
assertAlertSuccess();
return assertPolicy(expected, policy);
}
use of org.keycloak.testsuite.console.page.clients.authorization.permission.ResourcePermission in project keycloak by keycloak.
the class ResourcePermissionManagementTest method testUpdateResource.
@Test
public void testUpdateResource() throws InterruptedException {
authorizationPage.navigateTo();
ResourcePermissionRepresentation expected = new ResourcePermissionRepresentation();
expected.setName("testUpdateResource Permission");
expected.setDescription("description");
expected.addResource("Resource A");
expected.addPolicy("Policy A");
expected.addPolicy("Policy B");
expected.addPolicy("Policy C");
expected = createPermission(expected);
String previousName = expected.getName();
expected.setName(expected.getName() + " Changed");
expected.setDescription("Changed description");
expected.setDecisionStrategy(DecisionStrategy.CONSENSUS);
expected.getResources().clear();
expected.addResource("Resource B");
expected.getPolicies().clear();
expected.addPolicy("Policy A", "Policy C");
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().permissions().update(previousName, expected);
assertAlertSuccess();
authorizationPage.navigateTo();
ResourcePermission actual = authorizationPage.authorizationTabs().permissions().name(expected.getName());
assertPolicy(expected, actual);
expected.getPolicies().clear();
authorizationPage.navigateTo();
authorizationPage.authorizationTabs().permissions().update(expected.getName(), expected);
assertAlertSuccess();
authorizationPage.navigateTo();
actual = authorizationPage.authorizationTabs().permissions().name(expected.getName());
assertPolicy(expected, actual);
}
use of org.keycloak.testsuite.console.page.clients.authorization.permission.ResourcePermission in project keycloak by keycloak.
the class ResourcePermissionManagementTest method testCreateWithChild.
@Test
public void testCreateWithChild() {
ResourcePermissionRepresentation expected = new ResourcePermissionRepresentation();
expected.setName(UUID.randomUUID().toString());
expected.setDescription("description");
expected.addResource("Resource B");
expected.addPolicy("Policy C");
ResourcePermission policy = authorizationPage.authorizationTabs().permissions().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();
ResourcePermission actual = authorizationPage.authorizationTabs().permissions().name(expected.getName());
assertPolicy(expected, actual);
}
use of org.keycloak.testsuite.console.page.clients.authorization.permission.ResourcePermission in project keycloak by keycloak.
the class ResourcePermissionManagementTest method testCreateWithoutPolicies.
@Test
public void testCreateWithoutPolicies() throws InterruptedException {
authorizationPage.navigateTo();
ResourcePermissionRepresentation expected = new ResourcePermissionRepresentation();
expected.setName("testCreateWithoutPolicies Permission");
expected.setDescription("description");
expected.addResource("Resource A");
expected = createPermission(expected);
authorizationPage.navigateTo();
ResourcePermission actual = authorizationPage.authorizationTabs().permissions().name(expected.getName());
assertPolicy(expected, actual);
}
Aggregations