Search in sources :

Example 16 with ActivityContext

use of org.mifos.security.util.ActivityContext in project head by mifos.

the class AddActivityIntegrationTest method upgradeAndCheck.

private Upgrade upgradeAndCheck() throws IOException, SQLException, ApplicationException {
    //        Connection connection = session.connection();
    //        connection.setAutoCommit(true);
    short newId = 17032;
    AddActivity upgrade = new AddActivity(newId, SecurityConstants.LOAN_MANAGEMENT, "Can use the executive washroom");
    upgrade.upgrade(session.connection());
    session = StaticHibernateUtil.getSessionTL();
    ActivityEntity fetched = (ActivityEntity) session.get(ActivityEntity.class, newId);
    Assert.assertEquals("Can use the executive washroom", fetched.getActivityName());
    Assert.assertEquals(SecurityConstants.LOAN_MANAGEMENT, (short) fetched.getParent().getId());
    ActivityContext activityContext = new ActivityContext(newId, TestObjectFactory.HEAD_OFFICE);
    UserContext admin = TestUtils.makeUser(RolesAndPermissionConstants.ADMIN_ROLE);
    Assert.assertTrue(legacyRolesPermissionsDao.isActivityAllowed(admin, activityContext));
    UserContext nonAdmin = TestUtils.makeUser(TestUtils.DUMMY_ROLE);
    Assert.assertFalse(legacyRolesPermissionsDao.isActivityAllowed(nonAdmin, activityContext));
    return upgrade;
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) UserContext(org.mifos.security.util.UserContext)

Example 17 with ActivityContext

use of org.mifos.security.util.ActivityContext in project head by mifos.

the class LoanPrdActionStrutsTest method setUp.

@Before
public void setUp() throws Exception {
    userContext = TestObjectFactory.getContext();
    request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
    addRequestParameter("recordLoanOfficerId", "1");
    addRequestParameter("recordOfficeId", "1");
    ActivityContext ac = TestObjectFactory.getActivityContext();
    request.getSession(false).setAttribute("ActivityContext", ac);
    flowKey = createFlow(request, LoanPrdAction.class);
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) Before(org.junit.Before)

Example 18 with ActivityContext

use of org.mifos.security.util.ActivityContext in project head by mifos.

the class NotesActionStrutsTest 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);
    request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
    flowKey = createFlow(request, NotesAction.class);
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) Before(org.junit.Before)

Example 19 with ActivityContext

use of org.mifos.security.util.ActivityContext in project head by mifos.

the class AdminActionStrutsTest 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);
    request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) Before(org.junit.Before)

Example 20 with ActivityContext

use of org.mifos.security.util.ActivityContext in project head by mifos.

the class CheckListActionStrutsTest method setUp.

@Before
public void setUp() throws Exception {
    UserContext userContext = TestUtils.makeUser();
    request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
    addRequestParameter("recordLoanOfficerId", "1");
    addRequestParameter("recordOfficeId", "1");
    ActivityContext ac = new ActivityContext((short) 0, userContext.getBranchId(), userContext.getId());
    request.getSession(false).setAttribute("ActivityContext", ac);
    flowKey = createFlow(request, ChkListAction.class);
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) UserContext(org.mifos.security.util.UserContext) 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