use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class ProtocolMetricsTest method recordsServerSideHttp.
@Test
public void recordsServerSideHttp() {
styxServer = new StyxServer.Builder().addRoute("/", origin.port()).start();
HttpResponse response = doGet("/");
assertThat(response.status(), is(OK));
assertThat(styxServer.metrics().meter("styx.server.http.requests").getCount(), is(1L));
assertThat(styxServer.metrics().meter("styx.server.https.requests").getCount(), is(0L));
assertThat(styxServer.metrics().meter("styx.server.http.responses.200").getCount(), is(1L));
assertThat(styxServer.metrics().meter("styx.server.https.responses.200").getCount(), is(0L));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class StyxMetrics method downloadJsonString.
private static String downloadJsonString(String host, int port) {
StyxHttpClient client = new StyxHttpClient.Builder().build();
HttpResponse response = await(client.sendRequest(get(format("http://%s:%d/admin/metrics", host, port)).build()));
return response.bodyAs(UTF_8);
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class ClassPathResourceHandlerTest method removesDuplicatePathSeparators.
@Test
void removesDuplicatePathSeparators() {
HttpResponse response = Mono.from(new ClassPathResourceHandler("/a/prefix/", "/admin/dashboard").handle(get("/a/prefix/expected.txt").build(), requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(body(response), is("Foo\nBar\n"));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class ClassPathResourceHandlerTest method returnsForbiddenIfPrefixedRequestAttemptsToAccessResourcesOutsidePermittedRoot.
@ParameterizedTest
@MethodSource("forbiddenPaths")
void returnsForbiddenIfPrefixedRequestAttemptsToAccessResourcesOutsidePermittedRoot(String path) {
HttpResponse response = Mono.from(new ClassPathResourceHandler("/admin/dashboard", "/admin/dashboard").handle(get(path).build(), requestContext())).block();
assertThat(response.status(), is(FORBIDDEN));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class ClassPathResourceHandlerTest method returns403IfTryingToAccessResourcesOutsidePermittedRoot.
@ParameterizedTest
@MethodSource("forbiddenPaths")
void returns403IfTryingToAccessResourcesOutsidePermittedRoot(String path) {
HttpResponse response = Mono.from(new ClassPathResourceHandler("/admin/dashboard").handle(get(path).build(), requestContext())).block();
assertThat(response.status(), is(FORBIDDEN));
}
Aggregations