]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/nntpd-tls.t
nntp: support COMPRESS DEFLATE per RFC 8054
[public-inbox.git] / t / nntpd-tls.t
index 4cf53daad8cd0325fdb7e9555ab56bc7a19906d4..84d6e3c08f8bbc499e7698b33e81a7fb9f39092d 100644 (file)
@@ -13,6 +13,8 @@ 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';
@@ -27,6 +29,9 @@ 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);
@@ -232,6 +237,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;
 }