UserManager umgr = getUserManager(uSession);
Authorizable auth = umgr.getAuthorizable(UserConstants.USER_ADMIN_GROUP_NAME);
if (auth == null || !auth.isGroup()) {
throw new NotExecutableException("Cannot execute test. No User-Admin group found.");
}
Group userAdmin = (Group) auth;
Group testGroup = null;
User self = (User) umgr.getAuthorizable(uID);
try {
userAdmin.addMember(self);
save(uSession);
userAdmin.removeMember(self);
save(uSession);
fail("Group admin cannot add member to user-admins");
} catch (AccessDeniedException e) {
// success
}
try {
// let groupadmin create a new group
testGroup = umgr.createGroup(getTestPrincipal(), "/a/b/c/d");
save(uSession);
userAdmin.addMember(testGroup);
save(uSession);
userAdmin.removeMember(testGroup);
save(uSession);
fail("Group admin cannot add member to user-admins");
} catch (AccessDeniedException e) {
// success
} finally {
if (testGroup != null) {
testGroup.remove();
save(uSession);
}
}
}