Search in sources :

Example 6 with ActivityContext

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);
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) Before(org.junit.Before)

Example 7 with ActivityContext

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));
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) UserContext(org.mifos.security.util.UserContext) Test(org.junit.Test)

Example 8 with 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);
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) RolesPermissionsAction(org.mifos.security.rolesandpermission.struts.action.RolesPermissionsAction) Before(org.junit.Before)

Example 9 with ActivityContext

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;
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) FieldConfig(org.mifos.framework.components.fieldConfiguration.util.helpers.FieldConfig) Before(org.junit.Before)

Example 10 with ActivityContext

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;
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) FieldConfig(org.mifos.framework.components.fieldConfiguration.util.helpers.FieldConfig) Before(org.junit.Before)

Aggregations

ActivityContext (org.mifos.security.util.ActivityContext)24 Before (org.junit.Before)13 UserContext (org.mifos.security.util.UserContext)12 HttpSession (javax.servlet.http.HttpSession)5 Test (org.junit.Test)3 PersonnelBusinessService (org.mifos.customers.personnel.business.service.PersonnelBusinessService)3 ActivityEntity (org.mifos.security.rolesandpermission.business.ActivityEntity)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 FieldConfig (org.mifos.framework.components.fieldConfiguration.util.helpers.FieldConfig)2 PreviousRequestValues (org.mifos.framework.util.helpers.PreviousRequestValues)2 Enumeration (java.util.Enumeration)1 Locale (java.util.Locale)1 Random (java.util.Random)1 ServletException (javax.servlet.ServletException)1 ActionErrors (org.apache.struts.action.ActionErrors)1 ActionForward (org.apache.struts.action.ActionForward)1 ActionMessage (org.apache.struts.action.ActionMessage)1