Skip to content

Commit c1014f5

Browse files
committed
Relax relative path existence assertion for parsed URIs
See gh-29481 See gh-28522
1 parent 6a22629 commit c1014f5

File tree

4 files changed

+0
-16
lines changed

4 files changed

+0
-16
lines changed

spring-webflux/src/test/java/org/springframework/web/reactive/resource/PathResourceResolverTests.java

-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.springframework.core.io.UrlResource;
3131

3232
import static org.assertj.core.api.Assertions.assertThat;
33-
import static org.assertj.core.api.Assertions.fail;
3433

3534
/**
3635
* Unit tests for {@link PathResourceResolver}.
@@ -101,9 +100,6 @@ public void checkResource() throws IOException {
101100
private void testCheckResource(Resource location, String requestPath) throws IOException {
102101
List<Resource> locations = Collections.singletonList(location);
103102
Resource actual = this.resolver.resolveResource(null, requestPath, locations, null).block(TIMEOUT);
104-
if (!location.createRelative(requestPath).exists() && !requestPath.contains(":")) {
105-
fail(requestPath + " doesn't actually exist as a relative path");
106-
}
107103
assertThat(actual).isNull();
108104
}
109105

spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java

-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
import static org.assertj.core.api.Assertions.assertThat;
6464
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
6565
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
66-
import static org.assertj.core.api.Assertions.fail;
6766
import static org.mockito.ArgumentMatchers.any;
6867
import static org.mockito.BDDMockito.given;
6968
import static org.mockito.Mockito.mock;
@@ -412,9 +411,6 @@ private void testResolvePathWithTraversal(HttpMethod httpMethod, String requestP
412411
assertThat(((ResponseStatusException) err).getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
413412
})
414413
.verify(TIMEOUT);
415-
if (!location.createRelative(requestPath).exists() && !requestPath.contains(":")) {
416-
fail(requestPath + " doesn't actually exist as a relative path");
417-
}
418414
}
419415

420416
@Test

spring-webmvc/src/test/java/org/springframework/web/servlet/resource/PathResourceResolverTests.java

-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.springframework.web.util.UrlPathHelper;
3434

3535
import static org.assertj.core.api.Assertions.assertThat;
36-
import static org.assertj.core.api.Assertions.fail;
3736

3837
/**
3938
* Unit tests for {@link PathResourceResolver}.
@@ -86,9 +85,6 @@ public void checkResource() throws IOException {
8685
private void testCheckResource(Resource location, String requestPath) throws IOException {
8786
List<Resource> locations = Collections.singletonList(location);
8887
Resource actual = this.resolver.resolveResource(null, requestPath, locations, null);
89-
if (!location.createRelative(requestPath).exists() && !requestPath.contains(":")) {
90-
fail(requestPath + " doesn't actually exist as a relative path");
91-
}
9288
assertThat(actual).isNull();
9389
}
9490

spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerTests.java

-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import static org.assertj.core.api.Assertions.assertThat;
4545
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
4646
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
47-
import static org.assertj.core.api.Assertions.fail;
4847
import static org.mockito.ArgumentMatchers.any;
4948
import static org.mockito.BDDMockito.given;
5049
import static org.mockito.Mockito.mock;
@@ -414,9 +413,6 @@ private void testResolvePathWithTraversal(Resource location, String requestPath)
414413
this.request.setAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, requestPath);
415414
this.response = new MockHttpServletResponse();
416415
this.handler.handleRequest(this.request, this.response);
417-
if (!location.createRelative(requestPath).exists() && !requestPath.contains(":")) {
418-
fail(requestPath + " doesn't actually exist as a relative path");
419-
}
420416
assertThat(this.response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
421417
}
422418

0 commit comments

Comments
 (0)