use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class XForwardedRequestWrapperTest method test7.
/**
* @throws Exception
*/
@Test
public void test7() throws Exception {
MyApplication app = new MyApplication();
tester = new WicketTester(app);
app.factory.getConfig().setAllowedInternalProxies("192\\.168\\.0\\.10, 192\\.168\\.0\\.11");
app.factory.getConfig().setRemoteIPHeader("x-forwarded-for");
app.factory.getConfig().setProxiesHeader("x-forwarded-by");
app.factory.getConfig().setTrustedProxies("proxy1, proxy2");
request.setRemoteAddr("192.168.0.10");
request.addHeader("x-forwarded-for", "140.211.11.130, untrusted-proxy, proxy1");
tester.startPage(SimplePage.class);
tester.assertRenderedPage(SimplePage.class);
tester.assertResultPage(SimplePage.class, "SimplePageExpectedResult.html");
MockHttpServletResponse resp = tester.getResponse();
// @TODO should there be any header in the response ????
// assertEquals("140.211.11.130", resp.getHeader("x-forwarded-for"));
// assertEquals("proxy1", resp.getHeader("x-forwarded-by"));
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class HttpsMapperApplicationTest method switchHttpToHttpsWithCustomPorts.
@Test
public void switchHttpToHttpsWithCustomPorts() {
WicketTester tester = new WicketTester(new HttpsMapperApplication(123, 456));
tester.getRequest().setScheme("http");
tester.getRequest().setServerPort(123);
requestPage(tester, HttpsPage.class);
assertEquals("https", tester.getLastRequest().getScheme());
assertEquals(456, tester.getLastRequest().getServerPort());
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class HttpsMapperApplicationTest method switchHttpToHttpsWithDefaultPorts.
@Test
public void switchHttpToHttpsWithDefaultPorts() {
WicketTester tester = new WicketTester(new HttpsMapperApplication());
tester.getRequest().setScheme("http");
requestPage(tester, HttpsPage.class);
assertEquals("https", tester.getLastRequest().getScheme());
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class HttpsMapperApplicationTest method switchHttpsToHttpWithDefaultPorts.
@Test
public void switchHttpsToHttpWithDefaultPorts() {
WicketTester tester = new WicketTester(new HttpsMapperApplication());
tester.getRequest().setScheme("https");
tester.getRequest().setServerPort(443);
requestPage(tester, HttpPage.class);
assertEquals("http", tester.getLastRequest().getScheme());
}
use of org.apache.wicket.util.tester.WicketTester in project wicket by apache.
the class ResponseIOExceptionTest method before.
/**
* @throws Exception
*/
@Before
public void before() throws Exception {
tester = new WicketTester() {
@Override
protected Response newServletWebResponse(ServletWebRequest servletWebRequest) {
return new ProblematicResponse(servletWebRequest, getResponse());
}
};
tester.setExposeExceptions(false);
}
Aggregations