use of org.springframework.security.core.context.SecurityContextImpl in project head by mifos.
the class EditCustomerStatusActionStrutsTest method setUp.
@Before
public void setUp() throws Exception {
UserContext userContext = TestObjectFactory.getContext();
request.getSession().setAttribute(Constants.USER_CONTEXT_KEY, userContext);
addRequestParameter("recordLoanOfficerId", "1");
addRequestParameter("recordOfficeId", "1");
request.getSession(false).setAttribute("ActivityContext", TestObjectFactory.getActivityContext());
flowKey = createFlow(request, EditCustomerStatusAction.class);
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
}
use of org.springframework.security.core.context.SecurityContextImpl in project head by mifos.
the class MifosMockStrutsTestCase method beforeStrutsTest.
@Before
public void beforeStrutsTest() throws Exception {
mockStruts.setUp();
if (!strutsConfigSet) {
setStrutsConfig();
strutsConfigSet = true;
}
getActionServlet().getServletContext().setAttribute(ShutdownManager.class.getName(), new ShutdownManager());
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
}
use of org.springframework.security.core.context.SecurityContextImpl in project head by mifos.
the class PersonnelNoteActionStrutsTest method testSuccessCreatePersonnelNote.
@Test
public void testSuccessCreatePersonnelNote() throws Exception {
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
createPersonnelAndSetInSession(getBranchOffice(), PersonnelLevel.LOAN_OFFICER);
setRequestPathInfo("/personnelNoteAction.do");
addRequestParameter("method", Methods.create.toString());
addRequestParameter("personnelId", personnel.getPersonnelId().toString());
addRequestParameter("comment", "Test");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyForward(ActionForwards.create_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
}
use of org.springframework.security.core.context.SecurityContextImpl in project head by mifos.
the class CustHistoricalDataActionStrutsTest method testUpdateHistoricalDataWhenCustHistoricalDataIsNotNull.
@Test
public void testUpdateHistoricalDataWhenCustHistoricalDataIsNotNull() throws Exception {
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createInitialObjects();
CustomerHistoricalDataEntity customerHistoricalDataEntity = new CustomerHistoricalDataEntity(group);
group.updateHistoricalData(customerHistoricalDataEntity);
group.update();
StaticHibernateUtil.flushSession();
SessionUtils.setAttribute(Constants.BUSINESS_KEY, group, request);
setRequestPathInfo("/custHistoricalDataAction.do");
addRequestParameter("method", "updateHistoricalData");
addRequestParameter("productName", "Test");
addRequestParameter("loanAmount", "200");
addRequestParameter("totalAmountPaid", "150");
addRequestParameter("interestPaid", "50");
addRequestParameter("missedPaymentsCount", "2");
addRequestParameter("totalPaymentsCount", "3");
addRequestParameter("commentNotes", "Test notes");
addRequestParameter("loanCycleNumber", "2");
addRequestParameter("type", "Group");
addRequestParameter("mfiJoiningDate", DateUtils.getCurrentDate(((UserContext) request.getSession().getAttribute("UserContext")).getPreferredLocale()));
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
verifyForward(ActionForwards.updateHistoricalData_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
group = TestObjectFactory.getGroup(group.getCustomerId());
Assert.assertEquals("Test", group.getHistoricalData().getProductName());
Assert.assertEquals("Test notes", group.getHistoricalData().getNotes());
Assert.assertEquals(new Money(getCurrency(), "200"), group.getHistoricalData().getLoanAmount());
Assert.assertEquals(new Money(getCurrency(), "150"), group.getHistoricalData().getTotalAmountPaid());
Assert.assertEquals(new Money(getCurrency(), "50"), group.getHistoricalData().getInterestPaid());
Assert.assertEquals(2, group.getHistoricalData().getMissedPaymentsCount().intValue());
Assert.assertEquals(3, group.getHistoricalData().getTotalPaymentsCount().intValue());
Assert.assertEquals(2, group.getHistoricalData().getLoanCycleNumber().intValue());
}
use of org.springframework.security.core.context.SecurityContextImpl in project head by mifos.
the class MeetingActionStrutsTest method setMifosUserFromContext.
private void setMifosUserFromContext() {
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUser(userContext.getId(), userContext.getBranchId(), userContext.getLevelId(), new ArrayList<Short>(userContext.getRoles()), userContext.getName(), "".getBytes(), true, true, true, true, new ArrayList<GrantedAuthority>(), userContext.getLocaleId());
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
}
Aggregations