use of org.apache.directory.fortress.core.DelAdminMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method deleteAdminRoles.
/**
* @param rArray
*/
private void deleteAdminRoles(String msg, String[][] rArray, boolean isAdmin) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr;
if (isAdmin) {
dAdminMgr = getManagedDelegatedMgr();
} else {
dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
}
for (String[] rle : rArray) {
AdminRole role = new AdminRole();
role.setName(RoleTestData.getName(rle));
dAdminMgr.deleteRole(role);
LOG.debug("deleteAdminRoles role [" + role.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("deleteAdminRoles caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.DelAdminMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method deassignAdminUsers.
/**
* @param msg
* @param uArray
* @param rArray
*/
void deassignAdminUsers(String msg, String[][] uArray, String[][] rArray, boolean isAdmin) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr;
DelReviewMgr dReviewMgr;
if (isAdmin) {
dAdminMgr = getManagedDelegatedMgr();
dReviewMgr = getManagedDelegatedReviewMgr();
} else {
dAdminMgr = DelAdminMgrFactory.createInstance(TestUtils.getContext());
dReviewMgr = DelReviewMgrFactory.createInstance(TestUtils.getContext());
}
int i = 0;
for (String[] usr : uArray) {
i++;
for (String[] rle : rArray) {
UserAdminRole uAdminRole = new UserAdminRole(UserTestData.getUserId(usr), AdminRoleTestData.getRole(rle).getName());
AdminRoleTestData.getRole(rle);
dAdminMgr.deassignUser(uAdminRole);
LOG.debug("deassignAdminUsers user [" + uAdminRole.getUserId() + "] role [" + uAdminRole.getName() + "] successful");
// Let's double check the number of users associated with role:
List<User> users = dReviewMgr.assignedUsers(AdminRoleTestData.getRole(rle));
assertNotNull(users);
// If this is the last user deassigned from role, both lists will be returned empty:
if (i == uArray.length) {
assertTrue(users.size() == 0);
} else {
assertTrue(CLS_NM + "deassignAdminUsers list size check", (rArray.length - i) == users.size());
}
}
}
} catch (SecurityException ex) {
LOG.error("deassignAdminUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.DelAdminMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method deleteOrgUnits.
/**
* @param msg
* @param oArray
*/
private void deleteOrgUnits(String msg, String[][] oArray) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
for (String[] ole : oArray) {
OrgUnit ou = OrgUnitTestData.getOrgUnit(ole);
dAdminMgr.delete(ou);
LOG.debug("deleteOrgUnits ou [" + ou.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("deleteOrgUnits caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.DelAdminMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method delAdminRoleAscendant.
/**
* @param msg
* @param rArray
*/
private void delAdminRoleAscendant(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
for (String[] rle : rArray) {
AdminRole adminRole = AdminRoleTestData.getRole(rle);
Set<String> ascs = RoleTestData.getRelationships(rle);
if (ascs != null) {
for (String asc : ascs) {
dAdminMgr.deleteInheritance(new AdminRole(asc), adminRole);
LOG.debug("delAdminRoleAscendant desc adminRole [" + adminRole.getName() + "] asc adminRole [" + asc + "] successful");
}
}
Set<String> inheritances = RoleTestData.getInheritances(rle);
if (inheritances != null) {
for (String asc : inheritances) {
dAdminMgr.deleteInheritance(new AdminRole(asc), adminRole);
LOG.debug("delAdminRoleAscendant desc adminRole [" + adminRole.getName() + "] asc orgUnit [" + asc + "] successful");
}
}
dAdminMgr.deleteRole(adminRole);
LOG.debug("delAdminRoleAscendant remove desc adminRole [" + adminRole.getName() + "] successful");
}
// cleanup the top ascendant from orgUnit data set.
DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
String adminRoleSrchVal = RoleTestData.getName(rArray[0]);
// stip off prefix and search:
adminRoleSrchVal = adminRoleSrchVal.substring(0, 3);
List<AdminRole> cleanup = dReviewMgr.findRoles(adminRoleSrchVal);
for (AdminRole re : cleanup) {
dAdminMgr.deleteRole(re);
LOG.debug("delAdminRoleAscendant cleanup adminRole [" + re.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("delAdminRoleAscendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.DelAdminMgr in project directory-fortress-core by apache.
the class DelegatedMgrImplTest method delAdminRoleDescendant.
private void delAdminRoleDescendant(String msg, String[][] rArray) {
LogUtil.logIt(msg);
try {
DelAdminMgr dAdminMgr = getManagedDelegatedMgr();
for (String[] rle : rArray) {
AdminRole adminRole = AdminRoleTestData.getRole(rle);
// use list because order is important for test structure:
List<String> descs = RoleTestData.getRelationshipList(rle);
if (descs != null) {
if (RoleTestData.isTree(rle)) {
AdminRole parent = adminRole;
for (String desc : descs) {
AdminRole child = new AdminRole(desc);
dAdminMgr.deleteInheritance(parent, new AdminRole(desc));
LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
parent = child;
}
} else {
for (String desc : descs) {
dAdminMgr.deleteInheritance(adminRole, new AdminRole(desc));
LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
}
}
}
Set<String> inheritances = RoleTestData.getInheritances(rle);
if (inheritances != null) {
for (String desc : inheritances) {
dAdminMgr.deleteInheritance(adminRole, new AdminRole(desc));
LOG.debug("delAdminRoleDescendant asc adminRole [" + adminRole.getName() + "] desc adminRole [" + desc + "] successful");
}
}
dAdminMgr.deleteRole(adminRole);
LOG.debug("delAdminRoleDescendant remove asc adminRole [" + adminRole.getName() + "] successful");
}
// cleanup the last row of descendants from orgUnit data set.
DelReviewMgr dReviewMgr = getManagedDelegatedReviewMgr();
String srchVal = TestUtils.getSrchValue(RoleTestData.getName(rArray[0]));
List<AdminRole> cleanup = dReviewMgr.findRoles(srchVal);
for (Role re : cleanup) {
dAdminMgr.deleteRole((AdminRole) re);
LOG.debug("delAdminRoleDescendant cleanup adminRole [" + re.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("delOrgUnitDescendant caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations