use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class ViaHeaderAppendingInterceptorTest method addsViaHeaderToRequestWhenItIsPresentButEmpty.
@Test
public void addsViaHeaderToRequestWhenItIsPresentButEmpty() throws Exception {
LiveHttpRequest request = post("/foo").header(VIA, "").build();
LiveHttpRequest interceptedRequest = interceptRequest(interceptor, request);
assertThat(interceptedRequest.headers().get(VIA), isValue("1.1 styx"));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class ViaHeaderAppendingInterceptorTest method addsViaHeaderToRequestIfNotAlreadyPresent.
@Test
public void addsViaHeaderToRequestIfNotAlreadyPresent() throws Exception {
LiveHttpRequest request = post("/foo").header(HOST, "www.example.com:8000").build();
LiveHttpRequest interceptedRequest = interceptRequest(interceptor, request);
assertThat(interceptedRequest.headers().get(VIA), isValue("1.1 styx"));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class AntlrConditionTest method cookieValueMatchesWithString.
@Test
public void cookieValueMatchesWithString() {
Condition condition = condition("cookie('TheCookie') == 'foobar-foobar-baz'");
LiveHttpRequest request = newRequest().cookies(requestCookie("TheCookie", "foobar-foobar-baz")).header("App-Name", "app3").build();
assertThat(condition.evaluate(request, context), is(true));
request = newRequest().cookies(requestCookie("AnotherCookie", "foobar-baz")).header("App-Name", "app3").build();
assertThat(condition.evaluate(request, context), is(false));
request = newRequest().header("App-Name", "app3").build();
assertThat(condition.evaluate(request, context), is(false));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class AntlrConditionTest method matchesHeaderPresence.
@Test
public void matchesHeaderPresence() {
Condition condition = condition("header('Host')");
LiveHttpRequest request = newRequest("/foo").header(HOST, "bbc.co.uk").build();
assertThat(condition.evaluate(request, context), is(true));
LiveHttpRequest request2 = newRequest("/foo").build();
assertThat(condition.evaluate(request2, context), is(false));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class AntlrConditionTest method cookieValueMatchesWithRegexp.
@Test
public void cookieValueMatchesWithRegexp() {
Condition condition = condition("cookie('TheCookie') =~ 'foobar-.*-baz'");
LiveHttpRequest request = newRequest().cookies(requestCookie("TheCookie", "foobar-foobar-baz")).header("App-Name", "app3").build();
assertThat(condition.evaluate(request, context), is(true));
request = newRequest().cookies(requestCookie("AnotherCookie", "foobar-x-baz")).header("App-Name", "app3").build();
assertThat(condition.evaluate(request, context), is(false));
request = newRequest().header("App-Name", "app3").build();
assertThat(condition.evaluate(request, context), is(false));
}
Aggregations