use of org.forgerock.openam.uma.rest.PolicyGraph in project OpenAM by OpenRock.
the class PolicyGraphTest method shouldSwitchAllScopesInvalid.
/*
Dave had removed Ed's ability to DELETE, so Ed's resharing policy to Bob had been
made inactive. Dave has re-granted Ed's DELETE, so the inactive policy can be made
active again.
*/
@Test
public void shouldSwitchAllScopesInvalid() throws Exception {
// Given
List<ResourceResponse> policies = excludePolicies(ED, BOB);
policies.add(makePolicy(ED, BOB, false, DELETE));
PolicyGraph graph = makePolicyGraph(policies);
graph.computeGraph();
given(delegate.updatePolicies(isNull(Context.class), anySet())).willReturn(Promises.<List<ResourceResponse>, ResourceException>newResultPromise(Collections.<ResourceResponse>emptyList()));
// When
Promise<List<List<ResourceResponse>>, ResourceException> promise = graph.update(null, delegate);
// Then
AssertJPromiseAssert.assertThat(promise).succeeded();
assertThat(policyUpdated().get("active").asBoolean()).isTrue();
verifyNoMoreInteractions(delegate);
}
use of org.forgerock.openam.uma.rest.PolicyGraph in project OpenAM by OpenRock.
the class PolicyGraphTest method shouldUpdateInvalidRightsTree.
/*
Dave had previously re-shared VIEW scope to ED, but that was made invalid when
he lost that scope himself. He has been re-granted that scope so the VIEW scope
should move the active policy and the empty inactive policy should be deleted.
*/
@Test
public void shouldUpdateInvalidRightsTree() throws Exception {
// Given
List<ResourceResponse> policies = excludePolicies(DAVE, ED);
policies.add(makePolicy(DAVE, ED, true, DELETE));
policies.add(makePolicy(DAVE, ED, false, VIEW));
PolicyGraph graph = makePolicyGraph(policies);
graph.computeGraph();
given(delegate.updatePolicies(isNull(Context.class), anySet())).willReturn(Promises.<List<ResourceResponse>, ResourceException>newResultPromise(Collections.<ResourceResponse>emptyList()));
given(delegate.deletePolicies(isNull(Context.class), anySet())).willReturn(Promises.<List<ResourceResponse>, ResourceException>newResultPromise(Collections.<ResourceResponse>emptyList()));
// When
Promise<List<List<ResourceResponse>>, ResourceException> promise = graph.update(null, delegate);
// Then
AssertJPromiseAssert.assertThat(promise).succeeded();
assertThat(UmaPolicyUtils.getPolicyScopes(policyUpdated())).containsOnly(VIEW, DELETE);
assertThat(policyDeleted()).isEqualTo("Dave-Ed-false");
verifyNoMoreInteractions(delegate);
}
use of org.forgerock.openam.uma.rest.PolicyGraph in project OpenAM by OpenRock.
the class PolicyGraphTest method makePolicyGraph.
private PolicyGraph makePolicyGraph(List<ResourceResponse> policies) {
PolicyGraph graph = new PolicyGraph(RESOURCE_SET);
for (ResourceResponse policy : policies) {
graph.handleResource(policy);
}
graph.handleResult(Responses.newQueryResponse());
return graph;
}
Aggregations