Skip to content

Commit 6f5d1e7

Browse files
committed
Reenable test with firewall disabled.
1 parent 068c4ea commit 6f5d1e7

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/handler/predicate/PathRoutePredicateFactoryTests.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
import org.junit.jupiter.api.Disabled;
2323
import org.junit.jupiter.api.Test;
2424

25+
import org.springframework.beans.BeansException;
2526
import org.springframework.beans.factory.annotation.Value;
27+
import org.springframework.beans.factory.config.BeanPostProcessor;
2628
import org.springframework.boot.SpringBootConfiguration;
2729
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2830
import org.springframework.boot.test.context.SpringBootTest;
@@ -34,6 +36,8 @@
3436
import org.springframework.context.annotation.Bean;
3537
import org.springframework.context.annotation.Import;
3638
import org.springframework.http.HttpHeaders;
39+
import org.springframework.security.web.server.WebFilterChainProxy;
40+
import org.springframework.security.web.server.firewall.StrictServerWebExchangeFirewall;
3741
import org.springframework.test.annotation.DirtiesContext;
3842
import org.springframework.web.server.ServerWebExchange;
3943

@@ -93,7 +97,7 @@ public void mulitPathDslRouteWorks() {
9397
}
9498

9599
@Test
96-
@Disabled
100+
//@Disabled
97101
public void pathRouteWorksWithPercent() {
98102
testClient.get()
99103
.uri("/abc/123%/function")
@@ -149,6 +153,22 @@ public static class TestConfig {
149153
@Value("${test.uri}")
150154
String uri;
151155

156+
// TODO: move to bean of StrictServerWebExchangeFirewall
157+
@Bean
158+
public BeanPostProcessor firewallPostProcessor() {
159+
return new BeanPostProcessor() {
160+
@Override
161+
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
162+
if (bean instanceof WebFilterChainProxy webFilterChainProxy) {
163+
StrictServerWebExchangeFirewall firewall = new StrictServerWebExchangeFirewall();
164+
firewall.setAllowUrlEncodedPercent(true);
165+
webFilterChainProxy.setFirewall(firewall);
166+
}
167+
return bean;
168+
}
169+
};
170+
}
171+
152172
@Bean
153173
public RouteLocator testRouteLocator(RouteLocatorBuilder builder) {
154174
return builder.routes()

0 commit comments

Comments
 (0)