Exemplo n.º 1
0
  public void testCheckAccess() {
    ACL acl1 = new ACLImpl("acl1");
    ACE ace1 = new ACE("joe", EVERYTHING, true);
    acl1.add(ace1);
    acp.addACL(acl1);

    assertSame(GRANT, acp.getAccess("joe", READ));
    assertSame(UNKNOWN, acp.getAccess("joe", RESTRICTED_READ));
    assertSame(UNKNOWN, acp.getAccess("jack", READ));
  }
Exemplo n.º 2
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());
  }