#!/usr/bin/perl use Test::More; use LWP::ConsoleLogger::Easy qw( debug_ua ); use IO::Socket::SSL; use LWP::UserAgent; my $DEBUG = 1; my $num_tests = 0; my %pages = ( # some name for the page to hit 'google' => [ # the url to hit 'https://www.google.com', # regex obj to validate returned content qr/Google Search/, ], ); my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 1 }); if( $DEBUG == 1 ){ LWP::ConsoleLogger::Easy::debug_ua($ua, 6); $IO::Socket::SSL::DEBUG = 3; } my ($response, $content, $aurl, $regex_validator, $apage); foreach $apage (keys %pages){ ($aurl, $regex_validator) = @{$pages{$apage}}; $response = $ua->get($aurl); ok(defined($response), "$apage hit : $aurl"); $num_tests++; ok($response->is_success==1, "$apage hit got success status code : $aurl") or BAIL_OUT("$apage : failed to hit : $aurl"); $num_tests++; $content = $response->decoded_content; ok($content =~ $regex_validator, "$apage validated OK") or print "$apage : failed to validate the following content:\n".$content."\nend content.\n"; $num_tests++; } # END done_testing($num_tests);