use of org.apache.jackrabbit.oak.api.ContentRepository in project jackrabbit-oak by apache.
the class OakTest method checkMissingStrategySetting.
@Test(expected = CommitFailedException.class)
public void checkMissingStrategySetting() throws Exception {
Whiteboard wb = new DefaultWhiteboard();
WhiteboardIndexEditorProvider wbProvider = new WhiteboardIndexEditorProvider();
wbProvider.start(wb);
Registration r1 = wb.register(IndexEditorProvider.class, new PropertyIndexEditorProvider(), null);
Registration r2 = wb.register(IndexEditorProvider.class, new ReferenceEditorProvider(), null);
Oak oak = new Oak().with(new OpenSecurityProvider()).with(new InitialContent()).with(wb).with(wbProvider).withFailOnMissingIndexProvider();
ContentRepository repo = oak.createContentRepository();
ContentSession cs = repo.login(null, null);
Root root = cs.getLatestRoot();
Tree t = root.getTree("/");
t.setProperty("foo", "u1", Type.REFERENCE);
r1.unregister();
root.commit();
cs.close();
((Closeable) repo).close();
}
use of org.apache.jackrabbit.oak.api.ContentRepository in project jackrabbit-oak by apache.
the class OakTest method checkExecutorShutdown.
@Test
public void checkExecutorShutdown() throws Exception {
Runnable runnable = new Runnable() {
@Override
public void run() {
}
};
Oak oak = new Oak().with(new OpenSecurityProvider());
ContentRepository repo = oak.createContentRepository();
WhiteboardUtils.scheduleWithFixedDelay(oak.getWhiteboard(), runnable, 1);
((Closeable) repo).close();
try {
WhiteboardUtils.scheduleWithFixedDelay(oak.getWhiteboard(), runnable, 1);
fail("Executor should have rejected the task");
} catch (RejectedExecutionException ignore) {
}
//Externally passed executor should not be shutdown upon repository close
ScheduledExecutorService externalExecutor = Executors.newSingleThreadScheduledExecutor();
Oak oak2 = new Oak().with(new OpenSecurityProvider()).with(externalExecutor);
ContentRepository repo2 = oak2.createContentRepository();
WhiteboardUtils.scheduleWithFixedDelay(oak2.getWhiteboard(), runnable, 1);
((Closeable) repo2).close();
WhiteboardUtils.scheduleWithFixedDelay(oak2.getWhiteboard(), runnable, 1);
externalExecutor.shutdown();
}
use of org.apache.jackrabbit.oak.api.ContentRepository in project jackrabbit-oak by apache.
the class PrivilegeDefinitionReaderTest method testMissingPermissionRoot.
@Test
public void testMissingPermissionRoot() throws Exception {
ContentRepository repo = new Oak().with(new OpenSecurityProvider()).createContentRepository();
Root tmpRoot = repo.login(null, null).getLatestRoot();
try {
PrivilegeDefinitionReader reader = new PrivilegeDefinitionReader(tmpRoot);
assertNull(reader.readDefinition(JCR_READ));
} finally {
tmpRoot.getContentSession().close();
}
}
use of org.apache.jackrabbit.oak.api.ContentRepository in project jackrabbit-oak by apache.
the class UserInitializerTest method testAdminConfiguration.
/**
* @since OAK 1.0 The configuration defines if the password of the
* admin user is being set.
*/
@Test
public void testAdminConfiguration() throws Exception {
Map<String, Object> userParams = new HashMap();
userParams.put(UserConstants.PARAM_ADMIN_ID, "admin");
userParams.put(UserConstants.PARAM_OMIT_ADMIN_PW, true);
ConfigurationParameters params = ConfigurationParameters.of(UserConfiguration.NAME, ConfigurationParameters.of(userParams));
SecurityProvider sp = new SecurityProviderImpl(params);
final ContentRepository repo = new Oak().with(new InitialContent()).with(new PropertyIndexEditorProvider()).with(new PropertyIndexProvider()).with(new TypeEditorProvider()).with(sp).createContentRepository();
ContentSession cs = Subject.doAs(SystemSubject.INSTANCE, new PrivilegedExceptionAction<ContentSession>() {
@Override
public ContentSession run() throws Exception {
return repo.login(null, null);
}
});
try {
Root root = cs.getLatestRoot();
UserConfiguration uc = sp.getConfiguration(UserConfiguration.class);
UserManager umgr = uc.getUserManager(root, NamePathMapper.DEFAULT);
Authorizable adminUser = umgr.getAuthorizable("admin");
assertNotNull(adminUser);
Tree adminTree = root.getTree(adminUser.getPath());
assertTrue(adminTree.exists());
assertNull(adminTree.getProperty(UserConstants.REP_PASSWORD));
} finally {
cs.close();
}
// login as admin should fail
ContentSession adminSession = null;
try {
adminSession = repo.login(new SimpleCredentials("admin", new char[0]), null);
fail();
} catch (LoginException e) {
//success
} finally {
if (adminSession != null) {
adminSession.close();
}
}
}
use of org.apache.jackrabbit.oak.api.ContentRepository in project jackrabbit-oak by apache.
the class L16_RepositoryWithoutUserManagement method testUserManagementDescriptor.
@Test
public void testUserManagementDescriptor() throws RepositoryException {
Oak oak = new Oak().with(new InitialContent()).with(getSecurityProvider());
ContentRepository contentRepository = oak.createContentRepository();
assertFalse(contentRepository.getDescriptors().getValue(JackrabbitRepository.OPTION_USER_MANAGEMENT_SUPPORTED).getBoolean());
}
Aggregations