X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Fnntpd-tls.t;h=0b6afcefdff750ec189947a9697505922dbb404f;hb=1bbfab375438f149dcff9047dd0c5ed3a08eed53;hp=4cf53daad8cd0325fdb7e9555ab56bc7a19906d4;hpb=0f1da9d213e16946371b5c140b1c55b7231a8cd5;p=public-inbox.git diff --git a/t/nntpd-tls.t b/t/nntpd-tls.t index 4cf53daa..0b6afcef 100644 --- a/t/nntpd-tls.t +++ b/t/nntpd-tls.t @@ -13,12 +13,14 @@ foreach my $mod (qw(DBD::SQLite IO::Socket::SSL Net::NNTP IO::Poll)) { } Net::NNTP->can('starttls') or plan skip_all => 'Net::NNTP does not support TLS'; +IO::Socket::SSL->VERSION(2.007) or + plan skip_all => 'IO::Socket::SSL <2.007 not supported by Net::NNTP'; my $cert = 'certs/server-cert.pem'; my $key = 'certs/server-key.pem'; unless (-r $key && -r $cert) { plan skip_all => - "certs/ missing for $0, run ./create-certs.perl in certs/"; + "certs/ missing for $0, run $^X ./create-certs.perl in certs/"; } use_ok 'PublicInbox::TLS'; @@ -27,12 +29,15 @@ require './t/common.perl'; require PublicInbox::InboxWritable; require PublicInbox::MIME; require PublicInbox::SearchIdx; +my $need_zlib; +eval { require Compress::Raw::Zlib } or + $need_zlib = 'Compress::Raw::Zlib missing'; my $version = 2; # v2 needs newer git require_git('2.6') if $version >= 2; my $tmpdir = tempdir('pi-nntpd-tls-XXXXXX', TMPDIR => 1, CLEANUP => 1); my $err = "$tmpdir/stderr.log"; my $out = "$tmpdir/stdout.log"; -my $mainrepo = "$tmpdir"; +my $inboxdir = "$tmpdir"; my $pi_config = "$tmpdir/pi_config"; my $group = 'test-nntpd-tls'; my $addr = $group . '@example.com'; @@ -47,7 +52,7 @@ END { }; my $ibx = PublicInbox::Inbox->new({ - mainrepo => $mainrepo, + inboxdir => $inboxdir, name => 'nntpd-tls', version => $version, -primary_address => $addr, @@ -59,7 +64,7 @@ $ibx->init_inbox(0); open my $fh, '>', $pi_config or die "open: $!\n"; print $fh < [qw(1 1 n)] }; # start negotiating a slow TLS connection - my $slow = IO::Socket::INET->new( - Proto => 'tcp', - PeerAddr => $nntps_addr, - Type => SOCK_STREAM, - Blocking => 0, - ); + my $slow = tcp_connect($nntps, Blocking => 0); $slow = IO::Socket::SSL->start_SSL($slow, SSL_startHandshake => 0, %o); my $slow_done = $slow->connect_SSL; diag('W: connect_SSL early OK, slow client test invalid') if $slow_done; @@ -232,6 +232,14 @@ sub get_capa { die "unexpected: $!" unless defined($r); die 'unexpected EOF' if $r == 0; } until $capa =~ /\.\r\n\z/; + + my $deflate_capa = qr/\r\nCOMPRESS DEFLATE\r\n/; + if ($need_zlib) { + unlike($capa, $deflate_capa, + 'COMPRESS DEFLATE NOT advertised '.$need_zlib); + } else { + like($capa, $deflate_capa, 'COMPRESS DEFLATE advertised'); + } $capa; }