Search in sources :

Example 31 with PropInfo

use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.

the class AccessControlImporterBaseTest method testImportWithRestrictionNodeInfo.

@Test
public void testImportWithRestrictionNodeInfo() throws Exception {
    // single value restriction
    PropInfo globInfo = new PropInfo(REP_GLOB, PropertyType.STRING, createTextValue("/*"));
    // mv restriction
    PropInfo ntNamesInfo = new PropInfo(REP_NT_NAMES, PropertyType.NAME, createTextValues(NodeTypeConstants.NT_OAK_RESOURCE, NodeTypeConstants.NT_OAK_RESOURCE));
    // mv restriction with singular value
    PropInfo itemNamesInfo = new PropInfo(REP_ITEM_NAMES, PropertyType.NAME, createTextValue("itemName"));
    init();
    importer.start(aclTree);
    importer.startChildInfo(aceGrantInfo, ImmutableList.of(principalInfo, privInfo));
    importer.startChildInfo(restrInfo, ImmutableList.of(globInfo, ntNamesInfo, itemNamesInfo));
    importer.endChildInfo();
    importer.endChildInfo();
    importer.end(aclTree);
    assertImport(aclTree, principalName);
}
Also used : PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 32 with PropInfo

use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.

the class AccessControlImporterBaseTest method testUnknownRestriction.

@Test(expected = ValueFormatException.class)
public void testUnknownRestriction() throws Exception {
    init();
    importer.start(aclTree);
    importer.startChildInfo(aceGrantInfo, ImmutableList.of(principalInfo, privInfo));
    PropInfo invalidRestrProp = new PropInfo("unknown", PropertyType.STRING, createTextValue("val"));
    importer.startChildInfo(restrInfo, ImmutableList.of(invalidRestrProp));
    importer.endChildInfo();
    importer.endChildInfo();
    importer.end(aclTree);
}
Also used : PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 33 with PropInfo

use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.

the class AccessControlImporterIgnoreTest method testImportWithUnknownPrincipal.

@Test
public void testImportWithUnknownPrincipal() throws Exception {
    init();
    importer.start(aclTree);
    PropInfo privs = new PropInfo(REP_PRIVILEGES, PropertyType.NAME, createTextValues(PrivilegeConstants.JCR_READ));
    importer.startChildInfo(aceGrantInfo, ImmutableList.of(unknownPrincipalInfo, privs));
    importer.endChildInfo();
    importer.end(aclTree);
    // ace with invalid principal is ignored with this behaviour => ace tree not imported
    assertFalse(aclTree.getChildren().iterator().hasNext());
}
Also used : PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) Test(org.junit.Test)

Example 34 with PropInfo

use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.

the class UserImporterPasswordTreeTest method testNotRepPassword.

@Test
public void testNotRepPassword() throws Exception {
    pwTree.setProperty(JCR_PRIMARYTYPE, NodeTypeConstants.NT_OAK_UNSTRUCTURED, Type.NAME);
    PropInfo propInfo = mock(PropInfo.class);
    PropertyDefinition propDef = mock(PropertyDefinition.class);
    assertFalse(importer.handlePropInfo(pwTree, propInfo, propDef));
    verify(propInfo, never()).getName();
    verify(propDef, never()).getRequiredType();
}
Also used : PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition) Test(org.junit.Test)

Example 35 with PropInfo

use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.

the class UserImporterPasswordTreeTest method testInvalidPropName2.

@Test
public void testInvalidPropName2() throws Exception {
    PropInfo propInfo = createPropInfo(null, "value");
    PropertyDefinition propDef = when(mock(PropertyDefinition.class).getName()).thenReturn(NodeTypeConstants.RESIDUAL_NAME).getMock();
    assertFalse(importer.handlePropInfo(pwTree, propInfo, propDef));
}
Also used : PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition) Test(org.junit.Test)

Aggregations

PropInfo (org.apache.jackrabbit.oak.spi.xml.PropInfo)37 Test (org.junit.Test)26 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)15 Tree (org.apache.jackrabbit.oak.api.Tree)14 MockUtility.mockTree (org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl.MockUtility.mockTree)8 TextValue (org.apache.jackrabbit.oak.spi.xml.TextValue)8 ArrayList (java.util.ArrayList)5 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)5 RepositoryException (javax.jcr.RepositoryException)4 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)4 SAXException (org.xml.sax.SAXException)4 User (org.apache.jackrabbit.api.security.user.User)3 NodeInfo (org.apache.jackrabbit.oak.spi.xml.NodeInfo)3 ImmutableList (com.google.common.collect.ImmutableList)2 IOException (java.io.IOException)2 List (java.util.List)2 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Reader (java.io.Reader)1 Map (java.util.Map)1