use of org.apache.directory.fortress.core.ReviewMgr in project directory-fortress-core by apache.
the class ReviewMgrImplTest method assignedRoles.
/**
* @param msg
* @param uArray
* @param rArray
*/
public static void assignedRoles(String msg, String[][] uArray, String[][] rArray) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
for (String[] usr : uArray) {
User user = reviewMgr.readUser(new User(UserTestData.getUserId(usr)));
assertNotNull(user);
List<UserRole> uRoles = reviewMgr.assignedRoles(user);
assertTrue(CLS_NM + "assignedRoles list size check", rArray.length == uRoles.size());
for (String[] url : rArray) {
int indx = uRoles.indexOf(RoleTestData.getUserRole(UserTestData.getUserId(usr), url));
if (indx != -1) {
UserRole uRole = uRoles.get(indx);
assertNotNull(uRole);
RoleTestData.assertEquals(UserTestData.getUserId(usr), uRole, url);
LOG.debug("assignedRoles userId [" + uRole.getUserId() + "] role [" + uRole.getName() + "] successful");
} else {
msg = "assignedRoles userId [" + user.getUserId() + "] role [" + RoleTestData.getName(url) + "] failed list search";
LogUtil.logIt(msg);
fail(msg);
}
}
}
} catch (SecurityException ex) {
LOG.error("assignedRoles 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 searchPermissionOps.
/**
* @param msg
* @param srchValue
* @param pObjArray
*/
public static void searchPermissionOps(String msg, String srchValue, String[][] pObjArray, String[][] pOpArray) {
LogUtil.logIt(msg);
Permission pOp;
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
for (String[] obj : pObjArray) {
for (String[] op : pOpArray) {
pOp = new Permission();
pOp.setObjName(PermTestData.getName(obj));
pOp.setOpName(srchValue);
List<Permission> ops = reviewMgr.findPermissions(pOp);
assertNotNull(ops);
assertTrue(CLS_NM + "searchPermissionOps srchValue [" + srchValue + "] list size check", pOpArray.length == ops.size());
int indx = ops.indexOf(new Permission(PermTestData.getName(obj), PermTestData.getName(op), PermTestData.getObjId(op)));
if (indx != -1) {
Permission entity = ops.get(indx);
assertNotNull(entity);
PermTestData.assertEquals(PermTestData.getName(obj), entity, op);
LOG.debug("searchPermissionOps objName [" + entity.getObjName() + "] operation name [" + entity.getOpName() + "] successful");
} else {
msg = "searchPermissionOps srchValue [" + srchValue + "] failed list search";
LogUtil.logIt(msg);
fail(msg);
}
}
}
} catch (SecurityException ex) {
LOG.error("searchPermissionOps srchValue [" + srchValue + "] 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 permissionRoles.
/**
* @param msg
* @param pObjArray
* @param pOpArray
* @param rArray
*/
public static void permissionRoles(String msg, String[][] pObjArray, String[][] pOpArray, String[][] rArray) {
LogUtil.logIt(msg);
Permission pOp;
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
for (String[] obj : pObjArray) {
for (String[] op : pOpArray) {
pOp = new Permission();
pOp.setObjName(PermTestData.getName(obj));
pOp.setOpName(PermTestData.getName(op));
pOp.setObjId(PermTestData.getObjId(op));
List<String> roles = reviewMgr.permissionRoles(pOp);
assertNotNull(roles);
assertTrue(CLS_NM + "permissionRoles permission object [" + pOp.getObjName() + "] operationName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "]", rArray.length == roles.size());
for (String[] rle : rArray) {
int indx = roles.indexOf(RoleTestData.getName(rle));
if (indx != -1) {
String roleNm = roles.get(indx);
assertEquals(CLS_NM + ".permissionRoles failed compare role name", RoleTestData.getName(rle), roleNm);
LOG.debug(".permissionRoles permission objName [" + pOp.getObjName() + "] operationName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "] roleNm [" + roleNm + "] successful");
} else {
msg = "permissionRoles permission objName [" + pOp.getObjName() + "] operationName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "] role [" + RoleTestData.getName(rle) + "] failed list search";
LogUtil.logIt(msg);
fail(msg);
}
}
}
}
} catch (SecurityException ex) {
LOG.error("permissionRoles 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 authorizedUsersHier.
/**
* @param msg
* @param roleMap
*/
public static void authorizedUsersHier(String msg, Map roleMap) {
LogUtil.logIt(msg);
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
// iterate over every role entry found in map:
for (Object o : roleMap.entrySet()) {
Map.Entry pairs = (Map.Entry) o;
String roleName = (String) pairs.getKey();
String szValidUsers = (String) pairs.getValue();
Set<String> userSet = TestUtils.getSets(szValidUsers);
assertNotNull(userSet);
assertTrue(userSet.size() > 0);
List<User> actualUsers = reviewMgr.authorizedUsers(new Role(roleName));
assertNotNull(actualUsers);
assertTrue(actualUsers.size() > 0);
// Ensure the two list sizes match or fail the test case.
assertTrue(CLS_NM + "authorizedUsersHier failed list size test case", userSet.size() == actualUsers.size());
// for each valid user expected, ensure it actually pulled from API:
for (String userId : userSet) {
User validUser = new User(userId);
assertTrue(CLS_NM + ".authorizedUsersHier failed authorizedUsers test, role [" + roleName + "] does not have user [" + validUser.getUserId() + "] as authorized", actualUsers.contains(validUser));
}
}
} catch (SecurityException ex) {
LOG.error("authorizedUsersHier 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 permissionUsers.
/**
* @param msg
* @param pObjArray
* @param pOpArray
* @param uArray
*/
public static void permissionUsers(String msg, String[][] pObjArray, String[][] pOpArray, String[][] uArray) {
LogUtil.logIt(msg);
Permission pOp;
try {
ReviewMgr reviewMgr = getManagedReviewMgr();
for (String[] obj : pObjArray) {
for (String[] op : pOpArray) {
pOp = new Permission();
pOp.setObjName(PermTestData.getName(obj));
pOp.setOpName(PermTestData.getName(op));
pOp.setObjId(PermTestData.getObjId(op));
List<String> users = reviewMgr.permissionUsers(pOp);
assertNotNull(users);
assertTrue(CLS_NM + "permissionUsers permission object [" + pOp.getObjName() + "] operationName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "]", uArray.length == users.size());
for (String[] usr : uArray) {
int indx = users.indexOf(RoleTestData.getName(usr));
if (indx != -1) {
String userId = users.get(indx);
assertEquals(CLS_NM + ".permissionUsers failed compare userId", UserTestData.getUserId(usr), userId);
LOG.debug("permissionUsers permission objName [" + pOp.getObjName() + "] operationName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "] userId [" + userId + "] successful");
} else {
msg = "permissionUsers permission objName [" + pOp.getObjName() + "] operationName [" + pOp.getOpName() + "] objectId [" + pOp.getObjId() + "] userId [" + UserTestData.getUserId(usr) + "] failed list search";
LogUtil.logIt(msg);
fail(msg);
}
}
}
}
} catch (SecurityException ex) {
LOG.error("permissionUsers caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations