File: 21connect.t

package info (click to toggle)
libnet-proxy-perl 0.12-5
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 304 kB
  • ctags: 66
  • sloc: perl: 777; sh: 84; makefile: 44
file content (57 lines) | stat: -rw-r--r-- 1,685 bytes parent folder | download | duplicates (6)
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' );