use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class AntlrConditionTest method matchesHttpHeader.
@Test
public void matchesHttpHeader() {
Condition condition = condition("header('Host') == 'bbc.co.uk'");
LiveHttpRequest request = newRequest("/path").header(HOST, "bbc.co.uk").build();
assertThat(condition.evaluate(request, context), is(true));
LiveHttpRequest request2 = newRequest("/path").header(HOST, "hotels.com").build();
assertThat(condition.evaluate(request2, context), is(false));
LiveHttpRequest request3 = newRequest("/path").build();
assertThat(condition.evaluate(request3, context), is(false));
}
use of com.hotels.styx.api.LiveHttpRequest in project styx by ExpediaGroup.
the class FunctionResolverTest method resolvesOneArgumentFunctions.
@Test
public void resolvesOneArgumentFunctions() {
LiveHttpRequest request = get("/foo").header("Host", "www.hotels.com").cookies(requestCookie("lang", "en_US|en-us_hotels_com")).build();
assertThat(functionResolver.resolveFunction("header", singletonList("Host")).call(request, context), is("www.hotels.com"));
assertThat(functionResolver.resolveFunction("cookie", singletonList("lang")).call(request, context), is("en_US|en-us_hotels_com"));
}
Aggregations