use of org.apache.jackrabbit.api.security.user.AuthorizableExistsException in project jackrabbit-oak by apache.
the class UserManagerTest method testCreateGroupWithExistingPrincipal2.
@Test
public void testCreateGroupWithExistingPrincipal2() throws RepositoryException, NotExecutableException {
Principal p = getTestPrincipal();
String uid = createUserId();
assertFalse(uid.equals(p.getName()));
User u = null;
try {
// 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 CreateGroupTest method testCreateDuplicateGroup.
@Test
public void testCreateDuplicateGroup() throws RepositoryException, NotExecutableException {
Principal p = getTestPrincipal();
Group gr = createGroup(p);
createdGroups.add(gr);
try {
Group gr2 = createGroup(p);
createdGroups.add(gr2);
fail("Creating 2 groups with the same Principal should throw AuthorizableExistsException.");
} catch (AuthorizableExistsException e) {
// success.
}
}
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);
}
}
}
use of org.apache.jackrabbit.api.security.user.AuthorizableExistsException in project jackrabbit by apache.
the class UserManagerImplTest method testCreateGroupWithExistingGroupID.
public void testCreateGroupWithExistingGroupID() throws RepositoryException, NotExecutableException {
Principal p = getTestPrincipal();
String uid = getTestUserId(p);
Group g = null;
try {
// create a user with the given ID
g = userMgr.createGroup(uid);
save(superuser);
// 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();
save(superuser);
}
}
} finally {
if (g != null) {
g.remove();
save(superuser);
}
}
}
Aggregations