adds test with variables in the prefix
This commit is contained in:
@@ -25,6 +25,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.gateway.handler.RoutePredicateHandlerMapping;
|
||||
import org.springframework.cloud.gateway.test.BaseWebClientTests;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@@ -37,6 +38,17 @@ public class PathRoutePredicateFactoryTests extends BaseWebClientTests {
|
||||
|
||||
@Test
|
||||
public void pathRouteWorks() {
|
||||
testClient.get().uri("/abc/123/function")
|
||||
.header(HttpHeaders.HOST, "www.path.org")
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
.expectHeader().valueEquals(HANDLER_MAPPER_HEADER, RoutePredicateHandlerMapping.class.getSimpleName())
|
||||
.expectHeader().valueEquals("transfer-encoding", "chunked")
|
||||
.expectHeader().valueEquals(ROUTE_ID_HEADER, "path_test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultPathRouteWorks() {
|
||||
testClient.get().uri("/get")
|
||||
.exchange()
|
||||
.expectStatus().isOk()
|
||||
|
||||
@@ -62,6 +62,11 @@ public class HttpBinCompatibleController {
|
||||
return get(exchange).delayElement(Duration.ofSeconds(delay));
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/anything/{anything}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Mono<Map<String, Object>> anything(ServerWebExchange exchange, @PathVariable String anything) {
|
||||
return get(exchange);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/get", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public Mono<Map<String, Object>> get(ServerWebExchange exchange) {
|
||||
return getHeaders(exchange).map(map -> {
|
||||
|
||||
@@ -117,6 +117,15 @@ spring:
|
||||
- Host=**.notbetween.org
|
||||
- Between=1000-03-13T10:39:37.518-04:00[America/New_York],1002-03-13T10:39:37.518-04:00[America/New_York]
|
||||
|
||||
# =====================================
|
||||
- id: path_test
|
||||
uri: ${test.uri}
|
||||
predicates:
|
||||
- Path=/{org}/{scope}/function
|
||||
- Host=**.path.org
|
||||
filters:
|
||||
- SetPath=/anything/{org}{scope}
|
||||
|
||||
# =====================================
|
||||
- id: redirect_to_test
|
||||
uri: ${test.uri}
|
||||
|
||||
Reference in New Issue
Block a user