use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class PluginToggleHandlerTest method notifiesWhenPluginAlreadyDisabled.
@Test
public void notifiesWhenPluginAlreadyDisabled() {
HttpRequest request = put("/foo/off/enabled").body("false", UTF_8).build();
HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(body(response), is("{\"message\":\"State of 'off' was already 'disabled'\",\"plugin\":{\"name\":\"off\",\"state\":\"disabled\"}}"));
assertThat(initiallyEnabled.enabled(), is(true));
assertThat(initiallyDisabled.enabled(), is(false));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class PluginToggleHandlerTest method saysBadRequestWhenPluginDoesNotExist.
@Test
public void saysBadRequestWhenPluginDoesNotExist() {
HttpRequest request = put("/foo/nonexistent/enabled").body("true", UTF_8).build();
HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
assertThat(response.status(), is(NOT_FOUND));
assertThat(body(response), is("No such plugin: pluginName=nonexistent"));
assertThat(initiallyEnabled.enabled(), is(true));
assertThat(initiallyDisabled.enabled(), is(false));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class ServiceProviderHandlerTest method returnsNotFoundStatusWhenNamedProviderNotFound.
@Test
public void returnsNotFoundStatusWhenNamedProviderNotFound() throws IOException {
StyxObjectStore<StyxObjectRecord<StyxService>> store = createTestStore();
ServiceProviderHandler handler = new ServiceProviderHandler(store);
HttpRequest request = HttpRequest.get("/admin/service/provider/nonexistent").build();
HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
assertThat(response.status(), equalTo(NOT_FOUND));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class ServiceProviderHandlerTest method returnsNotFoundStatusWithNonHandledUrl.
@Test
public void returnsNotFoundStatusWithNonHandledUrl() {
StyxObjectStore<StyxObjectRecord<StyxService>> empty = new StyxObjectStore<>();
ServiceProviderHandler handler = new ServiceProviderHandler(empty);
HttpRequest request = HttpRequest.get("/not/my/url").build();
HttpResponse response = Mono.from(handler.handle(request, requestContext())).block();
assertThat(response.status(), equalTo(NOT_FOUND));
}
use of com.hotels.styx.api.HttpResponse in project styx by ExpediaGroup.
the class StartupConfigHandlerTest method outputsExpectedData.
@Test
public void outputsExpectedData() {
StartupConfig startupConfig = newStartupConfigBuilder().styxHome("/foo").configFileLocation("/bar/configure-me.yml").logbackConfigLocation("/baz/logback-conf.xml").build();
StartupConfigHandler handler = new StartupConfigHandler(startupConfig);
HttpResponse response = Mono.from(handler.handle(get("/").build(), requestContext())).block();
assertThat(response.status(), is(OK));
assertThat(response.bodyAs(UTF_8), matchesRegex("<html><body>" + "Styx Home='[/\\\\]foo'" + "<br />Config File Location='.*[/\\\\]bar[/\\\\]configure-me.yml'" + "<br />Log Config Location='.*[/\\\\]baz[/\\\\]logback-conf.xml'" + "</body></html>"));
}
Aggregations