use of com.google.cloud.runtime.jetty.test.annotation.RemoteOnly in project jetty-runtime by GoogleCloudPlatform.
the class ConfigurationIntegrationTest method testNoDirectoryListing.
/**
* Simple test validating no directory listing.
*
* @throws IOException test in error
*/
@Test
@RemoteOnly
public void testNoDirectoryListing() throws IOException {
URI target = getUri().resolve("/directory/");
assertThat(target.getPath(), containsString("/directory/"));
HttpURLConnection http = HttpUrlUtil.openTo(target);
assertThat(http.getResponseCode(), is(403));
}
use of com.google.cloud.runtime.jetty.test.annotation.RemoteOnly in project jetty-runtime by GoogleCloudPlatform.
the class ForwardedIntegrationTest method testForwardedIgnored.
/**
* Validate Forwarded header is ignored.
*
* @throws IOException test in error
*/
@Test
@RemoteOnly
public void testForwardedIgnored() throws IOException {
URI target = getUri().resolve("/dump/info");
assertThat(target.getPath(), containsString("/dump/info"));
HttpURLConnection http = HttpUrlUtil.openTo(target);
http.setRequestProperty("Forwarded", "for=1.2.3.4;by=1.1.1.1;proto=https;host=example.com");
assertThat(http.getResponseCode(), is(200));
String responseBody = HttpUrlUtil.getResponseBody(http);
// Test forwarded header is ignored
assertThat(responseBody, not(containsString("remoteHost/Addr:port=1.2.3.4")));
assertThat(responseBody, containsString("scheme=http(secure=false)"));
}
use of com.google.cloud.runtime.jetty.test.annotation.RemoteOnly in project jetty-runtime by GoogleCloudPlatform.
the class ForwardedIntegrationTest method testRemoteFor.
/**
* Validate proxy for header is handled.
*
* @throws IOException test in error
*/
@Test
@RemoteOnly
public void testRemoteFor() throws IOException {
URI target = getUri().resolve("/dump/info");
assertThat(target.getPath(), containsString("/dump/info"));
HttpURLConnection http = HttpUrlUtil.openTo(target);
http.setRequestProperty("X-Forwarded-For", "1.2.3.4, 5.6.7.8");
assertThat(http.getResponseCode(), is(200));
String responseBody = HttpUrlUtil.getResponseBody(http);
// Test that the client is trusted to say what their IP is
assertThat(responseBody, containsString("remoteHost/Addr:port=1.2.3.4"));
// Test GFE IP is added to the forwarded list by looking for trailing comma
assertThat(responseBody, containsString("X-Forwarded-For: 1.2.3.4, 5.6.7.8,"));
}
use of com.google.cloud.runtime.jetty.test.annotation.RemoteOnly in project jetty-runtime by GoogleCloudPlatform.
the class LocalRemoteTestRunner method runChild.
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
Description description = describeChild(method);
// check Ignore first
if (method.getAnnotation(Ignore.class) != null) {
notify("@Ignore", description);
notifier.fireTestIgnored(description);
} else if (localTestsEnabled && method.getAnnotation(RemoteOnly.class) != null) {
// if running in local mode and @RemoteOnly annotation exists, ignore
notify("Skip @RemoteOnly", description);
notifier.fireTestIgnored(description);
} else if (remoteTestsEnabled && method.getAnnotation(LocalOnly.class) != null) {
// if running in remote mode and @LocalOnly annotation exists, ignore
notify("Skip @LocalOnly", description);
notifier.fireTestIgnored(description);
} else {
// default is run in either mode
notify("Test[" + mode + "]", description);
super.runChild(method, notifier);
}
}
use of com.google.cloud.runtime.jetty.test.annotation.RemoteOnly in project jetty-runtime by GoogleCloudPlatform.
the class ForwardedIntegrationTest method testRemoteUserProto.
/**
* Validate proxy proto header is handled.
*
* @throws IOException test in error
*/
@Test
@RemoteOnly
public void testRemoteUserProto() throws IOException {
URI target = getUri().resolve("/dump/info");
assertThat(target.getPath(), containsString("/dump/info"));
// Check that user provided X-Forwarded-Proto is ignored
HttpURLConnection http = HttpUrlUtil.openTo(target);
http.setRequestProperty("X-Forwarded-Proto", "https");
assertThat(http.getResponseCode(), is(200));
String responseBody = HttpUrlUtil.getResponseBody(http);
assertThat(responseBody, containsString("scheme=http(secure=false)"));
}
Aggregations