use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class HopByHopHeadersRemovingInterceptorTest method removesAllFieldsWhenMultipleInstancesArePresent.
@Test
public void removesAllFieldsWhenMultipleInstancesArePresent() {
LiveHttpRequest request = delete("/foo").header(PROXY_AUTHENTICATE, "foo").header(PROXY_AUTHENTICATE, "bar").header(PROXY_AUTHENTICATE, "baz").build();
LiveHttpRequest interceptedRequest = interceptRequest(request);
assertThat(interceptedRequest.header(PROXY_AUTHENTICATE), isAbsent());
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class BackendServicesRouterTest method selectsUsingSingleSlashPath.
@Test
public void selectsUsingSingleSlashPath() throws Exception {
Registry.Changes<BackendService> changes = added(appA().newCopy().path("/").build(), appB().newCopy().path("/appB/hotel/details.html").build());
BackendServicesRouter router = new BackendServicesRouter(serviceClientFactory, environment, executor);
router.onChange(changes);
LiveHttpRequest request = get("/").build();
Optional<HttpHandler> route = router.route(request, context);
assertThat(proxyTo(route, request).header(ORIGIN_ID_DEFAULT), isValue(APP_A));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class HttpErrorStatusCauseLoggerTest method logsOtherExceptionsWithoutRequest.
@Test
public void logsOtherExceptionsWithoutRequest() {
LiveHttpRequest request = LiveHttpRequest.get("/foo").build();
Exception exception = new Exception("This is just a test");
httpErrorStatusCauseLogger.proxyErrorOccurred(request, InetSocketAddress.createUnresolved("127.0.0.1", 0), BAD_GATEWAY, exception);
assertThat(loggingTestSupport.log(), hasItem(loggingEvent(ERROR, "Failure status=\"502 Bad Gateway\", exception=\"java.lang.Exception.*This is just a test.*\"")));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class HttpErrorStatusMetricsTest method updatesCountersForProxyErrorsWithResponse.
@Test
public void updatesCountersForProxyErrorsWithResponse() {
LiveHttpRequest request = get("/foo").build();
errorListener.proxyErrorOccurred(request, InetSocketAddress.createUnresolved("127.0.0.1", 0), INTERNAL_SERVER_ERROR, new CustomException());
assertThat(count(ERROR), is(1));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class StyxServerTest method serverDoesNotStartUntilPluginsAreStarted.
@Test
public void serverDoesNotStartUntilPluginsAreStarted() throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
StyxServer styxServer = styxServerWithPlugins(Map.of("slowlyStartingPlugin", new Plugin() {
@Override
public void styxStarting() {
try {
latch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public Eventual<LiveHttpResponse> intercept(LiveHttpRequest request1, Chain chain) {
return Eventual.of(response(OK).build());
}
}));
try {
styxServer.startAsync();
Thread.sleep(10);
assertThat(styxServer.proxyHttpAddress(), nullValue());
latch.countDown();
eventually(() -> assertThat(styxServer.proxyHttpAddress().getPort(), is(greaterThan(0))));
} finally {
stopIfRunning(styxServer);
}
}
Aggregations