mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-21 21:39:05 +00:00
Ignore an empty port
Closes gh-37117
This commit is contained in:
+11
-5
@@ -937,11 +937,17 @@ class UriComponentsBuilderTests {
|
||||
@ParameterizedTest
|
||||
@EnumSource
|
||||
void verifyInvalidPort(ParserType parserType) {
|
||||
String url = "http://localhost:XXX/path";
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> UriComponentsBuilder.fromUriString(url, parserType).build().toUri());
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> UriComponentsBuilder.fromUriString(url, parserType).build().toUri());
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
UriComponentsBuilder.fromUriString("http://localhost:XXX/path", parserType).build().toUri());
|
||||
}
|
||||
|
||||
@ParameterizedTest // gh-37117
|
||||
@EnumSource
|
||||
void verifyEmptyPort(ParserType parserType) {
|
||||
URI uri = UriComponentsBuilder.fromUriString("http://localhost:/path", parserType).build().toUri();
|
||||
assertThat(uri.getHost()).isEqualTo("localhost");
|
||||
assertThat(uri.getPort()).isEqualTo(-1);
|
||||
assertThat(uri.getPath()).isEqualTo("/path");
|
||||
}
|
||||
|
||||
@ParameterizedTest // gh-27039
|
||||
|
||||
@@ -201,10 +201,9 @@ class UriComponentsTests {
|
||||
.isThrownBy(() -> fromUriString("https://example.com:XXX/bar", parserType));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource
|
||||
void invalidPortSet(ParserType parserType) {
|
||||
UriComponents uriComponents = fromUriString("https://example.com/bar", parserType).port("XXX").build();
|
||||
@Test
|
||||
void invalidPortSet() {
|
||||
UriComponents uriComponents = fromUriString("https://example.com/bar").port("XXX").build();
|
||||
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(uriComponents::getPort)
|
||||
@@ -215,6 +214,12 @@ class UriComponentsTests {
|
||||
.withMessage("The port must be an integer: XXX");
|
||||
}
|
||||
|
||||
@Test // gh-37117
|
||||
void emptyPortSet() {
|
||||
UriComponents uriComponents = fromUriString("https://example.com/bar").port("").build();
|
||||
assertThat(uriComponents.getPort()).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void expandEncoded() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
|
||||
Reference in New Issue
Block a user