use of org.keycloak.admin.client.resource.ScopePermissionResource in project keycloak by keycloak.
the class ScopePermissionManagementTest method testDelete.
@Test
public void testDelete() {
AuthorizationResource authorization = getClient().authorization();
ScopePermissionRepresentation representation = new ScopePermissionRepresentation();
representation.setName("Test Delete Permission");
representation.addScope("execute");
representation.addPolicy("Only Marta Policy");
assertCreated(authorization, representation);
ScopePermissionsResource permissions = authorization.permissions().scope();
permissions.findById(representation.getId()).remove();
ScopePermissionResource removed = permissions.findById(representation.getId());
try {
removed.toRepresentation();
fail("Permission not removed");
} catch (NotFoundException ignore) {
}
}
use of org.keycloak.admin.client.resource.ScopePermissionResource in project keycloak by keycloak.
the class ScopePermissionManagementTest method assertCreated.
private void assertCreated(AuthorizationResource authorization, ScopePermissionRepresentation representation) {
ScopePermissionsResource permissions = authorization.permissions().scope();
try (Response response = permissions.create(representation)) {
ScopePermissionRepresentation created = response.readEntity(ScopePermissionRepresentation.class);
ScopePermissionResource permission = permissions.findById(created.getId());
assertRepresentation(representation, permission);
}
}
use of org.keycloak.admin.client.resource.ScopePermissionResource in project keycloak by keycloak.
the class ScopePermissionManagementTest method testUpdate.
@Test
public void testUpdate() {
AuthorizationResource authorization = getClient().authorization();
ScopePermissionRepresentation representation = new ScopePermissionRepresentation();
representation.setName("Update Test Scope Permission");
representation.setDescription("description");
representation.setDecisionStrategy(DecisionStrategy.CONSENSUS);
representation.setLogic(Logic.NEGATIVE);
representation.addResource("Resource A");
representation.addScope("read", "execute");
representation.addPolicy("Only Marta Policy", "Only Kolo Policy");
assertCreated(authorization, representation);
representation.setName("changed");
representation.setDescription("changed");
representation.setDecisionStrategy(DecisionStrategy.AFFIRMATIVE);
representation.setLogic(Logic.POSITIVE);
representation.getResources().remove("Resource A");
representation.addResource("Resource B");
representation.getScopes().remove("execute");
representation.getPolicies().remove("Only Marta Policy");
ScopePermissionsResource permissions = authorization.permissions().scope();
ScopePermissionResource permission = permissions.findById(representation.getId());
permission.update(representation);
assertRepresentation(representation, permission);
}
Aggregations