File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
main/java/org/springframework/security/web/util/matcher
test/java/org/springframework/security/web/util/matcher Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -130,4 +130,12 @@ private InetAddress parseAddress(String address) {
130130 }
131131 }
132132
133+ public InetAddress getRequiredAddress () {
134+ return this .requiredAddress ;
135+ }
136+
137+ public int getMaskBits () {
138+ return this .nMaskBits ;
139+ }
140+
133141}
Original file line number Diff line number Diff line change @@ -152,5 +152,18 @@ public void constructorWhenRequiredAddressIsEmptyThenThrowsIllegalArgumentExcept
152152 assertThatIllegalArgumentException ().isThrownBy (() -> new IpAddressMatcher ("" ))
153153 .withMessage ("ipAddress cannot be empty" );
154154 }
155+ // gh-16693
156+ @ Test
157+ public void getRequiredAddressWhenCidrIsValidThenReturnsHostAddress () {
158+ IpAddressMatcher ipAddressMatcher = new IpAddressMatcher ("192.168.1.0/24" );
159+ assertThat (ipAddressMatcher .getRequiredAddress ().getHostAddress ()).isEqualTo ("192.168.1.0" );
160+ }
161+
162+ // gh-16693
163+ @ Test
164+ public void getRequiredAddressWhenCidrIsValidThenReturnsMaskBits () {
165+ IpAddressMatcher ipAddressMatcher = new IpAddressMatcher ("192.168.1.0/24" );
166+ assertThat (ipAddressMatcher .getMaskBits ()).isEqualTo (24 );
167+ }
155168
156169}
You can’t perform that action at this time.
0 commit comments