]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: fix IMAP auth failure handling
authorEric Wong <e@80x24.org>
Tue, 30 Mar 2021 22:29:47 +0000 (03:29 +0500)
committerEric Wong <e@80x24.org>
Wed, 31 Mar 2021 00:33:53 +0000 (00:33 +0000)
We must use the $ops hashref returned by lei->workers_start,
since it's modified to include extra handlers for auth failures
and whatnot.

Fixes: 954581b8e575966a ("lei: simplify PktOp callers")
lib/PublicInbox/LeiImport.pm
lib/PublicInbox/LeiTag.pm
xt/lei-auth-fail.t

index 227a2a2111fb38bf98819387e7b870b3e2118b7a..dbf655b6f3fc690f8e39f41de8b24740b2d6aded 100644 (file)
@@ -76,7 +76,7 @@ sub lei_import { # the main "lei import" method
        my $ops = { '' => [ \&import_done, $lei ] };
        $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
        $self->{-wq_nr_workers} = $j // 1; # locked
-       my ($op_c, undef) = $lei->workers_start($self, 'lei_import', $j, $ops);
+       (my $op_c, $ops) = $lei->workers_start($self, 'lei_import', $j, $ops);
        $lei->{imp} = $self;
        net_merge_complete($self) unless $lei->{auth};
        $op_c->op_wait_event($ops);
index 56ac25fa690fd6f83edab51a43f0db748192015a..8b012b160eaf5778ffff42115b3e445ebeef60aa 100644 (file)
@@ -116,7 +116,7 @@ sub lei_tag { # the "lei tag" method
        my $ops = { '' => [ \&tag_done, $lei ] };
        $lei->{auth}->op_merge($ops, $self) if $lei->{auth};
        $self->{vmd_mod} = $vmd_mod;
-       my ($op_c, undef) = $lei->workers_start($self, 'lei_tag', 1, $ops);
+       (my $op_c, $ops) = $lei->workers_start($self, 'lei_tag', 1, $ops);
        $lei->{tag} = $self;
        net_merge_complete($self) unless $lei->{auth};
        $op_c->op_wait_event($ops);
index 78f8466d4fec226a258372ceabc9a9bb3bfadd0e..e352aab3e1252d3778ae17c81c7fce146f62fd10 100644 (file)
@@ -9,13 +9,12 @@ require_mods(qw(Mail::IMAPClient));
 my $imap_fail = $ENV{TEST_LEI_IMAP_FAIL_URL} //
        'imaps://AzureDiamond:Hunter2@public-inbox.org:994/INBOX';
 test_lei(sub {
-       ok(!lei(qw(convert -o mboxrd:/dev/stdout), $imap_fail),
-               'IMAP auth failure on convert');
-       like($lei_err, qr!\bE:.*?imaps://.*?!sm, 'error shown');
-       unlike($lei_err, qr!Hunter2!s, 'password not shown');
-       is($lei_out, '', 'nothing output');
-       ok(!lei(qw(import), $imap_fail), 'IMAP auth failure on import');
-       like($lei_err, qr!\bE:.*?imaps://.*?!sm, 'error shown');
-       unlike($lei_err, qr!Hunter2!s, 'password not shown');
+       for my $pfx ([qw(convert -o mboxrd:/dev/stdout)], ['import'],
+                       [qw(tag +L:INBOX)]) {
+               ok(!lei(@$pfx, $imap_fail), "IMAP auth failure on @$pfx");
+               like($lei_err, qr!\bE:.*?imaps://.*?!sm, 'error shown');
+               unlike($lei_err, qr!Hunter2!s, 'password not shown');
+               is($lei_out, '', 'nothing output');
+       }
 });
 done_testing;