]> Sergey Matveev's repositories - public-inbox.git/blob - xt/lei-auth-fail.t
public-inbox 1.7.0
[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 lei));
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 my ($ro_home, $cfg_path) = setup_public_inboxes;
12 test_lei(sub {
13         for my $pfx ([qw(q z:0.. --only), "$ro_home/t1", '-o'],
14                         [qw(convert -o mboxrd:/dev/stdout)],
15                         [qw(convert t/utf8.eml -o), $imap_fail],
16                         ['import'], [qw(tag +L:INBOX)]) {
17                 ok(!lei(@$pfx, $imap_fail), "IMAP auth failure on @$pfx");
18                 like($lei_err, qr!\bE:.*?imaps?://.*?!sm, 'error shown');
19                 unlike($lei_err, qr!Hunter2!s, 'password not shown');
20                 is($lei_out, '', 'nothing output');
21         }
22 });
23 done_testing;