Search in sources :

Example 96 with Request

use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.

the class RequestSecurityManagerImplTest method link_security_when_security_is_disabled.

/**
 * https://issues.apache.org/jira/browse/TAP5-1511
 */
@Test(dataProvider = "security_disabled_data")
public void link_security_when_security_is_disabled(boolean secureRequest, LinkSecurity expectedLinkSecurity) {
    Request request = mockRequest();
    Response response = mockResponse();
    MetaDataLocator locator = mockMetaDataLocator();
    train_isSecure(request, secureRequest);
    replay();
    RequestSecurityManager manager = new RequestSecurityManagerImpl(request, response, null, locator, false);
    assertEquals(manager.checkPageSecurity(PAGE_NAME), expectedLinkSecurity);
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) Request(org.apache.tapestry5.http.services.Request) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Example 97 with Request

use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.

the class RequestSecurityManagerImplTest method check_redirect_needed.

@Test
public void check_redirect_needed() throws Exception {
    Request request = mockRequest();
    Response response = mockResponse();
    MetaDataLocator locator = mockMetaDataLocator();
    Link link = mockLink();
    ComponentEventLinkEncoder encoder = newMock(ComponentEventLinkEncoder.class);
    train_isSecure(request, false);
    train_isSecure(locator, PAGE_NAME, true);
    PageRenderRequestParameters parameters = new PageRenderRequestParameters(PAGE_NAME, new EmptyEventContext(), false);
    train_createPageRenderLink(encoder, parameters, link);
    response.sendRedirect(link);
    replay();
    RequestSecurityManager manager = new RequestSecurityManagerImpl(request, response, encoder, locator, true);
    assertTrue(manager.checkForInsecurePageRenderRequest(parameters));
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) PageRenderRequestParameters(org.apache.tapestry5.services.PageRenderRequestParameters) ComponentEventLinkEncoder(org.apache.tapestry5.services.ComponentEventLinkEncoder) EmptyEventContext(org.apache.tapestry5.internal.EmptyEventContext) Request(org.apache.tapestry5.http.services.Request) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Link(org.apache.tapestry5.http.Link) Test(org.testng.annotations.Test)

Example 98 with Request

use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.

the class RequestImplTest method isSessionInvalidated_is_true_when_session_is_invalid.

@Test
public void isSessionInvalidated_is_true_when_session_is_invalid() {
    HttpServletRequest sr = mockHttpServletRequest();
    Session session = mockSession();
    TapestrySessionFactory sf = newMock(TapestrySessionFactory.class);
    expect(sf.getSession(false)).andReturn(session);
    expect(session.isInvalidated()).andReturn(true);
    replay();
    Request request = new RequestImpl(sr, CHARSET, sf);
    assertTrue(request.isSessionInvalidated());
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TapestrySessionFactory(org.apache.tapestry5.http.internal.services.TapestrySessionFactory) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.http.services.Request) RequestImpl(org.apache.tapestry5.http.internal.services.RequestImpl) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.tapestry5.http.services.Session) Test(org.testng.annotations.Test)

Example 99 with Request

use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.

the class RequestImplTest method isSessionInvalidated_is_false_when_no_session_at_all.

@Test
public void isSessionInvalidated_is_false_when_no_session_at_all() {
    HttpServletRequest sr = mockHttpServletRequest();
    TapestrySessionFactory sf = newMock(TapestrySessionFactory.class);
    expect(sf.getSession(false)).andReturn(null);
    replay();
    Request request = new RequestImpl(sr, CHARSET, sf);
    assertFalse(request.isSessionInvalidated());
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TapestrySessionFactory(org.apache.tapestry5.http.internal.services.TapestrySessionFactory) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.http.services.Request) RequestImpl(org.apache.tapestry5.http.internal.services.RequestImpl) Test(org.testng.annotations.Test)

Example 100 with Request

use of org.apache.tapestry5.http.services.Request in project tapestry-5 by apache.

the class RequestImplTest method get_path_for_websphere_with_nonempty_path.

/**
 * TAPESTRY-1713
 */
@Test
public void get_path_for_websphere_with_nonempty_path() {
    HttpServletRequest sr = mockHttpServletRequest();
    train_getPathInfo(sr, "");
    replay();
    Request request = new RequestImpl(sr, CHARSET, null);
    assertEquals(request.getPath(), "/");
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.http.services.Request) RequestImpl(org.apache.tapestry5.http.internal.services.RequestImpl) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)86 Request (org.apache.tapestry5.http.services.Request)83 Response (org.apache.tapestry5.http.services.Response)25 HttpServletRequest (javax.servlet.http.HttpServletRequest)19 LocalizationSetter (org.apache.tapestry5.services.LocalizationSetter)19 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)18 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)17 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)15 HttpServletResponse (javax.servlet.http.HttpServletResponse)14 Session (org.apache.tapestry5.http.services.Session)14 Link (org.apache.tapestry5.http.Link)12 RequestImpl (org.apache.tapestry5.http.internal.services.RequestImpl)11 ComponentEventRequestParameters (org.apache.tapestry5.services.ComponentEventRequestParameters)9 Context (org.apache.tapestry5.http.services.Context)8 RequestFilter (org.apache.tapestry5.http.services.RequestFilter)8 RequestHandler (org.apache.tapestry5.http.services.RequestHandler)8 IOException (java.io.IOException)7 BaseURLSourceImpl (org.apache.tapestry5.http.internal.services.BaseURLSourceImpl)7 BaseURLSource (org.apache.tapestry5.http.services.BaseURLSource)7 Dispatcher (org.apache.tapestry5.http.services.Dispatcher)7