use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.
the class ReadPropertyTest method testGetParent.
@Test
public void testGetParent() throws Exception {
deny(path, privilegesFromName(PrivilegeConstants.REP_READ_NODES));
List<String> propertyPaths = new ArrayList<String>();
propertyPaths.add(childPPath);
propertyPaths.add(childchildPPath);
propertyPaths.add(path + "/jcr:primaryType");
for (String pPath : propertyPaths) {
Property p = testSession.getProperty(pPath);
try {
Node n = p.getParent();
fail();
} catch (AccessDeniedException e) {
// success
}
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.
the class IndexManagementTest method testAddIndexDefinitionWithoutPermission.
public void testAddIndexDefinitionWithoutPermission() throws Exception {
superuser.getNode(path).addNode(IndexConstants.INDEX_DEFINITIONS_NAME);
superuser.save();
allow(path, privilegesFromName(PrivilegeConstants.REP_WRITE));
try {
Node n = testSession.getNode(path).getNode(IndexConstants.INDEX_DEFINITIONS_NAME).addNode("myIndex", IndexConstants.INDEX_DEFINITIONS_NODE_TYPE);
n.setProperty(IndexConstants.TYPE_PROPERTY_NAME, "myType");
testSession.save();
fail("AccessDeniedException expected. Test session is not allowed to add index definition node.");
} catch (AccessDeniedException e) {
// success
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.
the class IndexManagementTest method testRemoveOakIndexWithoutPermission.
public void testRemoveOakIndexWithoutPermission() throws Exception {
Node indexDef = superuser.getNode(path).addNode(IndexConstants.INDEX_DEFINITIONS_NAME).addNode("myIndex", IndexConstants.INDEX_DEFINITIONS_NODE_TYPE);
indexDef.setProperty(IndexConstants.TYPE_PROPERTY_NAME, "myType");
superuser.save();
allow(path, privilegesFromName(PrivilegeConstants.REP_WRITE));
try {
Node n = testSession.getNode(path).getNode(IndexConstants.INDEX_DEFINITIONS_NAME);
n.remove();
testSession.save();
fail("AccessDeniedException expected. Test session is not allowed to remove oak:index.");
} catch (AccessDeniedException e) {
// success
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.
the class IndexManagementTest method testVersionableIndexDefinition.
public void testVersionableIndexDefinition() throws Exception {
allow(path, privilegesFromNames(new String[] { PrivilegeConstants.REP_INDEX_DEFINITION_MANAGEMENT, PrivilegeConstants.JCR_NODE_TYPE_MANAGEMENT }));
try {
Node n = testSession.getNode(path).addNode(IndexConstants.INDEX_DEFINITIONS_NAME).addNode("myIndex", IndexConstants.INDEX_DEFINITIONS_NODE_TYPE);
n.setProperty(IndexConstants.TYPE_PROPERTY_NAME, "myType");
n.addMixin(JcrConstants.MIX_VERSIONABLE);
testSession.save();
fail("Missing rep:versionManagement privilege");
} catch (AccessDeniedException e) {
// success
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.
the class NamespaceManagementTest method testRegisterNamespace.
@Test
public void testRegisterNamespace() throws Exception {
try {
Workspace testWsp = testSession.getWorkspace();
testWsp.getNamespaceRegistry().registerNamespace(getNewNamespacePrefix(testWsp), getNewNamespaceURI(testWsp));
fail("Namespace registration should be denied.");
} catch (AccessDeniedException e) {
// success
}
}
Aggregations