From b54167d634a293e948652d586c628bb8cf4840d8 Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Fri, 28 Jan 2022 19:22:09 +0100 Subject: [PATCH 1/6] Fix invalid backticks in the docs Fixes gh-2504 --- docs/src/main/asciidoc/spring-cloud-gateway.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/main/asciidoc/spring-cloud-gateway.adoc b/docs/src/main/asciidoc/spring-cloud-gateway.adoc index 130aa8b1..912fa9d7 100644 --- a/docs/src/main/asciidoc/spring-cloud-gateway.adoc +++ b/docs/src/main/asciidoc/spring-cloud-gateway.adoc @@ -1538,7 +1538,7 @@ spring: When the request size is greater than the permissible limit, the `RequestSize` `GatewayFilter` factory can restrict a request from reaching the downstream service. The filter takes a `maxSize` parameter. -The `maxSize is a `DataSize` type, so values can be defined as a number followed by an optional `DataUnit` suffix such as 'KB' or 'MB'. The default is 'B' for bytes. +The `maxSize` is a `DataSize` type, so values can be defined as a number followed by an optional `DataUnit` suffix such as 'KB' or 'MB'. The default is 'B' for bytes. It is the permissible size limit of the request defined in bytes. The following listing configures a `RequestSize` `GatewayFilter`: @@ -1566,7 +1566,7 @@ The `RequestSize` `GatewayFilter` factory sets the response status as `413 Paylo ==== [source] ---- -errorMessage` : `Request size is larger than permissible limit. Request size is 6.0 MB where permissible limit is 5.0 MB +errorMessage : Request size is larger than permissible limit. Request size is 6.0 MB where permissible limit is 5.0 MB ---- ==== @@ -1898,7 +1898,7 @@ It runs after all other filters have completed and writes the proxy response bac If there is a `Route` object in the `ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR` exchange attribute, the `RouteToRequestUrlFilter` runs. It creates a new URI, based off of the request URI but updated with the URI attribute of the `Route` object. -The new URI is placed in the `ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR` exchange attribute`. +The new URI is placed in the `ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR` exchange attribute. If the URI has a scheme prefix, such as `lb:ws://serviceid`, the `lb` scheme is stripped from the URI and placed in the `ServerWebExchangeUtils.GATEWAY_SCHEME_PREFIX_ATTR` for use later in the filter chain. From e47e5fc20d9a88481f32a05bbe021709214618fb Mon Sep 17 00:00:00 2001 From: spencergibb Date: Wed, 9 Feb 2022 11:57:39 -0500 Subject: [PATCH 2/6] Adds path predicate regex test --- .../predicate/PathRoutePredicateFactoryTests.java | 8 ++++++++ .../src/test/resources/application.yml | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactoryTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactoryTests.java index 3f4fff11..e2b4ddca 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactoryTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactoryTests.java @@ -88,6 +88,14 @@ public class PathRoutePredicateFactoryTests extends BaseWebClientTests { .valueEquals(ROUTE_ID_HEADER, "path_test"); } + @Test + public void pathRouteWorksWithRegex() { + testClient.get().uri("/regex/123").header(HttpHeaders.HOST, "www.pathregex.org").exchange().expectStatus() + .isOk().expectHeader() + .valueEquals(HANDLER_MAPPER_HEADER, RoutePredicateHandlerMapping.class.getSimpleName()).expectHeader() + .valueEquals(ROUTE_ID_HEADER, "path_regex"); + } + @Test public void matchOptionalTrailingSeparatorCopiedToMatchTrailingSlash() { Config config = new Config().setPatterns(Arrays.asList("patternA", "patternB")).setMatchTrailingSlash(false); diff --git a/spring-cloud-gateway-server/src/test/resources/application.yml b/spring-cloud-gateway-server/src/test/resources/application.yml index e4ede706..2628f122 100644 --- a/spring-cloud-gateway-server/src/test/resources/application.yml +++ b/spring-cloud-gateway-server/src/test/resources/application.yml @@ -262,6 +262,15 @@ spring: filters: - SetPath=/anything/multi{num} + # ===================================== + - id: path_regex + uri: ${test.uri} + predicates: + - Host=**.pathregex.org + - Path=/regex/{digits:\d+} + filters: + - SetPath=/anything/{digits} + # ===================================== - id: redirect_to_test uri: ${test.uri} From 6a5d723406677c6bd80570b47e22e6362eeb3ff0 Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Wed, 9 Feb 2022 17:30:09 +0100 Subject: [PATCH 3/6] Fix example in SetStatusGatewayFilterFactory docs Fixes gh-2513 --- docs/src/main/asciidoc/spring-cloud-gateway.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/main/asciidoc/spring-cloud-gateway.adoc b/docs/src/main/asciidoc/spring-cloud-gateway.adoc index 912fa9d7..4922f2c1 100644 --- a/docs/src/main/asciidoc/spring-cloud-gateway.adoc +++ b/docs/src/main/asciidoc/spring-cloud-gateway.adoc @@ -1395,7 +1395,7 @@ spring: - id: setstatusstring_route uri: https://example.org filters: - - SetStatus=BAD_REQUEST + - SetStatus=UNAUTHORIZED - id: setstatusint_route uri: https://example.org filters: From f8db47ee625ce438218d58142b63053aec52e000 Mon Sep 17 00:00:00 2001 From: spencergibb Date: Mon, 14 Feb 2022 17:15:00 -0500 Subject: [PATCH 4/6] Updates testcontainers to latest versions Fixes gh-2521 --- ...wayRedisRouteDefinitionRepositoryEnabledByPropertyTests.java | 2 +- .../cloud/gateway/filter/ratelimit/RedisRateLimiterTests.java | 2 +- .../gateway/route/RedisRouteDefinitionRepositoryTests.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/config/GatewayRedisRouteDefinitionRepositoryEnabledByPropertyTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/config/GatewayRedisRouteDefinitionRepositoryEnabledByPropertyTests.java index 23cb9e22..37fb3761 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/config/GatewayRedisRouteDefinitionRepositoryEnabledByPropertyTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/config/GatewayRedisRouteDefinitionRepositoryEnabledByPropertyTests.java @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class GatewayRedisRouteDefinitionRepositoryEnabledByPropertyTests { @Container - public static GenericContainer redis = new GenericContainer<>("redis:5.0.9-alpine").withExposedPorts(6379); + public static GenericContainer redis = new GenericContainer<>("redis:5.0.14-alpine").withExposedPorts(6379); @Autowired(required = false) private RedisRouteDefinitionRepository redisRouteDefinitionRepository; diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/ratelimit/RedisRateLimiterTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/ratelimit/RedisRateLimiterTests.java index cfcee51c..5cf30de5 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/ratelimit/RedisRateLimiterTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/ratelimit/RedisRateLimiterTests.java @@ -59,7 +59,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen public class RedisRateLimiterTests extends BaseWebClientTests { @Container - public static GenericContainer redis = new GenericContainer<>("redis:5.0.9-alpine").withExposedPorts(6379); + public static GenericContainer redis = new GenericContainer<>("redis:5.0.14-alpine").withExposedPorts(6379); @Autowired private RedisRateLimiter rateLimiter; diff --git a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/route/RedisRouteDefinitionRepositoryTests.java b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/route/RedisRouteDefinitionRepositoryTests.java index 19f66ef9..5a5be605 100644 --- a/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/route/RedisRouteDefinitionRepositoryTests.java +++ b/spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/route/RedisRouteDefinitionRepositoryTests.java @@ -59,7 +59,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class RedisRouteDefinitionRepositoryTests { @Container - public static GenericContainer redis = new GenericContainer<>("redis:5.0.9-alpine").withExposedPorts(6379); + public static GenericContainer redis = new GenericContainer<>("redis:5.0.14-alpine").withExposedPorts(6379); @Autowired private RedisRouteDefinitionRepository redisRouteDefinitionRepository; From bf9e98bced36297ceb139d1481307400f0f08e1b Mon Sep 17 00:00:00 2001 From: spencergibb Date: Mon, 14 Feb 2022 17:15:08 -0500 Subject: [PATCH 5/6] Updates testcontainers to latest versions Fixes gh-2521 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2cfeb55e..0d5ede1d 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ 1.0.0 2.1.1-SNAPSHOT 3.1.1-SNAPSHOT - 1.15.1 + 1.16.3 From d5a9a21a5e6430891c34265ac94ff8940ab67a22 Mon Sep 17 00:00:00 2001 From: spencergibb Date: Mon, 14 Feb 2022 17:15:29 -0500 Subject: [PATCH 6/6] Updates grpc in integration tests Fixes gh-2520 --- spring-cloud-gateway-integration-tests/grpc/pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-cloud-gateway-integration-tests/grpc/pom.xml b/spring-cloud-gateway-integration-tests/grpc/pom.xml index 131dd41a..6e1698e9 100644 --- a/spring-cloud-gateway-integration-tests/grpc/pom.xml +++ b/spring-cloud-gateway-integration-tests/grpc/pom.xml @@ -33,17 +33,17 @@ io.grpc grpc-netty-shaded - 1.41.0 + 1.44.0 io.grpc grpc-protobuf - 1.41.0 + 1.44.0 io.grpc grpc-stub - 1.41.0 + 1.44.0 io.netty @@ -85,9 +85,9 @@ protobuf-maven-plugin 0.6.1 - com.google.protobuf:protoc:3.17.3:exe:${os.detected.classifier} + com.google.protobuf:protoc:3.19.4:exe:${os.detected.classifier} grpc-java - io.grpc:protoc-gen-grpc-java:1.41.0:exe:${os.detected.classifier} + io.grpc:protoc-gen-grpc-java:1.44.0:exe:${os.detected.classifier}