use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class ExternalLoginModuleTest method testSyncCreateGroup.
@Test
public void testSyncCreateGroup() throws Exception {
UserManager userManager = getUserManager(root);
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(USER_ID, new char[0]));
root.refresh();
for (String id : new String[] { "a", "b", "c" }) {
assertNotNull(userManager.getAuthorizable(id));
}
for (String id : new String[] { "aa", "aaa" }) {
assertNull(userManager.getAuthorizable(id));
}
} finally {
if (cs != null) {
cs.close();
}
options.clear();
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class ExternalLoginModuleFactoryTest method testSyncCreateUser.
//~-------------------------------------------------------------< tests >---
@Test
public void testSyncCreateUser() throws Exception {
setUpJaasFactoryWithInjection();
UserManager userManager = getUserManager(root);
ContentSession cs = null;
try {
assertNull(userManager.getAuthorizable(USER_ID));
cs = login(new SimpleCredentials(USER_ID, new char[0]));
root.refresh();
Authorizable a = userManager.getAuthorizable(USER_ID);
assertNotNull(a);
ExternalUser user = idp.getUser(USER_ID);
for (String prop : user.getProperties().keySet()) {
assertTrue(a.hasProperty(prop));
}
assertEquals(TEST_CONSTANT_PROPERTY_VALUE, a.getProperty(TEST_CONSTANT_PROPERTY_NAME)[0].getString());
} finally {
if (cs != null) {
cs.close();
}
options.clear();
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class TokenExternalLoginModuleTest method testTokenLogin.
@Test
public void testTokenLogin() throws Exception {
Credentials creds = createTestCredentials();
assertTrue(credentialsSupport.setAttributes(creds, ImmutableMap.<String, Object>of(".token", "")));
String expectedUserId = credentialsSupport.getUserId(creds);
ContentSession cs = login(creds);
try {
String token = credentialsSupport.getAttributes(creds).get(".token").toString();
cs.close();
cs = login(new TokenCredentials(token));
assertEquals(expectedUserId, cs.getAuthInfo().getUserID());
} finally {
cs.close();
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class CugEvaluationTest method testReadCug2.
@Test
public void testReadCug2() throws Exception {
ContentSession cs = createTestSession2();
try {
Root r = cs.getLatestRoot();
assertTrue(r.getTree("/content/a/rep:cugPolicy").exists());
assertFalse(r.getTree("/content2/rep:cugPolicy").exists());
} finally {
cs.close();
}
}
use of org.apache.jackrabbit.oak.api.ContentSession in project jackrabbit-oak by apache.
the class CugEvaluationTest method testWrite2.
@Test
public void testWrite2() throws Exception {
ContentSession cs = createTestSession2();
Root r = cs.getLatestRoot();
try {
PermissionProvider pp = createPermissionProvider(cs);
assertTrue(pp.isGranted(root.getTree("/content/writeTest"), null, Permissions.ADD_NODE));
assertTrue(pp.isGranted(root.getTree("/content/a/b/c/writeTest"), null, Permissions.ADD_NODE));
List<String> paths = ImmutableList.of("/content", "/content/a/b/c");
for (String p : paths) {
NodeUtil content = new NodeUtil(r.getTree(p));
content.addChild("writeTest", NT_OAK_UNSTRUCTURED);
r.commit();
}
} finally {
r.refresh();
cs.close();
}
}
Aggregations