]> Sergey Matveev's repositories - public-inbox.git/blob - xt/lei-auth-fail.t
lei: fix IMAP auth failure handling
[public-inbox.git] / xt / lei-auth-fail.t
1 #!perl -w
2 # Copyright (C) 2021 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 use strict; use v5.10.1; use PublicInbox::TestCommon;
5 require_mods(qw(Mail::IMAPClient));
6
7 # TODO: mock IMAP server which fails at authentication so we don't
8 # have to make external connections to test this:
9 my $imap_fail = $ENV{TEST_LEI_IMAP_FAIL_URL} //
10         'imaps://AzureDiamond:Hunter2@public-inbox.org:994/INBOX';
11 test_lei(sub {
12         for my $pfx ([qw(convert -o mboxrd:/dev/stdout)], ['import'],
13                         [qw(tag +L:INBOX)]) {
14                 ok(!lei(@$pfx, $imap_fail), "IMAP auth failure on @$pfx");
15                 like($lei_err, qr!\bE:.*?imaps://.*?!sm, 'error shown');
16                 unlike($lei_err, qr!Hunter2!s, 'password not shown');
17                 is($lei_out, '', 'nothing output');
18         }
19 });
20 done_testing;