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

(-)a/t/Auth.t (-2 / +21 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
use Test::NoWarnings;
19
use Test::NoWarnings;
20
use Test::More tests => 13;
20
use Test::More tests => 14;
21
use Test::Warn;
21
use Test::Warn;
22
22
23
use C4::Auth qw( in_iprange );
23
use C4::Auth qw( in_iprange );
Lines 42-44 ok( Link Here
42
ok( in_iprange(""),               "blank list given, no preference set - implies everything goes through." );
42
ok( in_iprange(""),               "blank list given, no preference set - implies everything goes through." );
43
ok( in_iprange(),                 "no list given, no preference set - implies everything goes through." );
43
ok( in_iprange(),                 "no list given, no preference set - implies everything goes through." );
44
ok( in_iprange("192.168.1.1/36"), 'simple invalid ip range/36 with remote ip in it' );
44
ok( in_iprange("192.168.1.1/36"), 'simple invalid ip range/36 with remote ip in it' );
45
- 
45
46
subtest 'test localhost' => sub {
47
    plan tests => 2;
48
49
    sub _localhost_test {
50
      my $REMOTE_ADDR = shift;
51
      subtest "test REMOTE_ADDR = $REMOTE_ADDR" => sub {
52
        plan tests => 3;
53
        $ENV{REMOTE_ADDR} = $REMOTE_ADDR;
54
55
        ok(in_iprange('::1 127.0.0.1'), 'REMOTE_ADDR is in_iprange(::1 127.0.0.1)');
56
        ok(in_iprange($REMOTE_ADDR), 'REMOTE_ADDR is in_iprange('.$REMOTE_ADDR.')');
57
        my $opposite = $REMOTE_ADDR eq '127.0.0.1' ? '::1' : '127.0.0.1';
58
        ok(!in_iprange($opposite), 'REMOTE_ADDR is not in_iprange('.$opposite.')');
59
      };
60
    }
61
62
    _localhost_test('127.0.0.1');
63
    _localhost_test('::1');
64
};

Return to bug 41011