mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-03-01 10:59:16 +00:00
Add hasText assertion to IpAddressMatcher constructor
Issue gh-15527 (cherry picked from commit 3a298196512de5f3002707e2af8298d650033df7)
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…
x
Reference in New Issue
Block a user