|
22 | 22 | import org.junit.jupiter.api.Disabled; |
23 | 23 | import org.junit.jupiter.api.Test; |
24 | 24 |
|
| 25 | +import org.springframework.beans.BeansException; |
25 | 26 | import org.springframework.beans.factory.annotation.Value; |
| 27 | +import org.springframework.beans.factory.config.BeanPostProcessor; |
26 | 28 | import org.springframework.boot.SpringBootConfiguration; |
27 | 29 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
28 | 30 | import org.springframework.boot.test.context.SpringBootTest; |
|
34 | 36 | import org.springframework.context.annotation.Bean; |
35 | 37 | import org.springframework.context.annotation.Import; |
36 | 38 | import org.springframework.http.HttpHeaders; |
| 39 | +import org.springframework.security.web.server.WebFilterChainProxy; |
| 40 | +import org.springframework.security.web.server.firewall.StrictServerWebExchangeFirewall; |
37 | 41 | import org.springframework.test.annotation.DirtiesContext; |
38 | 42 | import org.springframework.web.server.ServerWebExchange; |
39 | 43 |
|
@@ -93,7 +97,7 @@ public void mulitPathDslRouteWorks() { |
93 | 97 | } |
94 | 98 |
|
95 | 99 | @Test |
96 | | - @Disabled |
| 100 | + //@Disabled |
97 | 101 | public void pathRouteWorksWithPercent() { |
98 | 102 | testClient.get() |
99 | 103 | .uri("/abc/123%/function") |
@@ -149,6 +153,22 @@ public static class TestConfig { |
149 | 153 | @Value("${test.uri}") |
150 | 154 | String uri; |
151 | 155 |
|
| 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 | + |
152 | 172 | @Bean |
153 | 173 | public RouteLocator testRouteLocator(RouteLocatorBuilder builder) { |
154 | 174 | return builder.routes() |
|
0 commit comments