Search in sources :

Example 11 with Response

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

the class RequestSecurityManagerImplTest method check_page_security.

@Test(dataProvider = "check_page_security_data")
public void check_page_security(boolean secureRequest, boolean securePage, LinkSecurity expectedLinkSecurity) {
    Request request = mockRequest();
    Response response = mockResponse();
    MetaDataLocator locator = mockMetaDataLocator();
    ComponentEventLinkEncoder encoder = newMock(ComponentEventLinkEncoder.class);
    train_isSecure(request, secureRequest);
    train_isSecure(locator, PAGE_NAME, securePage);
    replay();
    RequestSecurityManager manager = new RequestSecurityManagerImpl(request, response, encoder, locator, true);
    assertEquals(manager.checkPageSecurity(PAGE_NAME), expectedLinkSecurity);
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) ComponentEventLinkEncoder(org.apache.tapestry5.services.ComponentEventLinkEncoder) Request(org.apache.tapestry5.http.services.Request) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Example 12 with Response

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

the class RequestSecurityManagerImplTest method check_page_not_secure.

@Test
public void check_page_not_secure() throws Exception {
    Request request = mockRequest();
    Response response = mockResponse();
    MetaDataLocator locator = mockMetaDataLocator();
    ComponentEventLinkEncoder encoder = newMock(ComponentEventLinkEncoder.class);
    train_isSecure(request, false);
    train_isSecure(locator, PAGE_NAME, false);
    replay();
    PageRenderRequestParameters parameters = new PageRenderRequestParameters(PAGE_NAME, new EmptyEventContext(), false);
    RequestSecurityManager manager = new RequestSecurityManagerImpl(request, response, encoder, locator, true);
    assertFalse(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) Test(org.testng.annotations.Test)

Example 13 with Response

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

the class ResponseRendererImplTest method render_page_markup.

@Test
public void render_page_markup() throws Exception {
    RequestPageCache cache = mockRequestPageCache();
    PageContentTypeAnalyzer analyzer = mockPageContentTypeAnalyzer();
    String pageName = "foo/bar";
    Page page = mockPage();
    PageResponseRenderer pageResponseRenderer = mockPageResponseRenderer();
    Response response = mockResponse();
    train_get(cache, pageName, page);
    pageResponseRenderer.renderPageResponse(page);
    replay();
    ResponseRenderer renderer = new ResponseRendererImpl(cache, analyzer, pageResponseRenderer);
    renderer.renderPageMarkupResponse(pageName);
    verify();
}
Also used : Response(org.apache.tapestry5.http.services.Response) ResponseRenderer(org.apache.tapestry5.services.ResponseRenderer) Page(org.apache.tapestry5.internal.structure.Page) Test(org.testng.annotations.Test)

Example 14 with Response

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

the class StaticFilesFilterTest method existing_file.

@Test
public void existing_file() throws Exception {
    URL url = new URL("file://.");
    String path = "/cell.gif";
    Request request = newRequest(path);
    Response response = mockResponse();
    RequestHandler handler = mockRequestHandler();
    Context context = mockContext();
    train_getResource(context, path, url);
    replay();
    RequestFilter filter = new StaticFilesFilter(context);
    assertFalse(filter.service(request, response, handler));
    verify();
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.apache.tapestry5.http.services.Response) Context(org.apache.tapestry5.http.services.Context) RequestHandler(org.apache.tapestry5.http.services.RequestHandler) Request(org.apache.tapestry5.http.services.Request) URL(java.net.URL) RequestFilter(org.apache.tapestry5.http.services.RequestFilter) Test(org.testng.annotations.Test)

Example 15 with Response

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

the class StaticFilesFilterTest method colon_in_path_prevents_static_file_check.

/**
 * TAPESTRY-2606
 */
@Test
public void colon_in_path_prevents_static_file_check() throws Exception {
    String path = "/start.update:anevent";
    Request request = newRequest(path);
    Response response = mockResponse();
    RequestHandler handler = mockRequestHandler();
    Context context = mockContext();
    train_service(handler, request, response, true);
    replay();
    RequestFilter filter = new StaticFilesFilter(context);
    assertTrue(filter.service(request, response, handler));
    verify();
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.apache.tapestry5.http.services.Response) Context(org.apache.tapestry5.http.services.Context) RequestHandler(org.apache.tapestry5.http.services.RequestHandler) Request(org.apache.tapestry5.http.services.Request) RequestFilter(org.apache.tapestry5.http.services.RequestFilter) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)53 Response (org.apache.tapestry5.http.services.Response)47 Request (org.apache.tapestry5.http.services.Request)25 Link (org.apache.tapestry5.http.Link)23 HttpServletResponse (javax.servlet.http.HttpServletResponse)16 LocalizationSetter (org.apache.tapestry5.services.LocalizationSetter)12 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)12 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)11 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)11 EmptyEventContext (org.apache.tapestry5.internal.EmptyEventContext)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 RequestFilter (org.apache.tapestry5.http.services.RequestFilter)8 RequestHandler (org.apache.tapestry5.http.services.RequestHandler)8 JSONObject (org.apache.tapestry5.json.JSONObject)8 Context (org.apache.tapestry5.http.services.Context)7 Dispatcher (org.apache.tapestry5.http.services.Dispatcher)7 ComponentEventLinkEncoder (org.apache.tapestry5.services.ComponentEventLinkEncoder)7 ComponentEventRequestParameters (org.apache.tapestry5.services.ComponentEventRequestParameters)6 ComponentRequestHandler (org.apache.tapestry5.services.ComponentRequestHandler)6 IOException (java.io.IOException)5