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
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) {
130
130
}
131
131
}
132
132
133
+ public InetAddress getRequiredAddress () {
134
+ return this .requiredAddress ;
135
+ }
136
+
137
+ public int getMaskBits () {
138
+ return this .nMaskBits ;
139
+ }
140
+
133
141
}
Original file line number Diff line number Diff line change @@ -152,5 +152,18 @@ public void constructorWhenRequiredAddressIsEmptyThenThrowsIllegalArgumentExcept
152
152
assertThatIllegalArgumentException ().isThrownBy (() -> new IpAddressMatcher ("" ))
153
153
.withMessage ("ipAddress cannot be empty" );
154
154
}
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
+ }
155
168
156
169
}
You can’t perform that action at this time.
0 commit comments