Exemplo n.º 1
0
  @Test(expectedExceptions = IllegalStateException.class)
  public void shouldRequireComputeGraphCall() throws Exception {
    // Given
    PolicyGraph graph = new PolicyGraph(RESOURCE_SET);

    // When
    graph.isValid();
  }
Exemplo n.º 2
0
  @Test
  public void shouldDetectValidRights() throws Exception {
    // Given
    List<Resource> policies = VALID_POLICIES;
    PolicyGraph graph = makePolicyGraph(policies);

    // When
    graph.computeGraph();

    // Then
    assertThat(graph.isValid()).isTrue();
  }
Exemplo n.º 3
0
  /*
   VIEW scope is accessible to Dave, so his VIEW reshare to Ed should be active, not inactive.
  */
  @Test
  public void shouldDetectInvalidRightsTree() throws Exception {
    // Given
    List<Resource> policies = excludePolicies(DAVE, ED);
    policies.add(makePolicy(DAVE, ED, true, DELETE));
    policies.add(makePolicy(DAVE, ED, false, VIEW));

    PolicyGraph graph = makePolicyGraph(policies);

    // When
    graph.computeGraph();

    // Then
    assertThat(graph.isValid()).isFalse();
  }