Search in sources :

Example 1 with HttpResponse

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

the class OriginsCommandHandlerTest method returnsProperErrorMessageForBadCommand.

@Test
public void returnsProperErrorMessageForBadCommand() {
    HttpResponse response = post("/admin/tasks/origins?cmd=foo&appId=foo&originId=bar");
    assertThat(response.status(), is(BAD_REQUEST));
    assertThat(response.bodyAs(UTF_8), is("cmd, appId and originId are all required parameters. cmd can be enable_origin|disable_origin"));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with HttpResponse

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

the class OriginsCommandHandlerTest method returnsProperErrorMessageForMissingAppId.

@Test
public void returnsProperErrorMessageForMissingAppId() {
    HttpResponse response = post("/admin/tasks/origins?cmd=enable_origin&originId=bar");
    assertThat(response.status(), is(BAD_REQUEST));
    assertThat(response.bodyAs(UTF_8), is("cmd, appId and originId are all required parameters. cmd can be enable_origin|disable_origin"));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with HttpResponse

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

the class OriginsInventoryHandlerTest method returnsEmptyObjectWhenNoOrigins.

@Test
public void returnsEmptyObjectWhenNoOrigins() {
    OriginsInventoryHandler handler = new OriginsInventoryHandler(new EventBus());
    HttpResponse response = Mono.from(handler.handle(get("/").build(), requestContext())).block();
    assertThat(response.bodyAs(UTF_8), is("{}"));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) EventBus(com.google.common.eventbus.EventBus) Test(org.junit.jupiter.api.Test)

Example 4 with HttpResponse

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

the class PluginListHandlerTest method showsLoadedPlugins.

@Test
public void showsLoadedPlugins() {
    NamedPlugin one = namedPlugin("one", PASS_THROUGH);
    NamedPlugin two = namedPlugin("two", PASS_THROUGH);
    List<NamedPlugin> plugins = asList(one, two);
    PluginListHandler handler = new PluginListHandler(plugins);
    HttpResponse response = Mono.from(handler.handle(get("/").build(), requestContext())).block();
    assertThat(response.status(), is(OK));
    assertThat(response.bodyAs(UTF_8), is("" + "<h3>Loaded</h3>" + "<a href='/admin/plugins/one'>one</a><br />" + "<a href='/admin/plugins/two'>two</a><br />"));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) NamedPlugin(com.hotels.styx.proxy.plugin.NamedPlugin) Test(org.junit.jupiter.api.Test)

Example 5 with HttpResponse

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

the class PluginListHandlerTest method showsEnabledAndDisabledPlugins.

@Test
public void showsEnabledAndDisabledPlugins() {
    NamedPlugin one = namedPlugin("one", PASS_THROUGH);
    NamedPlugin two = namedPlugin("two", PASS_THROUGH);
    NamedPlugin three = namedPlugin("three", PASS_THROUGH);
    NamedPlugin four = namedPlugin("four", PASS_THROUGH);
    two.setEnabled(false);
    three.setEnabled(false);
    List<NamedPlugin> plugins = asList(one, two, three, four);
    PluginListHandler handler = new PluginListHandler(plugins);
    HttpResponse response = Mono.from(handler.handle(get("/").build(), requestContext())).block();
    assertThat(response.status(), is(OK));
    assertThat(response.bodyAs(UTF_8), is("" + "<h3>Enabled</h3>" + "<a href='/admin/plugins/one'>one</a><br />" + "<a href='/admin/plugins/four'>four</a><br />" + "<h3>Disabled</h3>" + "<a href='/admin/plugins/two'>two</a><br />" + "<a href='/admin/plugins/three'>three</a><br />"));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) NamedPlugin(com.hotels.styx.proxy.plugin.NamedPlugin) 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