use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit by apache.
the class AbstractACLTemplateTest method testGetPath.
public void testGetPath() throws RepositoryException {
JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
assertEquals(getTestPath(), pt.getPath());
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit by apache.
the class AbstractACLTemplateTest method testRemoveInvalidEntry2.
public void testRemoveInvalidEntry2() throws RepositoryException {
JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
try {
pt.removeAccessControlEntry(new JackrabbitAccessControlEntry() {
public boolean isAllow() {
return false;
}
public int getPrivilegeBits() {
return 0;
}
public String[] getRestrictionNames() {
return new String[0];
}
public Value getRestriction(String restrictionName) {
return null;
}
public Value[] getRestrictions(String restrictionName) throws RepositoryException {
return null;
}
public Principal getPrincipal() {
return testPrincipal;
}
public Privilege[] getPrivileges() {
return new Privilege[0];
}
});
fail("Passing a ACE with invalid privileges should fail");
} catch (AccessControlException e) {
// success
}
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit by apache.
the class AbstractACLTemplateTest method testRemoveEntry.
public void testRemoveEntry() throws RepositoryException, NotExecutableException {
JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
pt.addAccessControlEntry(testPrincipal, privilegesFromName(Privilege.JCR_READ));
pt.removeAccessControlEntry(pt.getAccessControlEntries()[0]);
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit by apache.
the class AbstractACLTemplateTest method testAddInvalidEntry.
public void testAddInvalidEntry() throws RepositoryException, NotExecutableException {
Principal unknownPrincipal;
if (!principalMgr.hasPrincipal("an unknown principal")) {
unknownPrincipal = new TestPrincipal("an unknown principal");
} else {
throw new NotExecutableException();
}
JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
try {
pt.addAccessControlEntry(unknownPrincipal, privilegesFromName(Privilege.JCR_READ));
fail("Adding an ACE with an unknown principal should fail");
} catch (AccessControlException e) {
// success
}
}
use of org.apache.jackrabbit.api.security.JackrabbitAccessControlList in project jackrabbit by apache.
the class AbstractACLTemplateTest method testAddEntry.
public void testAddEntry() throws RepositoryException, NotExecutableException {
JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
Privilege[] privs = privilegesFromName(Privilege.JCR_READ);
assertTrue(pt.addEntry(testPrincipal, privs, true, Collections.<String, Value>emptyMap()));
}
Aggregations