use of org.apache.directory.fortress.core.AccelMgr in project directory-fortress-core by apache.
the class TestAccelerator method testDeleteSession.
@Test
public void testDeleteSession() {
LOG.info("testDeleteSession...");
User user = new User();
user.setUserId("rbacuser1");
user.setPassword("secret");
try {
AccelMgr accelMgr = AccelMgrFactory.createInstance(TestUtils.getContext());
Session session;
session = accelMgr.createSession(user, false);
assertNotNull(session);
accelMgr.deleteSession(session);
} catch (SecurityException se) {
se.printStackTrace();
}
}
use of org.apache.directory.fortress.core.AccelMgr in project directory-fortress-core by apache.
the class TestAccelerator method testCombinedCalls.
@Test
public void testCombinedCalls() {
LOG.info("testCombinedCalls...");
try {
AccelMgr accelMgr = AccelMgrFactory.createInstance(TestUtils.getContext());
Session session;
User user = new User();
// positive test case:
user.setUserId("rbacuser1");
user.setPassword("secret");
session = accelMgr.createSession(user, false);
// positive test case:
Permission perm = new Permission();
perm.setObjName("/impl/cal2.jsp");
perm.setOpName("8am");
boolean result = accelMgr.checkAccess(session, perm);
assertTrue(result);
// drop role1:
UserRole userRole = new UserRole(user.getUserId(), "rbacrole1");
accelMgr.dropActiveRole(session, userRole);
// this should return false:
result = accelMgr.checkAccess(session, perm);
assertTrue(!result);
// now add role1 back again:
userRole = new UserRole(user.getUserId(), "rbacrole1");
accelMgr.addActiveRole(session, userRole);
// this should return true:
result = accelMgr.checkAccess(session, perm);
assertTrue(result);
} catch (SecurityException se) {
se.printStackTrace();
fail();
}
}
Aggregations