Search in sources :

Example 16 with NamePathMapper

use of org.apache.jackrabbit.oak.namepath.NamePathMapper in project jackrabbit-oak by apache.

the class AbstractAccessControlListTest method testGetOakPath.

@Test
public void testGetOakPath() {
    NamePathMapper npMapper = new NamePathMapperImpl(new LocalNameMapper(singletonMap("oak", "http://jackrabbit.apache.org"), singletonMap("jcr", "http://jackrabbit.apache.org")));
    // map of jcr-path to oak path
    Map<String, String> paths = new HashMap<String, String>();
    paths.put(null, null);
    paths.put(getTestPath(), getTestPath());
    paths.put("/", "/");
    String oakPath = "/oak:testPath";
    String jcrPath = "/jcr:testPath";
    paths.put(jcrPath, oakPath);
    jcrPath = "/{http://jackrabbit.apache.org}testPath";
    paths.put(jcrPath, oakPath);
    // test if oak-path is properly set.
    for (String path : paths.keySet()) {
        AbstractAccessControlList acl = createACL(path, Collections.<JackrabbitAccessControlEntry>emptyList(), npMapper);
        assertEquals(paths.get(path), acl.getOakPath());
    }
}
Also used : HashMap(java.util.HashMap) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.NamePathMapperImpl) LocalNameMapper(org.apache.jackrabbit.oak.namepath.LocalNameMapper) Test(org.junit.Test)

Example 17 with NamePathMapper

use of org.apache.jackrabbit.oak.namepath.NamePathMapper in project jackrabbit-oak by apache.

the class PrivilegeBitsProviderTest method testGetBitsFromPrivilegesInvalidMapping.

@Test
public void testGetBitsFromPrivilegesInvalidMapping() {
    Privilege p = Mockito.mock(Privilege.class);
    when(p.getName()).thenReturn("name");
    NamePathMapper mapper = new NamePathMapper.Default() {

        @Nonnull
        @Override
        public String getOakName(@Nonnull String jcrName) throws RepositoryException {
            throw new RepositoryException();
        }
    };
    assertSame(PrivilegeBits.EMPTY, bitsProvider.getBits(new Privilege[] { p }, mapper));
}
Also used : Nonnull(javax.annotation.Nonnull) NamePathMapper(org.apache.jackrabbit.oak.namepath.NamePathMapper) RepositoryException(javax.jcr.RepositoryException) Privilege(javax.jcr.security.Privilege) Test(org.junit.Test)

Aggregations

NamePathMapper (org.apache.jackrabbit.oak.namepath.NamePathMapper)17 Test (org.junit.Test)13 NamePathMapperImpl (org.apache.jackrabbit.oak.namepath.NamePathMapperImpl)12 LocalNameMapper (org.apache.jackrabbit.oak.namepath.LocalNameMapper)11 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)6 HashMap (java.util.HashMap)4 Privilege (javax.jcr.security.Privilege)3 Tree (org.apache.jackrabbit.oak.api.Tree)3 GlobalNameMapper (org.apache.jackrabbit.oak.namepath.GlobalNameMapper)3 Nonnull (javax.annotation.Nonnull)2 PrivilegeManager (org.apache.jackrabbit.api.security.authorization.PrivilegeManager)2 NameMapper (org.apache.jackrabbit.oak.namepath.NameMapper)2 AbstractAccessControlList (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList)2 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1 RepositoryException (javax.jcr.RepositoryException)1 NodeType (javax.jcr.nodetype.NodeType)1 NodeTypeIteratorAdapter (org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter)1 Root (org.apache.jackrabbit.oak.api.Root)1