Search in sources :

Example 1 with HttpConnectorConfig

use of com.hotels.styx.server.HttpConnectorConfig 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")));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) HttpConnectorConfig(com.hotels.styx.server.HttpConnectorConfig) Test(org.junit.jupiter.api.Test)

Example 2 with HttpConnectorConfig

use of com.hotels.styx.server.HttpConnectorConfig in project styx by ExpediaGroup.

the class StyxServerTest method styxConfig.

private static StyxConfig styxConfig() {
    ProxyServerConfig proxyConfig = new ProxyServerConfig.Builder().setHttpConnector(new HttpConnectorConfig(0)).build();
    AdminServerConfig adminConfig = new AdminServerConfig.Builder().setHttpConnector(new HttpConnectorConfig(0)).build();
    Configuration config = new MapBackedConfiguration(EMPTY_CONFIGURATION).set("admin", adminConfig).set("proxy", proxyConfig);
    return new StyxConfig(config);
}
Also used : AdminServerConfig(com.hotels.styx.admin.AdminServerConfig) Configuration(com.hotels.styx.api.configuration.Configuration) MapBackedConfiguration(com.hotels.styx.api.configuration.Configuration.MapBackedConfiguration) ProxyServerConfig(com.hotels.styx.proxy.ProxyServerConfig) MapBackedConfiguration(com.hotels.styx.api.configuration.Configuration.MapBackedConfiguration) HttpConnectorConfig(com.hotels.styx.server.HttpConnectorConfig)

Aggregations

HttpConnectorConfig (com.hotels.styx.server.HttpConnectorConfig)2 AdminServerConfig (com.hotels.styx.admin.AdminServerConfig)1 HttpResponse (com.hotels.styx.api.HttpResponse)1 Configuration (com.hotels.styx.api.configuration.Configuration)1 MapBackedConfiguration (com.hotels.styx.api.configuration.Configuration.MapBackedConfiguration)1 ProxyServerConfig (com.hotels.styx.proxy.ProxyServerConfig)1 Test (org.junit.jupiter.api.Test)1