1
1
package csconfig
2
2
3
3
import (
4
- "net"
4
+ "net/netip "
5
5
"os"
6
6
"strings"
7
7
"testing"
@@ -271,13 +271,6 @@ func TestLoadAPIServer(t *testing.T) {
271
271
}
272
272
}
273
273
274
- func mustParseCIDRNet (t * testing.T , s string ) * net.IPNet {
275
- _ , ipNet , err := net .ParseCIDR (s )
276
- require .NoError (t , err )
277
-
278
- return ipNet
279
- }
280
-
281
274
func TestParseCapiWhitelists (t * testing.T ) {
282
275
tests := []struct {
283
276
name string
@@ -289,33 +282,33 @@ func TestParseCapiWhitelists(t *testing.T) {
289
282
name : "empty file" ,
290
283
input : "" ,
291
284
expected : & CapiWhitelist {
292
- Ips : []net. IP {},
293
- Cidrs : []* net. IPNet {},
285
+ Ips : []netip. Addr {},
286
+ Cidrs : []netip. Prefix {},
294
287
},
295
288
expectedErr : "empty file" ,
296
289
},
297
290
{
298
291
name : "empty ip and cidr" ,
299
292
input : `{"ips": [], "cidrs": []}` ,
300
293
expected : & CapiWhitelist {
301
- Ips : []net. IP {},
302
- Cidrs : []* net. IPNet {},
294
+ Ips : []netip. Addr {},
295
+ Cidrs : []netip. Prefix {},
303
296
},
304
297
},
305
298
{
306
299
name : "some ip" ,
307
300
input : `{"ips": ["1.2.3.4"]}` ,
308
301
expected : & CapiWhitelist {
309
- Ips : []net. IP { net . IPv4 ( 1 , 2 , 3 , 4 )},
310
- Cidrs : []* net. IPNet {},
302
+ Ips : []netip. Addr { netip . MustParseAddr ( "1.2.3.4" )},
303
+ Cidrs : []netip. Prefix {},
311
304
},
312
305
},
313
306
{
314
307
name : "some cidr" ,
315
308
input : `{"cidrs": ["1.2.3.0/24"]}` ,
316
309
expected : & CapiWhitelist {
317
- Ips : []net. IP {},
318
- Cidrs : []* net. IPNet { mustParseCIDRNet ( t , "1.2.3.0/24" )},
310
+ Ips : []netip. Addr {},
311
+ Cidrs : []netip. Prefix { netip . MustParsePrefix ( "1.2.3.0/24" )},
319
312
},
320
313
},
321
314
}
0 commit comments