| 104 | | assertEquals(Access.UNKNOWN, acp.getAccess("joe", SecurityConstants.RESTRICTED_READ)); |
|---|
| 105 | | assertEquals(Access.UNKNOWN, acp.getAccess("jack", SecurityConstants.READ)); |
|---|
| | 104 | assertEquals(Access.UNKNOWN, acp.getAccess("joe", |
|---|
| | 105 | SecurityConstants.RESTRICTED_READ)); |
|---|
| | 106 | assertEquals(Access.UNKNOWN, acp.getAccess("jack", |
|---|
| | 107 | SecurityConstants.READ)); |
|---|
| | 138 | public void testGetOrCreateAcl() { |
|---|
| | 139 | // create ACL with name ACL.LOCAL_ACL |
|---|
| | 140 | ACL createdAcl = acp.getOrCreateACL(); |
|---|
| | 141 | createdAcl.add(new ACE("john", "Sing", true)); |
|---|
| | 142 | createdAcl.add(new ACE("anne", "Joke", false)); |
|---|
| | 143 | |
|---|
| | 144 | // check that the ACP has already been affected by the ACL editing |
|---|
| | 145 | assertTrue(acp.getAccess("john", "Sing").toBoolean()); |
|---|
| | 146 | assertFalse(acp.getAccess("anne", "Joke").toBoolean()); |
|---|
| | 147 | |
|---|
| | 148 | // check that by fetching the acl again we get the same instance |
|---|
| | 149 | ACL fetchedAcl = acp.getOrCreateACL(); |
|---|
| | 150 | assertEquals(createdAcl, fetchedAcl); |
|---|
| | 151 | assertTrue(acp.getAccess("john", "Sing").toBoolean()); |
|---|
| | 152 | assertFalse(acp.getAccess("anne", "Joke").toBoolean()); |
|---|
| | 153 | |
|---|
| | 154 | // check that setting the same ACL again does not clear it |
|---|
| | 155 | acp.addACL(fetchedAcl); |
|---|
| | 156 | assertEquals(createdAcl, fetchedAcl); |
|---|
| | 157 | assertTrue(acp.getAccess("john", "Sing").toBoolean()); |
|---|
| | 158 | assertFalse(acp.getAccess("anne", "Joke").toBoolean()); |
|---|
| | 159 | |
|---|
| | 160 | // check that setting an empty ACL with the same name clear the |
|---|
| | 161 | // permissions |
|---|
| | 162 | acp.addACL(new ACLImpl(ACL.LOCAL_ACL)); |
|---|
| | 163 | assertFalse(acp.getAccess("john", "Sing").toBoolean()); |
|---|
| | 164 | } |
|---|
| | 165 | |
|---|