use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class ReviewMgrImplTest method assignedRoleNms.
/**
* @param msg
* @param uArray
* @param rArray
*/
public static void assignedRoleNms(String msg, String[][] uArray, String[][] rArray) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
for (String[] usr : uArray) {
List<String> uRoles = reviewMgr.assignedRoles(UserTestData.getUserId(usr));
assertNotNull(uRoles);
assertTrue(CLS_NM + "assignedRoleNms list size check", rArray.length == uRoles.size());
for (String[] url : rArray) {
int indx = uRoles.indexOf(RoleTestData.getName(url));
if (indx != -1) {
String uRole = uRoles.get(indx);
assertNotNull(uRole);
assertEquals(CLS_NM + ".assignedRoleNms failed compare role name", RoleTestData.getName(url), uRole);
} else {
msg = "assignedRoleNms userId [" + UserTestData.getUserId(usr) + "] role [" + RoleTestData.getName(url) + "] failed list search";
LogUtil.logIt(msg);
fail(msg);
}
}
}
} catch (SecurityException ex) {
LOG.error("assignedRoleNms caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class ReviewMgrImplTest method rolePermissions.
/**
* @param msg
* @param rArray
* @param pObjArray
* @param pOpArray
*/
public static void rolePermissions(String msg, String[][] rArray, String[][] pObjArray, String[][] pOpArray) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
List<Permission> perms = reviewMgr.rolePermissions(role);
assertNotNull(perms);
assertTrue(CLS_NM + "rolePermissions list size check", pOpArray.length * pObjArray.length == perms.size());
for (String[] obj : pObjArray) {
for (String[] op : pOpArray) {
int indx = perms.indexOf(new Permission(PermTestData.getName(obj), PermTestData.getName(op), PermTestData.getObjId(op)));
if (indx != -1) {
Permission pOp = perms.get(indx);
assertNotNull(pOp);
PermTestData.assertEquals(PermTestData.getName(obj), pOp, op);
LOG.debug("rolePermissions role name [" + role.getName() + "] perm objName [" + PermTestData.getName(obj) + "] operationName [" + PermTestData.getName(op) + "] successful");
} else {
msg = "rolePermissions role name [" + role.getName() + "] perm objName [" + PermTestData.getName(obj) + "] operationName [" + PermTestData.getName(op) + "] failed list search";
LogUtil.logIt(msg);
fail(msg);
}
}
}
}
} catch (SecurityException ex) {
LOG.error("rolePermissions caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class ReviewMgrImplTest method authorizedUsers.
/**
* @param msg
* @param rArray
* @param uArray
*/
public static void authorizedUsers(String msg, String[][] rArray, String[][] uArray) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
for (String[] rle : rArray) {
List<User> users = reviewMgr.authorizedUsers(new Role(RoleTestData.getName(rle)));
assertNotNull(users);
// LOG.debug("authorizedUsers list source size=" + uArray.length + " ldap size=" + users.size());
assertTrue(CLS_NM + "authorizedUsers list size check", uArray.length == users.size());
for (String[] usr : uArray) {
int indx = users.indexOf(UserTestData.getUser(usr));
if (indx != -1) {
User user = users.get(indx);
assertNotNull(user);
UserTestData.assertEquals(user, usr);
LOG.debug("authorizedUsers role name [" + RoleTestData.getName(rle) + "] userId [" + user.getUserId() + "] successful");
} else {
msg = "authorizedUsers role [" + RoleTestData.getName(rle) + "] user [" + UserTestData.getUserId(usr) + "] failed list search";
LogUtil.logIt(msg);
fail(msg);
}
}
}
} catch (SecurityException ex) {
LOG.error("authorizedUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method addSsdRoleMember.
/**
* @param sArray
*/
public static void addSsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
for (String[] ssdle : sArray) {
SDSet ssd = RoleTestData.getSDSet(ssdle);
SDSet entity = adminMgr.createSsdSet(ssd);
LOG.debug("addSsdRoleMember SSD [" + entity.getName() + "] successful");
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
adminMgr.addSsdRoleMember(ssd, role);
List<SDSet> ssdSets = reviewMgr.ssdRoleSets(role);
assertNotNull(ssdSets);
assertTrue(CLS_NM + "addSsdRoleMember list size check", ssdSets.size() == 1);
SDSet ssd2 = ssdSets.get(0);
assertTrue(CLS_NM + "addSsdRoleMember SSD name check", ssd.getName().equals(ssd2.getName()));
assertTrue(CLS_NM + "addSsdRoleMember SSD role check", ssd2.getMembers().contains(role.getName()));
}
}
} catch (SecurityException ex) {
LOG.error("addSsdRoleMember caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method deleteSsdRoleMember.
/**
* @param sArray
*/
private void deleteSsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
for (String[] ssdle : sArray) {
SDSet ssd = RoleTestData.getSDSet(ssdle);
// first add all of the roles as members of SSD entity:
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
ssd.addMember(role.getName());
}
// now iterate over roles and remove from SSD set one at a time.
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
adminMgr.deleteSsdRoleMember(ssd, role);
List<SDSet> ssdSets = reviewMgr.ssdRoleSets(role);
assertTrue(CLS_NM + "deleteSsdRoleMember list size check ssdSets size [" + ssdSets.size() + "]", ssdSets.size() == 0);
}
adminMgr.deleteSsdSet(ssd);
LOG.debug("deleteSsdRoleMember SSD [" + ssd.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("deleteSsdRoleMember caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations