Search in sources :

Example 1 with TesterRequest

use of org.apache.tomcat.unittest.TesterRequest in project tomcat70 by apache.

the class TestResponse method testBug53062g.

@Test
public void testBug53062g() throws Exception {
    Request req = new TesterRequest();
    Response resp = new Response();
    resp.setRequest(req);
    String result = resp.toAbsolute("bar.html?x=/../");
    Assert.assertEquals("http://localhost:8080/level1/level2/bar.html?x=/../", result);
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) TesterRequest(org.apache.tomcat.unittest.TesterRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) TesterRequest(org.apache.tomcat.unittest.TesterRequest) TomcatBaseTest(org.apache.catalina.startup.TomcatBaseTest) Test(org.junit.Test)

Example 2 with TesterRequest

use of org.apache.tomcat.unittest.TesterRequest in project tomcat70 by apache.

the class TestResponse method doTestEncodeURL.

private void doTestEncodeURL(String location, String expected) {
    Request req = new TesterRequest(true);
    req.setRequestedSessionId("1234");
    req.setRequestedSessionURL(true);
    Response resp = new Response();
    resp.setRequest(req);
    String result = resp.encodeURL(location);
    Assert.assertEquals(expected, result);
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) TesterRequest(org.apache.tomcat.unittest.TesterRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) TesterRequest(org.apache.tomcat.unittest.TesterRequest)

Example 3 with TesterRequest

use of org.apache.tomcat.unittest.TesterRequest in project tomcat70 by apache.

the class TestResponse method testBug53062d.

@Test
public void testBug53062d() throws Exception {
    Request req = new TesterRequest();
    Response resp = new Response();
    resp.setRequest(req);
    String result = resp.toAbsolute(".././..");
    Assert.assertEquals("http://localhost:8080/", result);
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) TesterRequest(org.apache.tomcat.unittest.TesterRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) TesterRequest(org.apache.tomcat.unittest.TesterRequest) TomcatBaseTest(org.apache.catalina.startup.TomcatBaseTest) Test(org.junit.Test)

Example 4 with TesterRequest

use of org.apache.tomcat.unittest.TesterRequest in project tomcat70 by apache.

the class TestResponse method testBug53062h.

@Test
public void testBug53062h() throws Exception {
    Request req = new TesterRequest();
    Response resp = new Response();
    resp.setRequest(req);
    String result = resp.toAbsolute("bar.html?x=/../../");
    Assert.assertEquals("http://localhost:8080/level1/level2/bar.html?x=/../../", result);
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) TesterRequest(org.apache.tomcat.unittest.TesterRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) TesterRequest(org.apache.tomcat.unittest.TesterRequest) TomcatBaseTest(org.apache.catalina.startup.TomcatBaseTest) Test(org.junit.Test)

Example 5 with TesterRequest

use of org.apache.tomcat.unittest.TesterRequest in project tomcat70 by apache.

the class TestResponse method testBug53062f.

@Test
public void testBug53062f() throws Exception {
    Request req = new TesterRequest();
    Response resp = new Response();
    resp.setRequest(req);
    String result = resp.toAbsolute("bar.html");
    Assert.assertEquals("http://localhost:8080/level1/level2/bar.html", result);
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) TesterRequest(org.apache.tomcat.unittest.TesterRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) TesterRequest(org.apache.tomcat.unittest.TesterRequest) TomcatBaseTest(org.apache.catalina.startup.TomcatBaseTest) Test(org.junit.Test)

Aggregations

TesterRequest (org.apache.tomcat.unittest.TesterRequest)50 Test (org.junit.Test)46 TomcatBaseTest (org.apache.catalina.startup.TomcatBaseTest)42 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)20 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)20 HttpServletRequest (javax.servlet.http.HttpServletRequest)20 HttpServletResponse (javax.servlet.http.HttpServletResponse)20 Locale (java.util.Locale)4 TesterContext (org.apache.tomcat.unittest.TesterContext)3 ArrayList (java.util.ArrayList)2 Context (org.apache.catalina.Context)2 Response (org.apache.catalina.connector.Response)2 LoggingBaseTest (org.apache.catalina.startup.LoggingBaseTest)2 TesterMapRealm (org.apache.catalina.startup.TesterMapRealm)2 TesterResponse (org.apache.tomcat.unittest.TesterResponse)2 SecurityConstraint (org.apache.tomcat.util.descriptor.web.SecurityConstraint)2 ServletSecurityElement (jakarta.servlet.ServletSecurityElement)1 ServletSecurity (jakarta.servlet.annotation.ServletSecurity)1 URI (java.net.URI)1 HashSet (java.util.HashSet)1