Ejemplo n.º 1
0
  public void testGetOrCreateAcl() {
    // create ACL with name ACL.LOCAL_ACL
    ACL createdAcl = acp.getOrCreateACL();
    createdAcl.add(new ACE("john", "Sing", true));
    createdAcl.add(new ACE("anne", "Joke", false));

    // check that the ACP has already been affected by the ACL editing
    assertTrue(acp.getAccess("john", "Sing").toBoolean());
    assertFalse(acp.getAccess("anne", "Joke").toBoolean());

    // check that by fetching the acl again we get the same instance
    ACL fetchedAcl = acp.getOrCreateACL();
    assertEquals(createdAcl, fetchedAcl);
    assertTrue(acp.getAccess("john", "Sing").toBoolean());
    assertFalse(acp.getAccess("anne", "Joke").toBoolean());

    // check that setting the same ACL again does not clear it
    acp.addACL(fetchedAcl);
    assertEquals(createdAcl, fetchedAcl);
    assertTrue(acp.getAccess("john", "Sing").toBoolean());
    assertFalse(acp.getAccess("anne", "Joke").toBoolean());

    // check that setting an empty ACL with the same name clear the
    // permissions
    acp.addACL(new ACLImpl(ACL.LOCAL_ACL));
    assertFalse(acp.getAccess("john", "Sing").toBoolean());
  }