Search in sources :

Example 31 with RequestContext

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

Example 32 with RequestContext

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

Example 33 with RequestContext

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

Example 34 with RequestContext

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

Example 35 with RequestContext

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