use of org.springframework.cloud.gateway.handler.predicate.CookieRoutePredicateFactory.Config in project spring-cloud-gateway by spring-cloud.
the class CookieRoutePredicateFactoryTests method noCookiesForYou.
@Test
public void noCookiesForYou() {
MockServerHttpRequest request = MockServerHttpRequest.get("http://example.com").build();
MockServerWebExchange exchange = MockServerWebExchange.from(request);
Predicate<ServerWebExchange> predicate = new CookieRoutePredicateFactory().apply(new Config().setName("mycookie").setRegexp("ch.p"));
assertThat(predicate.test(exchange)).isFalse();
}
use of org.springframework.cloud.gateway.handler.predicate.CookieRoutePredicateFactory.Config in project spring-cloud-gateway by spring-cloud.
the class CookieRoutePredicateFactoryTests method okOneCookieForYou.
@Test
public void okOneCookieForYou() {
MockServerHttpRequest request = MockServerHttpRequest.get("http://example.com").cookie(new HttpCookie("yourcookie", "sugar"), new HttpCookie("mycookie", "chip")).build();
MockServerWebExchange exchange = MockServerWebExchange.from(request);
Predicate<ServerWebExchange> predicate = new CookieRoutePredicateFactory().apply(new Config().setName("mycookie").setRegexp("ch.p"));
assertThat(predicate.test(exchange)).isTrue();
}
Aggregations