Skip to content

Commit

Permalink
Relax relative path existence assertion for parsed URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Apr 30, 2023
1 parent 6a22629 commit c1014f5
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.springframework.core.io.UrlResource;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -412,9 +411,6 @@ private void testResolvePathWithTraversal(HttpMethod httpMethod, String requestP
assertThat(((ResponseStatusException) err).getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
})
.verify(TIMEOUT);
if (!location.createRelative(requestPath).exists() && !requestPath.contains(":")) {
fail(requestPath + " doesn't actually exist as a relative path");
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.springframework.web.util.UrlPathHelper;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -414,9 +413,6 @@ private void testResolvePathWithTraversal(Resource location, String requestPath)
this.request.setAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, requestPath);
this.response = new MockHttpServletResponse();
this.handler.handleRequest(this.request, this.response);
if (!location.createRelative(requestPath).exists() && !requestPath.contains(":")) {
fail(requestPath + " doesn't actually exist as a relative path");
}
assertThat(this.response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value());
}

Expand Down

0 comments on commit c1014f5

Please sign in to comment.