use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class PermissionTest method testProtectPropertiesByRestriction.
/**
* Tests the custom restriction provider that checks on the existence of a property.
* @throws Exception
*/
@Test
public void testProtectPropertiesByRestriction() throws Exception {
// create permissions
// allow rep:write /testroot
// deny jcr:modifyProperties /testroot/a glob = */c
addEntry(TEST_ROOT_PATH, true, "", PrivilegeConstants.JCR_READ, PrivilegeConstants.REP_WRITE);
addEntry(TEST_A_PATH, false, "*/c", PrivilegeConstants.JCR_MODIFY_PROPERTIES);
ContentSession testSession = createTestSession();
try {
Root testRoot = testSession.getLatestRoot();
PermissionProvider pp = getPermissionProvider(testSession);
assertIsGranted(pp, testRoot, true, TEST_A_PATH, Permissions.MODIFY_PROPERTY);
assertIsGranted(pp, testRoot, true, TEST_B_PATH, Permissions.MODIFY_PROPERTY);
assertIsGranted(pp, testRoot, false, TEST_C_PATH, Permissions.MODIFY_PROPERTY);
assertIsGranted(pp, testRoot, true, TEST_D_PATH, Permissions.MODIFY_PROPERTY);
assertIsGranted(pp, testRoot, true, TEST_E_PATH, Permissions.MODIFY_PROPERTY);
} finally {
testSession.close();
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class ExternalPrincipalConfigurationTest method testGetValidatorsOmitIdProtection.
@Test
public void testGetValidatorsOmitIdProtection() throws Exception {
principalConfiguration.setParameters(ConfigurationParameters.of(ExternalIdentityConstants.PARAM_PROTECT_EXTERNAL_IDS, false));
ContentSession cs = root.getContentSession();
List<? extends ValidatorProvider> validatorProviders = principalConfiguration.getValidators(cs.getWorkspaceName(), cs.getAuthInfo().getPrincipals(), new MoveTracker());
assertFalse(validatorProviders.isEmpty());
assertEquals(1, validatorProviders.size());
assertTrue(validatorProviders.get(0) instanceof ExternalIdentityValidatorProvider);
enable();
validatorProviders = principalConfiguration.getValidators(cs.getWorkspaceName(), cs.getAuthInfo().getPrincipals(), new MoveTracker());
assertFalse(validatorProviders.isEmpty());
assertEquals(1, validatorProviders.size());
assertTrue(validatorProviders.get(0) instanceof ExternalIdentityValidatorProvider);
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class DefaultConflictHandlerOursTest method setUp.
@Before
public void setUp() throws CommitFailedException {
ContentSession session = new Oak().with(new OpenSecurityProvider()).with(DefaultConflictHandler.OURS).createContentSession();
// Add test content
Root root = session.getLatestRoot();
Tree tree = root.getTree("/");
tree.setProperty("a", 1);
tree.setProperty("b", 2);
tree.setProperty("c", 3);
tree.addChild("x");
tree.addChild("y");
tree.addChild("z");
root.commit();
ourRoot = session.getLatestRoot();
theirRoot = session.getLatestRoot();
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class CompositeProviderNoScopeTest method before.
@Override
public void before() throws Exception {
super.before();
ContentSession cs = root.getContentSession();
Set<Principal> testPrincipals = ImmutableSet.of(getTestUser().getPrincipal(), EveryonePrincipal.getInstance());
cppTestUser = createPermissionProvider(testPrincipals);
defTestUser = getConfig(AuthorizationConfiguration.class).getPermissionProvider(root, cs.getWorkspaceName(), testPrincipals);
Set<Principal> adminPrincipals = cs.getAuthInfo().getPrincipals();
cppAdminUser = createPermissionProvider(adminPrincipals);
defAdminUser = getConfig(AuthorizationConfiguration.class).getPermissionProvider(root, cs.getWorkspaceName(), adminPrincipals);
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class DefaultLdapLoginModuleTest method testGuestLogin.
/**
* Login with {@link javax.jcr.GuestCredentials} must succeed and result in
* an guest session as the SUFFICIENT
* {@link org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl}
* handles the guest login (in contrast to the ExternalLoginModule).
*
* @throws Exception
*/
@Test
public void testGuestLogin() throws Exception {
ContentSession cs = login(new GuestCredentials());
assertEquals(UserConstants.DEFAULT_ANONYMOUS_ID, cs.getAuthInfo().getUserID());
cs.close();
}
Aggregations