Update Changes.
[p5sagit/p5-mst-13.2.git] / lib / Net / t / config.t
CommitLineData
c8570720 1#!./perl -w
2
3BEGIN {
4 if ($ENV{PERL_CORE}) {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 }
8}
9
10(my $libnet_t = __FILE__) =~ s/config.t/libnet_t.pl/;
11require $libnet_t;
12
13print "1..10\n";
14
15use Net::Config;
16ok( exists $INC{'Net/Config.pm'}, 'Net::Config should have been used' );
17ok( keys %NetConfig, '%NetConfig should be imported' );
18
19undef $NetConfig{'ftp_firewall'};
20is( Net::Config->requires_firewall(), 0,
21 'requires_firewall() should return 0 without ftp_firewall defined' );
22
23$NetConfig{'ftp_firewall'} = 1;
24is( Net::Config->requires_firewall(''), -1,
25 '... should return -1 without a valid hostname' );
26
27delete $NetConfig{'local_netmask'};
28is( Net::Config->requires_firewall('127.0.0.1'), 0,
29 '... should return 0 without local_netmask defined' );
30
31$NetConfig{'local_netmask'} = '127.0.0.1/24';
32is( Net::Config->requires_firewall('127.0.0.1'), 0,
33 '... should return false if host is within netmask' );
34is( Net::Config->requires_firewall('192.168.10.0'), 1,
35 '... should return true if host is outside netmask' );
36
37# now try more netmasks
38$NetConfig{'local_netmask'} = [ '127.0.0.1/24', '10.0.0.0/8' ];
39is( Net::Config->requires_firewall('10.10.255.254'), 0,
40 '... should find success with mutiple local netmasks' );
41is( Net::Config->requires_firewall('192.168.10.0'), 1,
42 '... should handle failure with multiple local netmasks' );
43
44is( \&Net::Config::is_external, \&Net::Config::requires_firewall,
45 'is_external() should be an alias for requires_firewall()' );