|
28 | 28 |
|
29 | 29 | /**
|
30 | 30 | * @author raccoonback
|
| 31 | + * @author Jens Mallien |
31 | 32 | */
|
32 | 33 | class BeforeFilterFunctionsTests {
|
33 | 34 |
|
@@ -183,4 +184,52 @@ void stripPrefixWithEncodedParameters() {
|
183 | 184 | assertThat(result.uri().toString()).hasToString("http://localhost/depth3?baz%5B%5D=qux%5B%5D");
|
184 | 185 | }
|
185 | 186 |
|
| 187 | + @Test |
| 188 | + void rewritePath() { |
| 189 | + MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get") |
| 190 | + .buildRequest(null); |
| 191 | + |
| 192 | + ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList()); |
| 193 | + |
| 194 | + ServerRequest modified = BeforeFilterFunctions.rewritePath("get", "modified").apply(request); |
| 195 | + |
| 196 | + assertThat(modified.uri().getRawPath()).isEqualTo("/modified"); |
| 197 | + } |
| 198 | + |
| 199 | + @Test |
| 200 | + void rewritePathWithSpace() { |
| 201 | + MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get/path/with spaces") |
| 202 | + .buildRequest(null); |
| 203 | + |
| 204 | + ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList()); |
| 205 | + |
| 206 | + ServerRequest modified = BeforeFilterFunctions.rewritePath("get", "modified").apply(request); |
| 207 | + |
| 208 | + assertThat(modified.uri().getRawPath()).isEqualTo("/modified/path/with%20spaces"); |
| 209 | + } |
| 210 | + |
| 211 | + @Test |
| 212 | + void rewritePathWithEnDash() { |
| 213 | + MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get/path/with–en–dashes") |
| 214 | + .buildRequest(null); |
| 215 | + |
| 216 | + ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList()); |
| 217 | + |
| 218 | + ServerRequest modified = BeforeFilterFunctions.rewritePath("get", "modified").apply(request); |
| 219 | + |
| 220 | + assertThat(modified.uri().getRawPath()).isEqualTo("/modified/path/with%E2%80%93en%E2%80%93dashes"); |
| 221 | + } |
| 222 | + |
| 223 | + @Test |
| 224 | + void rewritePathWithEnDashAndSpace() { |
| 225 | + MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/get/path/with–en–dashes and spaces") |
| 226 | + .buildRequest(null); |
| 227 | + |
| 228 | + ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList()); |
| 229 | + |
| 230 | + ServerRequest modified = BeforeFilterFunctions.rewritePath("get", "modified").apply(request); |
| 231 | + |
| 232 | + assertThat(modified.uri().getRawPath()).isEqualTo("/modified/path/with%E2%80%93en%E2%80%93dashes%20and%20spaces"); |
| 233 | + } |
| 234 | + |
186 | 235 | }
|
0 commit comments