]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/nntpd-tls.t
update copyrights for 2021
[public-inbox.git] / t / nntpd-tls.t
index c6dceaaa660793b8f6ce67fa1b8f57cd081f26fc..1194be6f18f802a224e810eab0795594e5b76fd6 100644 (file)
@@ -1,19 +1,15 @@
-# Copyright (C) 2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use warnings;
 use Test::More;
 use Socket qw(SOCK_STREAM IPPROTO_TCP SOL_SOCKET);
+use PublicInbox::TestCommon;
 # IO::Poll and Net::NNTP are part of the standard library, but
 # distros may split them off...
-foreach my $mod (qw(DBD::SQLite IO::Socket::SSL Net::NNTP IO::Poll)) {
-       eval "require $mod";
-       plan skip_all => "$mod missing for $0" if $@;
-}
+require_mods(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';
@@ -24,9 +20,8 @@ unless (-r $key && -r $cert) {
 
 use_ok 'PublicInbox::TLS';
 use_ok 'IO::Socket::SSL';
-require './t/common.perl';
 require PublicInbox::InboxWritable;
-require PublicInbox::MIME;
+require PublicInbox::Eml;
 require PublicInbox::SearchIdx;
 our $need_zlib;
 eval { require Compress::Raw::Zlib } or
@@ -66,11 +61,7 @@ EOF
 
 {
        my $im = $ibx->importer(0);
-       my $mime = PublicInbox::MIME->new(do {
-               open my $fh, '<', 't/data/0001.patch' or die;
-               local $/;
-               <$fh>
-       });
+       my $mime = eml_load 't/data/0001.patch';
        ok($im->add($mime), 'message added');
        $im->done;
        if ($version == 1) {
@@ -177,7 +168,7 @@ for my $args (
 
        SKIP: {
                skip 'TCP_DEFER_ACCEPT is Linux-only', 2 if $^O ne 'linux';
-               my $var = Socket::TCP_DEFER_ACCEPT();
+               my $var = eval { Socket::TCP_DEFER_ACCEPT() } // 9;
                defined(my $x = getsockopt($nntps, IPPROTO_TCP, $var)) or die;
                ok(unpack('i', $x) > 0, 'TCP_DEFER_ACCEPT set on NNTPS');
                defined($x = getsockopt($starttls, IPPROTO_TCP, $var)) or die;