use of org.springframework.security.authentication.TestingAuthenticationToken in project head by mifos.
the class RepayLoanActionStrutsTest 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);
}
use of org.springframework.security.authentication.TestingAuthenticationToken in project head by mifos.
the class ApplyAdjustmentActionStrutsTest method setUpSecurityContext.
private void setUpSecurityContext() {
SecurityContext securityContext = new SecurityContextImpl();
MifosUser mifosUser = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(mifosUser, mifosUser);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
}
use of org.springframework.security.authentication.TestingAuthenticationToken in project head by mifos.
the class ApplyChargeActionStrutsTest method testUpdateSuccess.
@Test
public void testUpdateSuccess() {
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();
accountBO = getLoanAccount(client, meeting);
setRequestPathInfo("/applyChargeAction.do");
addRequestParameter("method", "update");
addRequestParameter("chargeType", IS_PENALTY_TYPE + ":" + FEE_ID + ":" + IS_NOT_RATE_TYPE);
addRequestParameter("charge", "18");
addRequestParameter("accountId", accountBO.getAccountId().toString());
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
// verifyForward("loanDetails_success");
verifyNoActionErrors();
verifyNoActionMessages();
}
use of org.springframework.security.authentication.TestingAuthenticationToken in project head by mifos.
the class SavingsDepositWithdrawalActionStrutsTest method setUp.
@Before
public void setUp() throws Exception {
userContext = TestObjectFactory.getContext();
userContext.setPreferredLocale(new Locale("en", "GB"));
addRequestParameter("recordLoanOfficerId", "1");
addRequestParameter("recordOfficeId", "1");
request.getSession().setAttribute(Constants.USER_CONTEXT_KEY, userContext);
request.getSession(false).setAttribute("ActivityContext", TestObjectFactory.getActivityContext());
flowKey = createFlow(request, SavingsDepositWithdrawalAction.class);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
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.authentication.TestingAuthenticationToken in project head by mifos.
the class EditStatusActionStrutsTest method setUp.
@Before
public void setUp() throws Exception {
userContext = TestObjectFactory.getContext();
request.getSession().setAttribute(Constants.USERCONTEXT, userContext);
addRequestParameter("recordLoanOfficerId", "1");
addRequestParameter("recordOfficeId", "1");
request.getSession(false).setAttribute("ActivityContext", TestObjectFactory.getActivityContext());
flowKey = createFlow(request, EditStatusAction.class);
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
}
Aggregations