use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class StyxHttpClientTest method sendsMessagesInAbsoluteUrlFormat.
@Disabled
@Test
public /*
* Wiremock (or Jetty server) origin converts an absolute URL to an origin
* form. Therefore we are unable to use an origin to verify that client used
* an absolute URL. However I (Mikko) have verified with WireShark that the
* request is indeed sent in absolute form.
*/
void sendsMessagesInAbsoluteUrlFormat() throws ExecutionException, InterruptedException {
HttpResponse response = new StyxHttpClient.Builder().build().send(get(format("http://%s/index.html", hostString(server.port()))).build()).get();
assertThat(response.status(), is(OK));
server.verify(getRequestedFor(urlEqualTo(format("http://%s/index.html", hostString(server.port())))).withHeader("Host", equalTo(hostString(server.port()))));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class StyxHttpClientTest method overridesTlsSettingsWithSecure.
/*
* StyxHttpClientTransaction
* - secure() method applies default TLS settings
*/
@Test
public void overridesTlsSettingsWithSecure() throws ExecutionException, InterruptedException {
StyxHttpClient client = new StyxHttpClient.Builder().build();
HttpResponse response = client.secure().send(secureRequest).get();
assertThat(response.status(), is(OK));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class StyxHttpClientTest method overridesTlsSettingsWithSecureBoolean.
/*
* StyxHttpClientTransaction
* - secure(true) applies default TLS settings
*/
@Test
public void overridesTlsSettingsWithSecureBoolean() throws ExecutionException, InterruptedException {
StyxHttpClient client = new StyxHttpClient.Builder().build();
HttpResponse response = client.secure(true).send(secureRequest).get();
assertThat(response.status(), is(OK));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class StyxHttpClientTest method overridesTlsSettingsWithSecureBooleanFalse.
/*
* StyxHttpClientTransaction
* - secure(false) disables TLS protection
*/
@Test
public void overridesTlsSettingsWithSecureBooleanFalse() throws ExecutionException, InterruptedException {
StyxHttpClient client = new StyxHttpClient.Builder().tlsSettings(new TlsSettings.Builder().build()).build();
HttpResponse response = client.secure(false).send(httpRequest).get();
assertThat(response.status(), is(OK));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class MockOriginServerTest method configuresEndpoints.
@Test
public void configuresEndpoints() {
server = MockOriginServer.create("", "", 0, new HttpConnectorConfig(0)).start().stub(WireMock.get(urlMatching("/.*")), aResponse().withStatus(200).withHeader("a", "b").withBody("Hello, World!"));
HttpResponse response = await(client.sendRequest(get(format("http://localhost:%d/mock", server.port())).header("X-Forwarded-Proto", "http").build()));
assertThat(response.status(), is(OK));
assertThat(response.header("a"), is(Optional.of("b")));
assertThat(response.bodyAs(UTF_8), is("Hello, World!"));
server.verify(getRequestedFor(urlEqualTo("/mock")).withHeader("X-Forwarded-Proto", valueMatchingStrategy("http")));
}
Aggregations