use of org.mifos.security.util.ActivityContext in project head by mifos.
the class PersonnelNoteActionStrutsTest method setUp.
@Before
public void setUp() throws Exception {
userContext = TestUtils.makeUser();
request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
addRequestParameter("recordLoanOfficerId", "1");
addRequestParameter("recordOfficeId", "1");
ActivityContext ac = new ActivityContext((short) 0, userContext.getBranchId().shortValue(), userContext.getId().shortValue());
request.getSession(false).setAttribute("ActivityContext", ac);
flowKey = createFlow(request, PersonnelNoteAction.class);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
}
use of org.mifos.security.util.ActivityContext in project head by mifos.
the class RolesPermissionsActionStrutsTest method testDelete.
@Test
public void testDelete() throws Exception {
Short roleId = null;
List<ActivityEntity> activityList = legacyRolesPermissionsDao.getActivities();
ActivityEntity activityEntity_0 = activityList.get(0);
ActivityEntity activityEntity_1 = activityList.get(1);
ActivityEntity activityEntity_2 = activityList.get(2);
ActivityEntity activityEntity_3 = activityList.get(3);
ActivityEntity activityEntity_4 = activityList.get(4);
rolesPermissionService.createRole(RolesAndPermissionConstants.ADMIN_ROLE, "New Role", legacyRolesPermissionsDao.getActivitieIds());
role = legacyRolesPermissionsDao.getRole("New Role");
roleId = role.getId();
setRequestPathInfo("/rolesPermission.do");
addRequestParameter("method", "preview");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
addRequestParameter("id", role.getId().toString());
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward(ActionForwards.preview_success.toString());
Assert.assertNotNull(request.getAttribute(Constants.CURRENTFLOWKEY));
setRequestPathInfo("/rolesPermission.do");
addRequestParameter("method", "delete");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward(ActionForwards.delete_success.toString());
Assert.assertNull(request.getAttribute(Constants.CURRENTFLOWKEY));
role = legacyRolesPermissionsDao.getRole("New Role");
Assert.assertNull(role);
UserContext userContext = TestUtils.makeUser(roleId);
ActivityContext activityContext = new ActivityContext(activityEntity_0.getId(), (short) 1, (short) 0);
Assert.assertFalse(legacyRolesPermissionsDao.isActivityAllowed(userContext, activityContext));
activityContext = new ActivityContext(activityEntity_1.getId(), (short) 1, (short) 0);
Assert.assertFalse(legacyRolesPermissionsDao.isActivityAllowed(userContext, activityContext));
activityContext = new ActivityContext(activityEntity_2.getId(), (short) 1, (short) 0);
Assert.assertFalse(legacyRolesPermissionsDao.isActivityAllowed(userContext, activityContext));
activityContext = new ActivityContext(activityEntity_3.getId(), (short) 1, (short) 0);
Assert.assertFalse(legacyRolesPermissionsDao.isActivityAllowed(userContext, activityContext));
activityContext = new ActivityContext(activityEntity_4.getId(), (short) 1, (short) 0);
Assert.assertFalse(legacyRolesPermissionsDao.isActivityAllowed(userContext, activityContext));
}
use of org.mifos.security.util.ActivityContext in project head by mifos.
the class RolesPermissionsActionStrutsTest method setUp.
@Before
public void setUp() throws Exception {
userContext = TestUtils.makeUser();
request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
addRequestParameter("recordLoanOfficerId", "1");
addRequestParameter("recordOfficeId", "1");
ActivityContext ac = new ActivityContext((short) 0, userContext.getBranchId().shortValue(), userContext.getId().shortValue());
request.getSession(false).setAttribute("ActivityContext", ac);
flowKey = createFlow(request, RolesPermissionsAction.class);
}
use of org.mifos.security.util.ActivityContext in project head by mifos.
the class PersonActionStrutsTest method setUp.
@Before
public void setUp() throws Exception {
userContext = TestUtils.makeUser();
request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
addRequestParameter("recordLoanOfficerId", "1");
addRequestParameter("recordOfficeId", "1");
ActivityContext ac = new ActivityContext((short) 0, userContext.getBranchId().shortValue(), userContext.getId().shortValue());
request.getSession(false).setAttribute("ActivityContext", ac);
flowKey = createFlow(request, PersonAction.class);
EntityMasterData.getInstance().init();
FieldConfig fieldConfig = FieldConfig.getInstance();
fieldConfig.init();
getActionServlet().getServletContext().setAttribute(Constants.FIELD_CONFIGURATION, fieldConfig.getEntityMandatoryFieldMap());
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
addRequestParameter("input", "CreateUser");
PersonnelBusinessService personnelBusinessService = new PersonnelBusinessService();
SessionUtils.setAttribute(PersonnelConstants.OFFICE, personnelBusinessService.getOffice(TestObjectFactory.HEAD_OFFICE), request);
SessionUtils.setCollectionAttribute(PersonnelConstants.ROLES_LIST, personnelBusinessService.getRoles(), request);
SessionUtils.setCollectionAttribute(PersonnelConstants.ROLEMASTERLIST, personnelBusinessService.getRoles(), request);
personnelBusinessService = null;
}
use of org.mifos.security.util.ActivityContext in project head by mifos.
the class PersonnelSettingsActionStrutsTest method setUp.
@Before
public void setUp() throws Exception {
userContext = TestUtils.makeUser();
request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
addRequestParameter("recordLoanOfficerId", "1");
addRequestParameter("recordOfficeId", "1");
ActivityContext ac = new ActivityContext((short) 0, userContext.getBranchId().shortValue(), userContext.getId().shortValue());
request.getSession(false).setAttribute("ActivityContext", ac);
flowKey = createFlow(request, PersonnelSettingsAction.class);
EntityMasterData.getInstance().init();
FieldConfig fieldConfig = FieldConfig.getInstance();
fieldConfig.init();
getActionServlet().getServletContext().setAttribute(Constants.FIELD_CONFIGURATION, fieldConfig.getEntityMandatoryFieldMap());
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
addRequestParameter("input", "CreateUser");
PersonnelBusinessService personnelBusinessService = new PersonnelBusinessService();
SessionUtils.setAttribute(PersonnelConstants.OFFICE, personnelBusinessService.getOffice(TestObjectFactory.HEAD_OFFICE), request);
SessionUtils.setCollectionAttribute(PersonnelConstants.ROLES_LIST, personnelBusinessService.getRoles(), request);
SessionUtils.setCollectionAttribute(PersonnelConstants.ROLEMASTERLIST, personnelBusinessService.getRoles(), request);
personnelBusinessService = null;
}
Aggregations