Search in sources :

Example 71 with RequestContext

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());
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) RequestContext(com.agiletec.aps.system.RequestContext)

Example 72 with RequestContext

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);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) RequestContext(com.agiletec.aps.system.RequestContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Example 73 with RequestContext

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);
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) RequestContext(com.agiletec.aps.system.RequestContext)

Example 74 with RequestContext

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);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) RequestContext(com.agiletec.aps.system.RequestContext)

Example 75 with RequestContext

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());
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) List(java.util.List) RequestContext(com.agiletec.aps.system.RequestContext)

Aggregations

RequestContext (com.agiletec.aps.system.RequestContext)89 ServletRequest (javax.servlet.ServletRequest)25 JspException (javax.servlet.jsp.JspException)22 IPage (com.agiletec.aps.system.services.page.IPage)15 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)12 Lang (com.agiletec.aps.system.services.lang.Lang)10 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 Widget (com.agiletec.aps.system.services.page.Widget)5 NavigatorTarget (com.agiletec.aps.system.services.page.widget.NavigatorTarget)5 IURLManager (com.agiletec.aps.system.services.url.IURLManager)5 ContentRenderizationInfo (com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo)5 DataObjectRenderizationInfo (org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo)5 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)4 UserDetails (com.agiletec.aps.system.services.user.UserDetails)4 ControllerManager (com.agiletec.aps.system.services.controller.ControllerManager)3 HeadInfoContainer (com.agiletec.aps.tags.util.HeadInfoContainer)3 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)3 IContentListWidgetHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentListWidgetHelper)3 IContentViewerHelper (com.agiletec.plugins.jacms.aps.system.services.content.widget.IContentViewerHelper)3