Search in sources :

Example 1 with TestACL

use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.TestACL in project jackrabbit-oak by apache.

the class AccessControlManagerImplTest method testSetInvalidPolicy.

@Test
public void testSetInvalidPolicy() throws Exception {
    try {
        acMgr.setPolicy(testPath, new TestACL(testPath, getRestrictionProvider(), getNamePathMapper()));
        fail("Setting invalid policy must fail");
    } catch (AccessControlException e) {
    // success
    }
    ACL acl = setupPolicy(testPath);
    try {
        acMgr.setPolicy(testPath, new TestACL(testPath, getRestrictionProvider(), getNamePathMapper()));
        fail("Setting invalid policy must fail");
    } catch (AccessControlException e) {
    // success
    }
    ACL repoAcl = setupPolicy(null);
    try {
        acMgr.setPolicy(testPath, repoAcl);
        fail("Setting invalid policy must fail");
    } catch (AccessControlException e) {
    // success
    }
    try {
        acMgr.setPolicy(null, acl);
        fail("Setting invalid policy must fail");
    } catch (AccessControlException e) {
    // success
    }
}
Also used : TestACL(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.TestACL) AccessControlException(javax.jcr.security.AccessControlException) TestACL(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.TestACL) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 2 with TestACL

use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.TestACL in project jackrabbit-oak by apache.

the class AccessControlManagerImplTest method testRemoveInvalidPolicy.

@Test
public void testRemoveInvalidPolicy() throws Exception {
    ACL acl = setupPolicy(testPath);
    try {
        acMgr.removePolicy(testPath, new TestACL(testPath, getRestrictionProvider(), getNamePathMapper()));
        fail("Invalid policy -> removal must fail");
    } catch (AccessControlException e) {
    // success
    }
    ACL repoAcl = setupPolicy(null);
    try {
        acMgr.removePolicy(testPath, repoAcl);
        fail("Setting invalid policy must fail");
    } catch (AccessControlException e) {
    // success
    }
    try {
        acMgr.removePolicy(null, acl);
        fail("Setting invalid policy must fail");
    } catch (AccessControlException e) {
    // success
    }
}
Also used : TestACL(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.TestACL) AccessControlException(javax.jcr.security.AccessControlException) TestACL(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.TestACL) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

AccessControlException (javax.jcr.security.AccessControlException)2 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)2 TestACL (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.TestACL)2 Test (org.junit.Test)2