From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] lei: fix IMAP auth failure handling
Date: Wed, 31 Mar 2021 03:29:47 +0500 [thread overview]
Message-ID: <20210330222947.27332-1-e@80x24.org> (raw)
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 | 2 +-
lib/PublicInbox/LeiTag.pm | 2 +-
xt/lei-auth-fail.t | 15 +++++++--------
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm
index 227a2a21..dbf655b6 100644
--- a/lib/PublicInbox/LeiImport.pm
+++ b/lib/PublicInbox/LeiImport.pm
@@ -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);
diff --git a/lib/PublicInbox/LeiTag.pm b/lib/PublicInbox/LeiTag.pm
index 56ac25fa..8b012b16 100644
--- a/lib/PublicInbox/LeiTag.pm
+++ b/lib/PublicInbox/LeiTag.pm
@@ -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);
diff --git a/xt/lei-auth-fail.t b/xt/lei-auth-fail.t
index 78f8466d..e352aab3 100644
--- a/xt/lei-auth-fail.t
+++ b/xt/lei-auth-fail.t
@@ -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;
reply other threads:[~2021-03-30 22:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210330222947.27332-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).