use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class LoginModuleImplTest method testNullLogin.
@Test
public void testNullLogin() throws Exception {
ContentSession cs = null;
try {
cs = login(null);
fail("Null login should fail");
} catch (LoginException e) {
// success
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class LoginModuleImplTest method testSelfImpersonation.
@Test
public void testSelfImpersonation() throws Exception {
ContentSession cs = null;
try {
createTestUser();
SimpleCredentials sc = new SimpleCredentials(USER_ID, USER_PW.toCharArray());
cs = login(sc);
AuthInfo authInfo = cs.getAuthInfo();
assertEquals(USER_ID, authInfo.getUserID());
cs.close();
sc = new SimpleCredentials(USER_ID, new char[0]);
ImpersonationCredentials ic = new ImpersonationCredentials(sc, authInfo);
cs = login(ic);
authInfo = cs.getAuthInfo();
assertEquals(USER_ID, authInfo.getUserID());
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class LoginModuleImplTest method testAnonymousLogin.
@Test
public void testAnonymousLogin() throws Exception {
String anonymousID = UserUtil.getAnonymousId(getUserConfiguration().getParameters());
UserManager userMgr = getUserManager(root);
// verify initial user-content looks like expected
Authorizable anonymous = userMgr.getAuthorizable(anonymousID);
assertNotNull(anonymous);
assertFalse(root.getTree(anonymous.getPath()).hasProperty(UserConstants.REP_PASSWORD));
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(anonymousID, new char[0]));
fail("Login with anonymousID should fail since the initial setup doesn't provide a password.");
} catch (LoginException e) {
// success
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class CugEvaluationTest method testReadAcl2.
@Test
public void testReadAcl2() throws Exception {
ContentSession cs = createTestSession2();
try {
Root r = cs.getLatestRoot();
assertTrue(r.getTree("/content/rep:policy").exists());
} finally {
cs.close();
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class CugEvaluationTest method testWriteCug.
@Test
public void testWriteCug() throws Exception {
ContentSession cs = createTestSession2();
Root r = cs.getLatestRoot();
try {
// modify the existing cug
Tree tree = r.getTree("/content/a/rep:cugPolicy");
tree.setProperty(REP_PRINCIPAL_NAMES, ImmutableList.of(EveryonePrincipal.NAME, testGroupPrincipal.getName()), Type.STRINGS);
r.commit();
fail();
} catch (CommitFailedException e) {
assertTrue(e.isAccessViolation());
} finally {
r.refresh();
}
}
Aggregations