Lines 19-42
use Modern::Perl;
Link Here
|
19 |
use Test::More tests => 13; |
19 |
use Test::More tests => 13; |
20 |
use Test::Warn; |
20 |
use Test::Warn; |
21 |
|
21 |
|
22 |
use C4::Auth qw / in_ipset /; |
22 |
use C4::Auth qw / in_iprange /; |
23 |
|
23 |
|
24 |
$ENV{REMOTE_ADDR} = '192.168.1.30'; |
24 |
$ENV{REMOTE_ADDR} = '192.168.1.30'; |
25 |
my $ipset1 = "192.168.1.30"; |
25 |
my $ipset1 = "192.168.1.30"; |
26 |
|
26 |
|
27 |
ok(in_ipset("192.168.1.30"), 'simple single ip matching remote ip'); |
27 |
ok(in_iprange("192.168.1.30"), 'simple single ip matching remote ip'); |
28 |
ok(!in_ipset("192.168.1.31"), 'simple single ip not match remote ip'); |
28 |
ok(!in_iprange("192.168.1.31"), 'simple single ip not match remote ip'); |
29 |
ok(in_ipset("192.168.1.1/24"), 'simple ip range/24 with remote ip in it'); |
29 |
ok(in_iprange("192.168.1.1/24"), 'simple ip range/24 with remote ip in it'); |
30 |
ok(!in_ipset("192.168.2.1/24"), 'simple ip range/24 with remote ip not in it'); |
30 |
ok(!in_iprange("192.168.2.1/24"), 'simple ip range/24 with remote ip not in it'); |
31 |
ok(in_ipset("192.168.2.1/16"), 'simple ip range/16 with remote ip in it'); |
31 |
ok(in_iprange("192.168.2.1/16"), 'simple ip range/16 with remote ip in it'); |
32 |
ok(!in_ipset("192.168.1.10-30"), 'invalidly represented IP range with remote ip in it'); |
32 |
ok(!in_iprange("192.168.1.10-30"), 'invalidly represented IP range with remote ip in it'); |
33 |
ok(in_ipset("192.168.1.10-192.168.1.30"), 'validly represented ip range with remote ip in it'); |
33 |
ok(in_iprange("192.168.1.10-192.168.1.30"), 'validly represented ip range with remote ip in it'); |
34 |
ok(in_ipset("127.0.0.1 192.168.1.30 192.168.2.10-192.168.2.25"), 'multiple ips and ranges, including the remote ip'); |
34 |
ok(in_iprange("127.0.0.1 192.168.1.30 192.168.2.10-192.168.2.25"), 'multiple ips and ranges, including the remote ip'); |
35 |
ok(!in_ipset("127.0.0.1 8.8.8.8 192.168.2.1/24 192.168.3.1/24 192.168.1.1-192.168.1.29"), "multiple ip and ip ranges, with the remote ip in none of them"); |
35 |
ok(!in_iprange("127.0.0.1 8.8.8.8 192.168.2.1/24 192.168.3.1/24 192.168.1.1-192.168.1.29"), "multiple ip and ip ranges, with the remote ip in none of them"); |
36 |
ok(in_ipset(""), "blank list given, no preference set - implies everything goes through."); |
36 |
ok(in_iprange(""), "blank list given, no preference set - implies everything goes through."); |
37 |
ok(in_ipset(), "no list given, no preference set - implies everything goes through."); |
37 |
ok(in_iprange(), "no list given, no preference set - implies everything goes through."); |
38 |
ok(in_ipset("192.168.1.1/36"), 'simple invalid ip range/36 with remote ip in it'); |
38 |
ok(in_iprange("192.168.1.1/36"), 'simple invalid ip range/36 with remote ip in it'); |
39 |
$ENV{DEBUG} = 1; |
39 |
$ENV{DEBUG} = 1; |
40 |
warning_like { in_ipset("192.168.1.1/36") } |
40 |
warning_like { in_iprange("192.168.1.1/36") } |
41 |
qr/cidrlookup failed for/, |
41 |
qr/cidrlookup failed for/, |
42 |
'noisy simple invalid ip range/36 with remote ip in it'; |
42 |
'noisy simple invalid ip range/36 with remote ip in it'; |
43 |
- |
|
|