10 (my $libnet_t = __FILE__) =~ s/config.t/libnet_t.pl/;
16 ok( exists $INC{'Net/Config.pm'}, 'Net::Config should have been used' );
17 ok( keys %NetConfig, '%NetConfig should be imported' );
19 undef $NetConfig{'ftp_firewall'};
20 is( Net::Config->requires_firewall(), 0,
21 'requires_firewall() should return 0 without ftp_firewall defined' );
23 $NetConfig{'ftp_firewall'} = 1;
24 is( Net::Config->requires_firewall(''), -1,
25 '... should return -1 without a valid hostname' );
27 delete $NetConfig{'local_netmask'};
28 is( Net::Config->requires_firewall('127.0.0.1'), 0,
29 '... should return 0 without local_netmask defined' );
31 $NetConfig{'local_netmask'} = '127.0.0.1/24';
32 is( Net::Config->requires_firewall('127.0.0.1'), 0,
33 '... should return false if host is within netmask' );
34 is( Net::Config->requires_firewall('192.168.10.0'), 1,
35 '... should return true if host is outside netmask' );
37 # now try more netmasks
38 $NetConfig{'local_netmask'} = [ '127.0.0.1/24', '10.0.0.0/8' ];
39 is( Net::Config->requires_firewall('10.10.255.254'), 0,
40 '... should find success with mutiple local netmasks' );
41 is( Net::Config->requires_firewall('192.168.10.0'), 1,
42 '... should handle failure with multiple local netmasks' );
44 is( \&Net::Config::is_external, \&Net::Config::requires_firewall,
45 'is_external() should be an alias for requires_firewall()' );