use 5.006; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Local::Network::Reconfig', VERSION_FROM => 'lib/Local/Network/Reconfig.pm', # finds $VERSION PREREQ_PM => {'Test::More' => 0, 'LWP::UserAgent' => 0, 'Net::DNS' => 0, 'Crypt::SSLeay' => 0, }, ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/Local/Network/Reconfig.pm', # retrieve abstract from module AUTHOR => 'Marco ') : ()), ); #### #use Test::More tests => 1; use Test::More qw(no_plan) ; BEGIN { use_ok('Local::Network::Reconfig') }; use_ok('LWP::UserAgent') ; # HTTP tests my @urls = qw( http://www.x.it/ http://www.y.com/ http://web.z.it/abcd/ http://report.alpha.com https://report.alpha.com http://beta.gamma.com https://beta.gamma.com ) ; my $ua = LWP::UserAgent->new ; ok(defined($ua),"LWP::UserAgent ready") ; $ua->timeout(10) ; $ua->protocols_allowed( [ 'http', 'https'] ); foreach my $url (@urls) { my $response = $ua->get($url) ; ok($response->is_success,"GET $url") ; } my @authenticated_services = qw( http://authenticated.site.com ) ; foreach my $url (@authenticated_services) { my $response = $ua->get($url) ; is($response->status_line,'401 Access Denied', "Access to $url is authenticated") ; } # DNS tests use_ok('Net::DNS') ; my @nameservers = qw(1.2.3.4 5.6.7.8) ; my @queries = qw(test.me.com test.me.too.it 10.20.30.40 50.60.70.80) ; foreach my $server (@nameservers) { my $resolver = Net::DNS::Resolver->new( nameservers => [$server], recurse => 0, ) ; ok(defined($resolver),"Resolver object for $server") ; foreach my $host (@queries) { ok(defined($resolver->query($host)),"Query to $server for $host") ; } } #### USAGE To use this module type the following: perl Makefile.PL make make test After "perl Makefile.PL" you should check if you need to install any of the prerequisite modules. If something in "make test" goes wrong, you should change in the base directory of the distribution (that one where you typed the "perl Makefile.PL" command) and run: perl -Mblib t/Local-Network-Reconfig.t to get a deeper insight of what is going wrong DEPENDENCIES This module requires these other modules and libraries: Test::More LWP::UserAgent Net::DNS Crypt::SSLeay