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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations