use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.
the class GenericSecureIntegrationTest method testGetHiAfterFilter.
@Test
public void testGetHiAfterFilter() throws Exception {
UrlResponse response = testUtil.doMethodSecure("GET", "/hi", null);
Assert.assertTrue(response.headers.get("after").contains("foobar"));
}
use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.
the class GenericSecureIntegrationTest method testUnauthorized.
@Test
public void testUnauthorized() throws Exception {
UrlResponse urlResponse = testUtil.doMethodSecure("GET", "/protected/resource", null);
Assert.assertTrue(urlResponse.status == 401);
}
use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.
the class GenericSecureIntegrationTest method testXForwardedFor.
@Test
public void testXForwardedFor() throws Exception {
final String xForwardedFor = "XXX.XXX.XXX.XXX";
Map<String, String> headers = new HashMap<>();
headers.put("X-Forwarded-For", xForwardedFor);
UrlResponse response = testUtil.doMethod("GET", "/ip", null, true, "text/html", headers);
Assert.assertEquals(xForwardedFor, response.body);
response = testUtil.doMethod("GET", "/ip", null, true, "text/html", null);
Assert.assertNotEquals(xForwardedFor, response.body);
}
use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.
the class ServletTest method testUnauthorized.
@Test
public void testUnauthorized() throws Exception {
UrlResponse urlResponse = testUtil.doMethod("GET", SOMEPATH + "/protected/resource", null);
Assert.assertTrue(urlResponse.status == 401);
}
use of spark.util.SparkTestUtil.UrlResponse in project spark by perwendel.
the class ServletTest method testEchoParam1.
@Test
public void testEchoParam1() throws Exception {
UrlResponse response = testUtil.doMethod("GET", SOMEPATH + "/shizzy", null);
Assert.assertEquals(200, response.status);
Assert.assertEquals("echo: shizzy", response.body);
}
Aggregations