use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.
the class MutableRootTest method before.
@Before
public void before() {
SecurityProvider sp = new OpenSecurityProvider() {
@Nonnull
@Override
public <T> T getConfiguration(@Nonnull Class<T> configClass) {
if (AuthorizationConfiguration.class == configClass) {
return (T) new OpenAuthorizationConfiguration() {
@Nonnull
@Override
public PermissionProvider getPermissionProvider(@Nonnull Root root, @Nonnull String workspaceName, @Nonnull Set<Principal> principals) {
return permissionProvider;
}
};
} else {
return super.getConfiguration(configClass);
}
}
};
ContentSessionImpl cs = Mockito.mock(ContentSessionImpl.class);
when(cs.toString()).thenReturn("contentSession");
when(cs.getAuthInfo()).thenReturn(AuthInfoImpl.EMPTY);
when(cs.getWorkspaceName()).thenReturn("default");
root = new MutableRoot(store, new EmptyHook(), "default", new Subject(), sp, null, null, cs);
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.
the class AbstractCompositeProviderTest method testGetTreePermissionInstance.
@Test
public void testGetTreePermissionInstance() throws Exception {
PermissionProvider pp = createPermissionProvider();
TreePermission parentPermission = TreePermission.EMPTY;
for (String path : TP_PATHS) {
TreePermission tp = pp.getTreePermission(readOnlyRoot.getTree(path), parentPermission);
assertCompositeTreePermission(tp);
parentPermission = tp;
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.
the class AbstractCompositeProviderTest method testHasPrivilegesNone.
@Test
public void testHasPrivilegesNone() throws Exception {
PermissionProvider pp = createPermissionProvider();
for (String p : NODE_PATHS) {
Tree tree = readOnlyRoot.getTree(p);
assertTrue(p, pp.hasPrivileges(tree));
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.
the class AbstractCompositeProviderTest method testIsNotGrantedAction.
@Test
public void testIsNotGrantedAction() throws Exception {
PermissionProvider pp = createPermissionProvider();
String[] actions = new String[] { JackrabbitSession.ACTION_LOCKING, JackrabbitSession.ACTION_MODIFY_ACCESS_CONTROL };
for (String nodePath : NODE_PATHS) {
String actionStr = getActionString(actions);
assertFalse(nodePath, pp.isGranted(nodePath, actionStr));
String propPath = PathUtils.concat(nodePath, JcrConstants.JCR_PRIMARYTYPE);
assertFalse(propPath, pp.isGranted(propPath, actionStr));
String nonExPath = PathUtils.concat(nodePath, "nonExisting");
assertFalse(nonExPath, pp.isGranted(nonExPath, actionStr));
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider in project jackrabbit-oak by apache.
the class AbstractCompositeProviderTest method testHasPrivilegesOnRepoJcrAll.
@Test
public void testHasPrivilegesOnRepoJcrAll() throws Exception {
PermissionProvider pp = createPermissionProvider();
assertFalse(pp.hasPrivileges(null, JCR_ALL));
}
Aggregations