1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
use strict;
use warnings;
use Test::More;
use Net::Proxy::Connector;
BEGIN {
eval { require LWP::UserAgent; };
plan skip_all => 'LWP::UserAgent not available' if $@;
}
use Net::Proxy::Connector::connect;
plan tests => 13;
# delete all proxy keys from the environment
delete $ENV{$_} for grep { /_proxy$/i } keys %ENV;
my $c;
my $args = {};
eval { $c = Net::Proxy::Connector::connect->new( $args ); };
like( $@, qr/^host parameter is required /, 'No host');
$args->{host} = 'example.com';
eval { $c = Net::Proxy::Connector::connect->new( $args ); };
like( $@, qr/^port parameter is required /, 'No port');
$args->{port} = 9999;
$ENV{HTTP_PROXY} = 'http://powie:zgruppp@urkk.crunch.com:8888/';
eval { $c = Net::Proxy::Connector::connect->new( $args ); };
is( $@, '', 'env_proxy');
isa_ok( $c, 'Net::Proxy::Connector::connect' );
delete $ENV{HTTP_PROXY};
eval { $c = Net::Proxy::Connector::connect->new( $args ); };
like( $@, qr/^proxy_host parameter is required /, 'No proxy_host');
$args->{proxy_host} = 'urkk.crunch.com';
eval { $c = Net::Proxy::Connector::connect->new( $args ); };
is( $@, '', 'proxy_host');
isa_ok( $c, 'Net::Proxy::Connector::connect' );
$args->{proxy_port} = 8888;
eval { $c = Net::Proxy::Connector::connect->new( $args ); };
is( $@, '', 'proxy_port');
isa_ok( $c, 'Net::Proxy::Connector::connect' );
$args->{proxy_user} = 'barkhausen';
eval { $c = Net::Proxy::Connector::connect->new( $args ); };
is( $@, '', 'proxy_user');
isa_ok( $c, 'Net::Proxy::Connector::connect' );
$args->{proxy_pass} = 'gerfaut';
eval { $c = Net::Proxy::Connector::connect->new( $args ); };
is( $@, '', 'proxy_pass');
isa_ok( $c, 'Net::Proxy::Connector::connect' );
|