View | Details | Raw Unified | Return to bug 28657
Collapse All | Expand All

(-)a/C4/Auth.pm (+1 lines)
Lines 2262-2267 Returns 1 if the remote address is in the provided iprange, or 0 otherwise. Link Here
2262
2262
2263
sub in_iprange {
2263
sub in_iprange {
2264
    my ($iprange) = @_;
2264
    my ($iprange) = @_;
2265
    return 1 unless $iprange;
2265
    my $result = 0;
2266
    my $result = 0;
2266
    # FIXME remove '*' for backwards compatibility in branchip settings
2267
    # FIXME remove '*' for backwards compatibility in branchip settings
2267
    $iprange =~ s|\*||g;
2268
    $iprange =~ s|\*||g;
(-)a/t/Auth.t (-13 / +12 lines)
Lines 23-37 use C4::Auth qw( in_iprange ); Link Here
23
23
24
$ENV{REMOTE_ADDR} = '192.168.1.30';
24
$ENV{REMOTE_ADDR} = '192.168.1.30';
25
25
26
ok(in_iprange("192.168.1.30"), 'simple single ip matching remote ip');
26
is( 1, in_iprange("192.168.1.30"), 'simple single ip matching remote ip' );
27
ok(!in_iprange("192.168.1.31"), 'simple single ip not match remote ip');
27
is( 0, in_iprange("192.168.1.31"), 'simple single ip not match remote ip' );
28
ok(in_iprange("192.168.1.1/24"), 'simple ip range/24 with remote ip in it');
28
is( 1, in_iprange("192.168.1.1/24"), 'simple ip range/24 with remote ip in it' );
29
ok(!in_iprange("192.168.2.1/24"), 'simple ip range/24 with remote ip not in it');
29
is( 0, in_iprange("192.168.2.1/24"), 'simple ip range/24 with remote ip not in it' );
30
ok(in_iprange("192.168.2.1/16"), 'simple ip range/16 with remote ip in it');
30
is( 1, in_iprange("192.168.2.1/16"), 'simple ip range/16 with remote ip in it' );
31
ok(!in_iprange("192.168.1.10-30"), 'invalidly represented IP range with remote ip in it');
31
is( 0, in_iprange("192.168.1.10-30"), 'invalidly represented IP range with remote ip in it' );
32
ok(in_iprange("192.168.1.10-192.168.1.30"), 'validly represented ip range with remote ip in it');
32
is( 1, in_iprange("192.168.1.10-192.168.1.30"), 'validly represented ip range with remote ip in it' );
33
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');
33
is( 1, 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' );
34
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");
34
is( 0, 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" );
35
ok(in_iprange(""), "blank list given, no preference set - implies everything goes through.");
35
is( 1, in_iprange(""), "blank list given, no preference set - implies everything goes through." );
36
ok(in_iprange(), "no list given, no preference set - implies everything goes through.");
36
is( 1, in_iprange(), "no list given, no preference set - implies everything goes through." );
37
ok(in_iprange("192.168.1.1/36"), 'simple invalid ip range/36 with remote ip in it');
37
is( 0, in_iprange("192.168.1.1/36"), 'simple invalid ip range/36 with remote ip in it' );
38
- 

Return to bug 28657