use of com.hotels.styx.api.HttpRequest 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.HttpRequest 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.HttpRequest 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.HttpRequest 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.HttpRequest in project styx by ExpediaGroup.
the class StyxHttpClientTest method replacesUserAgentIfAlreadyPresentInRequest.
/*
* StyxHttpClient
* - User-Agent string from the request takes precedence.
*/
@Test
public void replacesUserAgentIfAlreadyPresentInRequest() throws ExecutionException, InterruptedException {
StyxHttpClient client = new StyxHttpClient.Builder().userAgent("My default user agent value").build();
HttpRequest request = get("/").header(HOST, hostString(server.port())).header(USER_AGENT, "My previous user agent").build();
client.send(request).get();
server.verify(getRequestedFor(urlEqualTo("/")).withHeader("User-Agent", equalTo("My default user agent value")));
}
Aggregations