use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestAuthenticator method testServiceFailure.
public void testServiceFailure() throws ApsSystemException {
RequestContext reqCtx = this.getRequestContext();
MockHttpServletRequest request = (MockHttpServletRequest) reqCtx.getRequest();
request.setParameter("user", "notauthorized");
request.setParameter("password", "notauthorized");
int status = _authenticator.service(reqCtx, ControllerManager.CONTINUE);
assertEquals(status, ControllerManager.CONTINUE);
UserDetails currentUser = (UserDetails) request.getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
assertEquals(SystemConstants.GUEST_USER_NAME, currentUser.getUsername());
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestErrorManager method testService.
public void testService() throws ApsSystemException {
RequestContext reqCtx = new RequestContext();
MockHttpServletRequest request = new MockHttpServletRequest();
request.setParameter(RequestContext.PAR_REDIRECT_FLAG, "");
reqCtx.setRequest(request);
MockHttpServletResponse response = new MockHttpServletResponse();
reqCtx.setResponse(response);
int status = _errorManager.service(reqCtx, ControllerManager.ERROR);
assertEquals(status, ControllerManager.REDIRECT);
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestRequestAuthorizator method testService_2.
public void testService_2() throws Throwable {
RequestContext reqCtx = this.getRequestContext();
this.setUserOnSession("admin");
IPage root = this._pageManager.getOnlineRoot();
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, root);
int status = this._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 TestRequestValidator method testServiceFailure_3.
public void testServiceFailure_3() throws ApsSystemException {
RequestContext reqCtx = this.getRequestContext();
// lang does not exist
((MockHttpServletRequest) reqCtx.getRequest()).setServletPath("/cc/homepage.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);
}
use of com.agiletec.aps.system.RequestContext in project entando-core by entando.
the class TestContentPreviewAction method testFailureExecutePreviewContent.
public void testFailureExecutePreviewContent() throws Throwable {
String contentId = "ART187";
Content contentForTest = this.getContentManager().loadContent(contentId, true);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(contentForTest, ApsAdminSystemConstants.EDIT);
String result = this.executeEdit(contentId, "admin");
assertEquals(Action.SUCCESS, result);
result = this.executePreviewPage("wrongPageCode", contentOnSessionMarker);
assertEquals(Action.INPUT, result);
RequestContext reqCtx = (RequestContext) this.getRequest().getAttribute(RequestContext.REQCTX);
assertNull(reqCtx);
Map<String, List<String>> fieldErrors = this.getAction().getFieldErrors();
assertEquals(1, fieldErrors.size());
assertEquals(1, fieldErrors.get("previewPageCode").size());
}
Aggregations