]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/nntpd.t
Merge remote-tracking branch 'origin/email-simple-mem' into master
[public-inbox.git] / t / nntpd.t
index cce21eeb620d09bfc9c783993ce5de743b94d9fa..bf5bb883f728dcb8f500ff67b831962e8b40c174 100644 (file)
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -91,7 +91,7 @@ EOF
                $im->add($mime);
                $im->done;
                if ($version == 1) {
-                       my $s = PublicInbox::SearchIdx->new($mainrepo, 1);
+                       my $s = PublicInbox::SearchIdx->new($ibx, 1);
                        $s->index_sync;
                }
        }
@@ -107,6 +107,13 @@ EOF
        is_deeply([$n->group($group)], [ qw(0 1 1), $group ], 'GROUP works');
        is_deeply($n->listgroup($group), [1], 'listgroup OK');
 
+       SKIP: {
+               $n->can('starttls') or
+                       skip('Net::NNTP too old to support STARTTLS', 2);
+               ok(!$n->starttls, 'STARTTLS fails when unconfigured');
+               is($n->code, 580, 'got 580 code on server w/o TLS');
+       };
+
        %opts = (
                PeerAddr => $host_port,
                Proto => 'tcp',
@@ -243,13 +250,30 @@ Date: Fri, 02 Oct 1993 00:00:00 +0000
                $im->add($for_leafnode);
                $im->done;
                if ($version == 1) {
-                       my $s = PublicInbox::SearchIdx->new($mainrepo, 1);
+                       my $s = PublicInbox::SearchIdx->new($ibx, 1);
                        $s->index_sync;
                }
                my $hdr = $n->head("<$long_hdr>");
                my $expect = qr/\AMessage-ID: /i . qr/\Q<$long_hdr>\E/;
                ok(scalar(grep(/$expect/, @$hdr)), 'Message-ID not folded');
                ok(scalar(grep(/^Path:/, @$hdr)), 'Path: header found');
+
+               # it's possible for v2 messages to have 2+ Message-IDs,
+               # but leafnode can't handle it
+               if ($version != 1) {
+                       my @mids = ("<$long_hdr>", '<2mid@wtf>');
+                       $for_leafnode->header_set('Message-ID', @mids);
+                       $for_leafnode->body_set('not-a-dupe');
+                       my $warn = '';
+                       $SIG{__WARN__} = sub { $warn .= join('', @_) };
+                       $im->add($for_leafnode);
+                       $im->done;
+                       like($warn, qr/reused/, 'warned for reused MID');
+                       $hdr = $n->head('<2mid@wtf>');
+                       my @hmids = grep(/\AMessage-ID: /i, @$hdr);
+                       is(scalar(@hmids), 1, 'Single Message-ID in header');
+                       like($hmids[0], qr/: <2mid\@wtf>/, 'got expected mid');
+               }
        }
 
        # pipelined requests: