use of org.apache.jackrabbit.oak.InitialContent in project jackrabbit-oak by apache.
the class ChangeCollectorProviderTest method setup.
@Before
public void setup() throws PrivilegedActionException, CommitFailedException {
collectorProvider = new ChangeCollectorProvider();
recorder = new Recorder();
Oak oak = new Oak().with(new InitialContent()).with(collectorProvider).with(recorder).with(getSecurityProvider());
contentRepository = oak.createContentRepository();
session = Subject.doAs(SystemSubject.INSTANCE, new PrivilegedExceptionAction<ContentSession>() {
@Override
public ContentSession run() throws LoginException, NoSuchWorkspaceException {
return contentRepository.login(null, null);
}
});
Root root = session.getLatestRoot();
Tree rootTree = root.getTree("/").addChild("test");
rootTree.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:parentType", Type.NAME);
Tree child1 = rootTree.addChild("child1");
child1.setProperty("child1Prop", 1);
child1.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:childType", Type.NAME);
Tree grandChild1 = child1.addChild("grandChild1");
grandChild1.setProperty("grandChild1Prop", 1);
grandChild1.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:grandChildType", Type.NAME);
Tree greatGrandChild1 = grandChild1.addChild("greatGrandChild1");
greatGrandChild1.setProperty("greatGrandChild1Prop", 1);
greatGrandChild1.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:greatGrandChildType", Type.NAME);
Tree child2 = rootTree.addChild("child2");
child2.setProperty("child2Prop", 1);
child2.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:childType", Type.NAME);
Tree grandChild2 = child2.addChild("grandChild2");
grandChild2.setProperty("grandChild2Prop", 1);
grandChild2.setProperty(JcrConstants.JCR_PRIMARYTYPE, "test:grandChildType", Type.NAME);
recorder.changes.clear();
root.commit();
ChangeSet changeSet = getSingleChangeSet();
assertMatches("parentPaths", changeSet.getParentPaths(), "/test/child2", "/test/child1", "/test/child1/grandChild1/greatGrandChild1", "/", "/test", "/test/child1/grandChild1", "/test/child2/grandChild2");
assertMatches("parentNodeNames", changeSet.getParentNodeNames(), "child2", "child1", "greatGrandChild1", "test", "grandChild1", "grandChild2");
assertMatches("parentNodeTypes", changeSet.getParentNodeTypes(), "test:parentType", "test:childType", "test:grandChildType", "test:greatGrandChildType");
assertMatches("allNodeTypes", changeSet.getAllNodeTypes(), "test:parentType", "test:childType", "test:grandChildType", "test:greatGrandChildType");
assertMatches("propertyNames", changeSet.getPropertyNames(), JcrConstants.JCR_PRIMARYTYPE, "child1Prop", "child2Prop", "grandChild1Prop", "grandChild2Prop", "greatGrandChild1Prop");
// clear the recorder so that we start off empty
recorder.changes.clear();
}
use of org.apache.jackrabbit.oak.InitialContent 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.InitialContent in project jackrabbit-oak by apache.
the class UserProviderTest method setUp.
@Before
public void setUp() throws Exception {
root = new Oak().with(new OpenSecurityProvider()).with(new InitialContent()).with(new PropertyIndexEditorProvider()).createRoot();
defaultConfig = ConfigurationParameters.EMPTY;
defaultUserPath = defaultConfig.getConfigValue(UserConstants.PARAM_USER_PATH, UserConstants.DEFAULT_USER_PATH);
defaultGroupPath = defaultConfig.getConfigValue(UserConstants.PARAM_GROUP_PATH, UserConstants.DEFAULT_GROUP_PATH);
customOptions = new HashMap<String, Object>();
customOptions.put(UserConstants.PARAM_GROUP_PATH, customGroupPath);
customOptions.put(UserConstants.PARAM_USER_PATH, customUserPath);
}
use of org.apache.jackrabbit.oak.InitialContent 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());
}
use of org.apache.jackrabbit.oak.InitialContent in project jackrabbit-oak by apache.
the class PrivateStoreValidatorProviderTest method setUp.
private void setUp(String... readOnlyPaths) {
configureMountInfoProvider(readOnlyPaths);
repository = new Oak().with(new OpenSecurityProvider()).with(new InitialContent()).with(privateStoreValidatorProvider).createContentRepository();
}
Aggregations