Check isAnyLocalAddress
This commit updates InternalInetAddressMatcher to check InetAddress#isAnyLocalAddress in order to catch additional IP addresses Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
This commit is contained in:
+3
-1
@@ -259,7 +259,9 @@ public final class InetAddressMatchers {
|
||||
if (address.isLoopbackAddress() || address.isLinkLocalAddress() || address.isSiteLocalAddress()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (address.isAnyLocalAddress()) {
|
||||
return true;
|
||||
}
|
||||
byte[] rawAddress = address.getAddress();
|
||||
|
||||
if (rawAddress.length == 16) {
|
||||
|
||||
+5
-4
@@ -276,16 +276,17 @@ class InetAddressMatchersTests {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "127.0.0.1", "127.0.0.255" })
|
||||
@ValueSource(strings = { "127.0.0.1", "127.0.0.255", "0.0.0.0" })
|
||||
void matchesWhenIpv4LoopbackThenReturnsTrue(String address) throws Exception {
|
||||
InetAddressMatcher matcher = InetAddressMatchers.matchInternal().build();
|
||||
assertThat(matcher.matches(InetAddress.getByName(address))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesWhenIpv6LoopbackThenReturnsTrue() throws Exception {
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "::1", "::" })
|
||||
void matchesWhenIpv6LoopbackThenReturnsTrue(String address) throws Exception {
|
||||
InetAddressMatcher matcher = InetAddressMatchers.matchInternal().build();
|
||||
assertThat(matcher.matches(InetAddress.getByName("::1"))).isTrue();
|
||||
assertThat(matcher.matches(InetAddress.getByName(address))).isTrue();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
|
||||
Reference in New Issue
Block a user