diff options
author | Steffen Ullrich <Steffen_Ullrich@genua.de> | 2014-05-16 22:27:23 +0200 |
---|---|---|
committer | Steffen Ullrich <Steffen_Ullrich@genua.de> | 2014-05-16 22:27:23 +0200 |
commit | ef409a3c4e598cb0819886060d3f0ad5871ba263 (patch) | |
tree | 545cfdfb7cc23b89ddfdf02cc8f08d0aa70d0933 | |
parent | c7d5842b0010f9f2ff01394ffac75df8256eda08 (diff) | |
download | perl-libnet-ef409a3c4e598cb0819886060d3f0ad5871ba263.tar.gz |
added external test for pop3 ssl
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | t/external/pop3-ssl.t | 51 |
2 files changed, 52 insertions, 0 deletions
@@ -43,3 +43,4 @@ t/pop3_ssl.t t/pop3_ipv6.t t/time.t t/external/smtp-ssl.t +t/external/pop3-ssl.t diff --git a/t/external/pop3-ssl.t b/t/external/pop3-ssl.t new file mode 100644 index 0000000..585890c --- /dev/null +++ b/t/external/pop3-ssl.t @@ -0,0 +1,51 @@ + +use strict; +use warnings; +use Net::POP3; +use Test::More; + +my $host = 'pop.gmx.net'; +my $debug = 0; + +plan skip_all => "no SSL support" if ! Net::POP3->can_ssl; +plan skip_all => "no verified SSL connection to $host:995 - $@" if ! eval { + IO::Socket::SSL->new(PeerAddr => "$host:995", Timeout => 10) + || die($IO::Socket::SSL::SSL_ERROR||$!); +}; + +plan tests => 2; + +SKIP: { + diag( "connect inet to $host:110" ); + skip "no inet connect to $host:110",1 + if ! IO::Socket::INET->new(PeerAddr => "$host:110", Timeout => 10); + my $pop3 = Net::POP3->new($host, Debug => $debug, Timeout => 10) + or skip "normal POP3 failed: $@",1; + skip "no STARTTLS support",1 if $pop3->message !~/STARTTLS/; + + if (!$pop3->starttls) { + fail("starttls failed: ".$pop3->code." $@") + } else { + # we now should have access to SSL stuff + my $cipher = eval { $pop3->get_cipher }; + if (!$cipher) { + fail("after starttls: not an SSL object"); + } elsif ( $pop3->quit ) { + pass("starttls + quit ok, cipher=$cipher"); + } else { + fail("quit after starttls failed: ".$pop3->code); + } + } +} + + +my $pop3 = Net::POP3->new($host, SSL => 1, Timeout => 10, Debug => $debug); +# we now should have access to SSL stuff +my $cipher = eval { $pop3->get_cipher }; +if (!$cipher) { + fail("after ssl connect: not an SSL object"); +} elsif ( $pop3->quit ) { + pass("ssl connect ok, cipher=$cipher"); +} else { + fail("quit after direct ssl failed: ".$pop3->code); +} |