use of org.apache.jackrabbit.core.security.TestPrincipal in project jackrabbit by apache.
the class EntryCollectorTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
// create some nodes below the test root in order to apply ac-stuff
Node node = testRootNode.addNode(nodeName1, testNodeType);
Node cn1 = node.addNode(nodeName2, testNodeType);
superuser.save();
path = node.getPath();
childNPath = cn1.getPath();
// create the testGroup
UserManager umgr = getUserManager(superuser);
Principal groupPrincipal = new TestPrincipal("testGroup" + UUID.randomUUID());
testGroup = umgr.createGroup(groupPrincipal);
testUser = umgr.createUser("testUser" + UUID.randomUUID(), "pw");
if (!umgr.isAutoSave() && superuser.hasPendingChanges()) {
superuser.save();
}
}
use of org.apache.jackrabbit.core.security.TestPrincipal in project jackrabbit by apache.
the class ConcurrentCreateUserTest method testCreateUsers.
public void testCreateUsers() throws Exception {
log.println("ConcurrentCreateUserTest.testCreateUsers: c=" + CONCURRENCY);
log.flush();
runTask(new Task() {
public void execute(Session session, Node test) throws RepositoryException {
JackrabbitSession s = null;
try {
s = (JackrabbitSession) getHelper().getSuperuserSession();
String name = "newname-" + UUID.randomUUID();
Authorizable authorizable = null;
int maxtries = RETRIES;
RepositoryException lastex = null;
while (authorizable == null && maxtries > 0) {
try {
maxtries -= 1;
authorizable = s.getUserManager().createUser(name, "password1", new TestPrincipal(name), INTERMEDIATE_PATH);
s.save();
} catch (InvalidItemStateException ex) {
lastex = ex;
log.println("got " + ex + ", retrying");
}
}
if (authorizable == null) {
throw new RepositoryException("user " + name + " not created in " + RETRIES + " attempts.", lastex);
}
userIDs.add(authorizable.getID());
log.println(authorizable + " created");
} finally {
s.logout();
}
}
}, CONCURRENCY, "/" + testPath);
}
use of org.apache.jackrabbit.core.security.TestPrincipal in project jackrabbit by apache.
the class UserManagerImplTest method testCreateGroupWithInvalidIdOrPrincipal.
public void testCreateGroupWithInvalidIdOrPrincipal() throws RepositoryException, NotExecutableException {
Principal p = getTestPrincipal();
String uid = p.getName();
Map<String, Principal> fail = new HashMap<String, Principal>();
fail.put(uid, null);
fail.put(uid, new TestPrincipal(""));
fail.put(null, p);
fail.put("", p);
for (String id : fail.keySet()) {
Group g = null;
try {
Principal princ = fail.get(id);
g = userMgr.createGroup(id, princ, null);
fail("Creating group with id '" + id + "' and principal '" + princ + "' should fail");
} catch (IllegalArgumentException e) {
// success
} finally {
if (g != null) {
g.remove();
save(superuser);
}
}
}
}
Aggregations