Search in sources :

Example 1 with StyxHttpClient

use of com.hotels.styx.client.StyxHttpClient in project styx by ExpediaGroup.

the class StyxServerTest method proxiesToOriginViaHttps.

@Test
public void proxiesToOriginViaHttps() {
    BackendService backendService = new BackendService().ssl().addOrigin(secureOriginServer.httpsPort());
    styxServer = new StyxServer.Builder().addRoute("/", backendService).start();
    StyxHttpClient tlsClient = new StyxHttpClient.Builder().tlsSettings(new TlsSettings.Builder().build()).build();
    HttpResponse response = await(tlsClient.sendRequest(get(format("https://localhost:%d/", styxServer.proxyHttpsPort())).build()));
    assertThat(response.status(), is(OK));
    configureFor(secureOriginServer.port());
    WireMock.verify(getRequestedFor(urlPathEqualTo("/")));
}
Also used : StyxHttpClient(com.hotels.styx.client.StyxHttpClient) HttpResponse(com.hotels.styx.api.HttpResponse) LiveHttpResponse(com.hotels.styx.api.LiveHttpResponse) TlsSettings(com.hotels.styx.api.extension.service.TlsSettings) Test(org.junit.jupiter.api.Test)

Example 2 with StyxHttpClient

use of com.hotels.styx.client.StyxHttpClient 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);
}
Also used : StyxHttpClient(com.hotels.styx.client.StyxHttpClient) HttpResponse(com.hotels.styx.api.HttpResponse)

Example 3 with StyxHttpClient

use of com.hotels.styx.client.StyxHttpClient in project styx by ExpediaGroup.

the class StyxServerTest method startsProxyOnSpecifiedHttpsPort.

@Test
public void startsProxyOnSpecifiedHttpsPort() {
    styxServer = new StyxServer.Builder().proxyHttpsPort(0).addRoute("/", originServer1.port()).start();
    StyxHttpClient tlsClient = new StyxHttpClient.Builder().tlsSettings(new TlsSettings.Builder().build()).build();
    HttpResponse response = await(tlsClient.sendRequest(get(format("https://localhost:%d/", styxServer.proxyHttpsPort())).build()));
    assertThat(response.status(), is(OK));
}
Also used : StyxHttpClient(com.hotels.styx.client.StyxHttpClient) HttpResponse(com.hotels.styx.api.HttpResponse) LiveHttpResponse(com.hotels.styx.api.LiveHttpResponse) TlsSettings(com.hotels.styx.api.extension.service.TlsSettings) Test(org.junit.jupiter.api.Test)

Aggregations

HttpResponse (com.hotels.styx.api.HttpResponse)3 StyxHttpClient (com.hotels.styx.client.StyxHttpClient)3 LiveHttpResponse (com.hotels.styx.api.LiveHttpResponse)2 TlsSettings (com.hotels.styx.api.extension.service.TlsSettings)2 Test (org.junit.jupiter.api.Test)2