use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class UserManagementTest method testRemoveUser2.
@Test
public void testRemoveUser2() throws Exception {
createUser(userId);
// testSession has user-mgt permission -> removal should succeed.
Privilege[] privs = privilegesFromNames(new String[] { PrivilegeConstants.REP_USER_MANAGEMENT, PrivilegeConstants.REP_WRITE });
allow("/", privs);
UserManager testUserMgr = getUserManager(testSession);
Authorizable a = testUserMgr.getAuthorizable(userId);
a.remove();
testSession.save();
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class UserManagementTest method testCreateGroup2.
@Test
public void testCreateGroup2() throws Exception {
UserManager testUserMgr = getUserManager(testSession);
Privilege[] privs = privilegesFromNames(new String[] { PrivilegeConstants.REP_USER_MANAGEMENT, PrivilegeConstants.REP_WRITE });
allow("/", privs);
// creating group should succeed
Group gr = testUserMgr.createGroup(groupId);
testSession.save();
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class UserManagementTest method testChangeUserPropertiesWithoutPermission2.
@Test
public void testChangeUserPropertiesWithoutPermission2() throws Exception {
createUser(userId);
// testSession has read and user-mgt permission but lacks permission to
// alter regular properties
modify("/", PrivilegeConstants.REP_USER_MANAGEMENT, true);
UserManager testUserMgr = getUserManager(testSession);
try {
Authorizable a = testUserMgr.getAuthorizable(userId);
a.setProperty("someProp", testSession.getValueFactory().createValue("value"));
testSession.save();
fail("Test session doesn't have sufficient permission to alter user properties.");
} catch (AccessDeniedException e) {
// success
}
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class UserManagementTest method testDisableUser.
@Test
public void testDisableUser() throws Exception {
createUser(userId);
// after granting user-mgt privilege changing the pw must succeed.
modify("/", PrivilegeConstants.REP_USER_MANAGEMENT, true);
UserManager testUserMgr = getUserManager(testSession);
User user = (User) testUserMgr.getAuthorizable(userId);
user.disable("disabled!");
testSession.save();
}
use of org.apache.jackrabbit.api.security.user.UserManager in project jackrabbit-oak by apache.
the class UserManagementTest method testCreateUserWithoutPermission.
@Test
public void testCreateUserWithoutPermission() throws Exception {
UserManager testUserMgr = getUserManager(testSession);
// testSession has read-only access
try {
testUserMgr.createUser(userId, "pw");
testSession.save();
fail("Test session doesn't have sufficient permission -> creating user should fail.");
} catch (AccessDeniedException e) {
// success
}
// testSession has write permission but no user-mgt permission
// -> should still fail
modify("/", PrivilegeConstants.REP_WRITE, true);
try {
testUserMgr.createUser(userId, "pw");
testSession.save();
fail("Test session doesn't have sufficient permission -> creating user should fail.");
} catch (AccessDeniedException e) {
// success
}
}
Aggregations