Search in sources :

Example 26 with PropInfo

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

the class PrincipalPolicyImporterTest method testHandlePropInfoOakDeclaringNtName.

@Test
public void testHandlePropInfoOakDeclaringNtName() throws Exception {
    init(false, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
    Tree tree = mockTree(REP_PRINCIPAL_POLICY, NT_REP_PRINCIPAL_POLICY, true);
    PropInfo propInfo = mockPropInfo(getJcrName(REP_PRINCIPAL_NAME));
    PropertyDefinition def = mockPropertyDefinition(NT_REP_PRINCIPAL_POLICY);
    assertFalse(importer.handlePropInfo(tree, propInfo, def));
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) MockUtility.mockTree(org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl.MockUtility.mockTree) PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition) Test(org.junit.Test)

Example 27 with PropInfo

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

the class PrincipalPolicyImporterTest method testHandlePropInfoDefinitionMultiple.

@Test
public void testHandlePropInfoDefinitionMultiple() throws Exception {
    init(false, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
    Tree tree = mockTree(REP_PRINCIPAL_POLICY, NT_REP_PRINCIPAL_POLICY, true);
    PropInfo propInfo = mockPropInfo(getJcrName(REP_PRINCIPAL_NAME));
    PropertyDefinition def = when(mock(PropertyDefinition.class).isMultiple()).thenReturn(true).getMock();
    assertFalse(importer.handlePropInfo(tree, propInfo, def));
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) MockUtility.mockTree(org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl.MockUtility.mockTree) PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) PropertyDefinition(javax.jcr.nodetype.PropertyDefinition) Test(org.junit.Test)

Example 28 with PropInfo

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

the class PrincipalPolicyImporterTest method testStartChildInfoUnsupportedProperty.

@Test(expected = ConstraintViolationException.class)
public void testStartChildInfoUnsupportedProperty() throws Exception {
    init(true, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING);
    User user = getTestSystemUser();
    Tree policyTree = createPolicyTree(user);
    importer.handlePropInfo(policyTree, mockPropInfo(user.getPrincipal()), mockPropertyDefinition(getJcrName(NT_REP_PRINCIPAL_POLICY)));
    List<PropInfo> propInfos = mockPropInfos("/effective/path", PrivilegeConstants.JCR_REMOVE_CHILD_NODES);
    propInfos.add(mockPropInfo("unsupportedProperty"));
    importer.startChildInfo(mockNodeInfo("entry", getJcrName(NT_REP_PRINCIPAL_ENTRY)), propInfos);
}
Also used : User(org.apache.jackrabbit.api.security.user.User) Tree(org.apache.jackrabbit.oak.api.Tree) MockUtility.mockTree(org.apache.jackrabbit.oak.spi.security.authorization.principalbased.impl.MockUtility.mockTree) PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo) Test(org.junit.Test)

Example 29 with PropInfo

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

the class PrincipalPolicyImporterTest method mockPropInfo.

private PropInfo mockPropInfo(@NotNull Principal principal) throws RepositoryException {
    TextValue tx = when(mock(TextValue.class).getString()).thenReturn(principal.getName()).getMock();
    PropInfo propInfo = mockPropInfo(getJcrName(REP_PRINCIPAL_NAME));
    when(propInfo.getTextValue()).thenReturn(tx);
    return propInfo;
}
Also used : TextValue(org.apache.jackrabbit.oak.spi.xml.TextValue) PropInfo(org.apache.jackrabbit.oak.spi.xml.PropInfo)

Example 30 with PropInfo

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

the class AccessControlImporterBaseTest method testImportWithRestrictions.

@Test
public void testImportWithRestrictions() 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, globInfo, ntNamesInfo, itemNamesInfo));
    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)

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