use of org.apache.jackrabbit.api.security.user.AuthorizableExistsException in project jackrabbit-oak by apache.
the class UserManagerTest method testCreateGroupWithExistingPrincipal.
@Test
public void testCreateGroupWithExistingPrincipal() throws RepositoryException, NotExecutableException {
User u = null;
try {
Principal p = getTestPrincipal();
String uid = p.getName();
// create a user with the given ID
u = userMgr.createUser(uid, "pw", p, null);
superuser.save();
// assert AuthorizableExistsException for principal that is already in use
Group gr = null;
try {
gr = userMgr.createGroup(p);
fail("Principal " + p.getName() + " is already in use -> must throw AuthorizableExistsException.");
} catch (AuthorizableExistsException e) {
// expected this
} finally {
if (gr != null) {
gr.remove();
superuser.save();
}
}
} finally {
if (u != null) {
u.remove();
superuser.save();
}
}
}
use of org.apache.jackrabbit.api.security.user.AuthorizableExistsException in project jackrabbit-oak by apache.
the class UserManagerTest method testCreateGroupWithExistingUserID.
@Test
public void testCreateGroupWithExistingUserID() throws RepositoryException, NotExecutableException {
User u = null;
try {
String uid = createUserId();
// create a user with the given ID
u = userMgr.createUser(uid, "pw");
superuser.save();
// assert AuthorizableExistsException for id that is already in use
Group gr = null;
try {
gr = userMgr.createGroup(uid);
fail("ID " + uid + " is already in use -> must throw AuthorizableExistsException.");
} catch (AuthorizableExistsException aee) {
// expected this
} finally {
if (gr != null) {
gr.remove();
superuser.save();
}
}
} finally {
if (u != null) {
u.remove();
superuser.save();
}
}
}
use of org.apache.jackrabbit.api.security.user.AuthorizableExistsException in project jackrabbit-oak by apache.
the class UserManagerTest method testCreateGroupWithExistingGroupID.
@Test
public void testCreateGroupWithExistingGroupID() throws RepositoryException, NotExecutableException {
Group g = null;
try {
String id = createGroupId();
// create a user with the given ID
g = userMgr.createGroup(id);
superuser.save();
// assert AuthorizableExistsException for id that is already in use
Group gr = null;
try {
gr = userMgr.createGroup(id);
fail("ID " + id + " is already in use -> must throw AuthorizableExistsException.");
} catch (AuthorizableExistsException aee) {
// expected this
} finally {
if (gr != null) {
gr.remove();
superuser.save();
}
}
} finally {
if (g != null) {
g.remove();
superuser.save();
}
}
}
use of org.apache.jackrabbit.api.security.user.AuthorizableExistsException in project jackrabbit by apache.
the class NotUserAdministratorTest method testCreateUser.
public void testCreateUser() throws NotExecutableException {
try {
Principal p = getTestPrincipal();
User u = uMgr.createUser(p.getName(), buildPassword(p));
save(uSession);
fail("A non-UserAdmin should not be allowed to create a new User.");
// clean-up: let superuser remove the user created by fault.
userMgr.getAuthorizable(u.getID()).remove();
} catch (AuthorizableExistsException e) {
// should never get here.
fail(e.getMessage());
} catch (RepositoryException e) {
// success
}
}
use of org.apache.jackrabbit.api.security.user.AuthorizableExistsException in project jackrabbit by apache.
the class UserManagerImplTest method testCreateGroupWithExistingPrincipal.
public void testCreateGroupWithExistingPrincipal() throws RepositoryException, NotExecutableException {
Principal p = getTestPrincipal();
String uid = p.getName();
User u = null;
try {
// create a user with the given ID
u = userMgr.createUser(uid, buildPassword(uid), p, null);
save(superuser);
// assert AuthorizableExistsException for principal that is already in use
Group gr = null;
try {
gr = userMgr.createGroup(p);
fail("Principal " + p.getName() + " is already in use -> must throw AuthorizableExistsException.");
} catch (AuthorizableExistsException aee) {
// expected this
} finally {
if (gr != null) {
gr.remove();
save(superuser);
}
}
} finally {
if (u != null) {
u.remove();
save(superuser);
}
}
}
Aggregations