use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestAuthenticator method testService_2.
public void testService_2() throws ApsSystemException {
RequestContext reqCtx = this.getRequestContext();
MockHttpServletRequest request = (MockHttpServletRequest) reqCtx.getRequest();
request.setParameter("username", "admin");
request.setParameter("password", "admin");
int status = _authenticator.service(reqCtx, ControllerManager.CONTINUE);
assertEquals(status, ControllerManager.CONTINUE);
UserDetails currentUser = (UserDetails) request.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
assertEquals("admin", currentUser.getUsername());
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestRequestAuthorizator method testService_1.
public void testService_1() throws Throwable {
RequestContext reqCtx = this.getRequestContext();
this.setUserOnSession(SystemConstants.GUEST_USER_NAME);
IPage root = this._pageManager.getOnlineRoot();
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, root);
int status = _authorizator.service(reqCtx, ControllerManager.CONTINUE);
assertEquals(status, ControllerManager.CONTINUE);
String redirectUrl = (String) reqCtx.getExtraParam(RequestContext.EXTRAPAR_REDIRECT_URL);
assertNull(redirectUrl);
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestRequestAuthorizator method testServiceFailure_2.
public void testServiceFailure_2() throws Throwable {
RequestContext reqCtx = this.getRequestContext();
reqCtx.getRequest().getSession().removeAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
IPage root = this._pageManager.getOnlineRoot();
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, root);
int status = _authorizator.service(reqCtx, ControllerManager.CONTINUE);
assertEquals(status, ControllerManager.SYS_ERROR);
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestRequestAuthorizator method testServiceFailure_1.
public void testServiceFailure_1() throws Throwable {
RequestContext reqCtx = this.getRequestContext();
((MockHttpServletRequest) reqCtx.getRequest()).setRequestURI("/Entando/it/customers_page.page");
this.setUserOnSession(SystemConstants.GUEST_USER_NAME);
IPage requiredPage = this._pageManager.getOnlinePage("customers_page");
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, requiredPage);
int status = _authorizator.service(reqCtx, ControllerManager.CONTINUE);
assertEquals(status, ControllerManager.REDIRECT);
String redirectUrl = (String) reqCtx.getExtraParam(RequestContext.EXTRAPAR_REDIRECT_URL);
assertTrue(redirectUrl.contains("/Entando/it/login.page?"));
assertTrue(redirectUrl.contains("redirectflag=1"));
assertTrue(redirectUrl.contains("returnUrl="));
assertTrue(redirectUrl.contains("customers_page.page"));
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestRequestValidator method testServiceFailure_2.
public void testServiceFailure_2() throws ApsSystemException {
RequestContext reqCtx = this.getRequestContext();
// wrong path
((MockHttpServletRequest) reqCtx.getRequest()).setServletPath("/wrongpath.wp");
int status = _requestValidator.service(reqCtx, ControllerManager.CONTINUE);
assertEquals(ControllerManager.REDIRECT, status);
String redirectUrl = (String) reqCtx.getExtraParam(RequestContext.EXTRAPAR_REDIRECT_URL);
assertEquals("/Entando/it/errorpage.page?redirectflag=1", redirectUrl);
}
Aggregations