]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/nntpd-tls.t
config: support "inboxdir" in addition to "mainrepo"
[public-inbox.git] / t / nntpd-tls.t
index 49b31221f02c6cf0ec19af788010c864ba857984..0b6afcefdff750ec189947a9697505922dbb404f 100644 (file)
@@ -20,7 +20,7 @@ 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';
@@ -29,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';
@@ -49,7 +52,7 @@ END {
 };
 
 my $ibx = PublicInbox::Inbox->new({
-       mainrepo => $mainrepo,
+       inboxdir => $inboxdir,
        name => 'nntpd-tls',
        version => $version,
        -primary_address => $addr,
@@ -61,7 +64,7 @@ $ibx->init_inbox(0);
        open my $fh, '>', $pi_config or die "open: $!\n";
        print $fh <<EOF
 [publicinbox "nntpd-tls"]
-       mainrepo = $mainrepo
+       inboxdir = $inboxdir
        address = $addr
        indexlevel = basic
        newsgroup = $group
@@ -114,12 +117,7 @@ for my $args (
        my $expect = { $group => [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;
@@ -234,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;
 }