Add hasText assertion to IpAddressMatcher constructor
Issue gh-15527
(cherry picked from commit 3a29819651)
This commit is contained in:
parent
554df6fab6
commit
ddf4542a9e
|
|
@ -50,6 +50,7 @@ public final class IpAddressMatcher implements RequestMatcher {
|
|||
* come.
|
||||
*/
|
||||
public IpAddressMatcher(String ipAddress) {
|
||||
Assert.hasText(ipAddress, "ipAddress cannot be empty");
|
||||
assertNotHostName(ipAddress);
|
||||
if (ipAddress.indexOf('/') > 0) {
|
||||
String[] addressAndMask = StringUtils.split(ipAddress, "/");
|
||||
|
|
|
|||
|
|
@ -139,4 +139,18 @@ public class IpAddressMatcherTests {
|
|||
assertThat(this.v4matcher.matches((String) null)).isFalse();
|
||||
}
|
||||
|
||||
// gh-15527
|
||||
@Test
|
||||
public void constructorWhenRequiredAddressIsNullThenThrowsIllegalArgumentException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new IpAddressMatcher(null))
|
||||
.withMessage("ipAddress cannot be empty");
|
||||
}
|
||||
|
||||
// gh-15527
|
||||
@Test
|
||||
public void constructorWhenRequiredAddressIsEmptyThenThrowsIllegalArgumentException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new IpAddressMatcher(""))
|
||||
.withMessage("ipAddress cannot be empty");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue