Search in sources :

Example 41 with HttpResponse

use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.

the class StyxServerTest method startsAdminOnSpecifiedHttpPort.

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

Example 42 with HttpResponse

use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.

the class StyxServerTest method proxiesToOriginViaHttpsWithRequestOriginallyHttp.

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

Example 43 with HttpResponse

use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.

the class StyxServerTest method addsPluginsLinkToAdminIndex.

@Test
public void addsPluginsLinkToAdminIndex() {
    styxServer = new StyxServer.Builder().addRoute("/", originServer1.port()).start();
    HttpResponse response = doAdminRequest("/");
    assertThat(response.status(), is(OK));
    assertThat(response.bodyAs(UTF_8), containsString("/admin/plugins"));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) LiveHttpResponse(com.hotels.styx.api.LiveHttpResponse) Test(org.junit.jupiter.api.Test)

Example 44 with HttpResponse

use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.

the class StyxServerTest method startsProxyOnSpecifiedHttpPort.

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

Example 45 with HttpResponse

use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.

the class StyxServerTest method addsPluginLinkToPluginsIndex.

@Test
public void addsPluginLinkToPluginsIndex() {
    setUpStyxAndPlugins("plugin-foo", "plugin-bar", "plugin-baz");
    HttpResponse response = doAdminRequest("/admin/plugins");
    assertThat(response.status(), is(OK));
    assertThat(response.bodyAs(UTF_8), allOf(containsString("/admin/plugins/plugin-foo"), containsString("/admin/plugins/plugin-bar"), containsString("/admin/plugins/plugin-baz")));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) LiveHttpResponse(com.hotels.styx.api.LiveHttpResponse) Test(org.junit.jupiter.api.Test)

Aggregations

HttpResponse (com.hotels.styx.api.HttpResponse)107 Test (org.junit.jupiter.api.Test)99 LiveHttpResponse (com.hotels.styx.api.LiveHttpResponse)30 HttpRequest (com.hotels.styx.api.HttpRequest)18 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 Eventual (com.hotels.styx.api.Eventual)10 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)9 StyxHttpClient (com.hotels.styx.client.StyxHttpClient)8 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)8 TlsSettings (com.hotels.styx.api.extension.service.TlsSettings)7 StyxObjectRecord (com.hotels.styx.StyxObjectRecord)6 HttpHandler (com.hotels.styx.api.HttpHandler)6 LiveHttpRequest (com.hotels.styx.api.LiveHttpRequest)6 OK (com.hotels.styx.api.HttpResponseStatus.OK)5 HttpClient (com.hotels.styx.client.HttpClient)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 HttpInterceptor (com.hotels.styx.api.HttpInterceptor)4 Plugin (com.hotels.styx.api.plugins.spi.Plugin)4 PluginFactory (com.hotels.styx.api.plugins.spi.PluginFactory)4 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)3