1use strict; 2use Test::More tests => 8; 3 4use Net::SSL; 5 6# ensure no proxification takes place 7$ENV{NO_PROXY} = '127.0.0.1'; 8 9my $sock; 10eval { 11 $sock = Net::SSL->new( 12 PeerAddr => '127.0.0.1', 13 PeerPort => 443, 14 Timeout => 3, 15 ); 16}; 17 18my $test_name = 'Net::SSL->new'; 19if ($@) { 20 my $fail = $@; 21 if ($fail =~ /\AConnect failed: connect: \b/i) { 22 pass( "$test_name - expected failure" ); 23 } 24 else { 25 fail( "$test_name" ); 26 diag( $fail ); 27 } 28} 29else { 30 ok( defined $sock, $test_name ); 31} 32 33SKIP: { 34 skip( "nothing listening on localhost:443", 7 ) 35 unless defined $sock; 36 37 is( ref($sock), 'Net::SSL', 'blessed socket' ); 38 39 eval { $sock->accept }; 40 like ($@, qr(\Aaccept not implemented for Net::SSL sockets), 41 'accept() not implemented' 42 ); 43 44 eval { $sock->getc }; 45 like ($@, qr(\Agetc not implemented for Net::SSL sockets), 46 'getc() not implemented' 47 ); 48 49 eval { $sock->ungetc }; 50 like ($@, qr(\Aungetc not implemented for Net::SSL sockets), 51 'ungetc() not implemented' 52 ); 53 54 eval { $sock->getlines }; 55 like ($@, qr(\Agetlines not implemented for Net::SSL sockets), 56 'getlines() not implemented' 57 ); 58 59 is( $sock->blocking, 1, 'socket is blocking' ); 60 $sock->blocking(0); 61 is( $sock->blocking, 0, 'socket is now non-blocking' ); 62} 63