use of org.keycloak.admin.client.resource.AggregatePoliciesResource in project keycloak by keycloak.
the class AggregatePolicyManagementTest method testUpdate.
@Test
public void testUpdate() {
AuthorizationResource authorization = getClient().authorization();
AggregatePolicyRepresentation representation = new AggregatePolicyRepresentation();
representation.setName("Update Aggregate Policy");
representation.setDescription("description");
representation.setDecisionStrategy(DecisionStrategy.CONSENSUS);
representation.setLogic(Logic.NEGATIVE);
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.getPolicies().clear();
representation.addPolicy("Only Kolo Policy");
AggregatePoliciesResource policies = authorization.policies().aggregate();
AggregatePolicyResource policy = policies.findById(representation.getId());
policy.update(representation);
assertRepresentation(representation, policy);
}
use of org.keycloak.admin.client.resource.AggregatePoliciesResource in project keycloak by keycloak.
the class AggregatePolicyManagementTest method assertCreated.
private void assertCreated(AuthorizationResource authorization, AggregatePolicyRepresentation representation) {
AggregatePoliciesResource permissions = authorization.policies().aggregate();
try (Response response = permissions.create(representation)) {
AggregatePolicyRepresentation created = response.readEntity(AggregatePolicyRepresentation.class);
AggregatePolicyResource permission = permissions.findById(created.getId());
assertRepresentation(representation, permission);
}
}
use of org.keycloak.admin.client.resource.AggregatePoliciesResource in project keycloak by keycloak.
the class AggregatePolicyManagementTest method testDelete.
@Test
public void testDelete() {
AuthorizationResource authorization = getClient().authorization();
AggregatePolicyRepresentation representation = new AggregatePolicyRepresentation();
representation.setName("Test Delete Policy");
representation.addPolicy("Only Marta Policy");
AggregatePoliciesResource policies = authorization.policies().aggregate();
try (Response response = policies.create(representation)) {
AggregatePolicyRepresentation created = response.readEntity(AggregatePolicyRepresentation.class);
policies.findById(created.getId()).remove();
AggregatePolicyResource removed = policies.findById(created.getId());
try {
removed.toRepresentation();
fail("Policy not removed");
} catch (NotFoundException ignore) {
}
}
}
Aggregations