public-inbox.git  about / heads / tags
an "archives first" approach to mailing lists
blob 1ccc2ab22e445ebed66c28e439421704b825f66c 916 bytes (raw)
$ git show HEAD:xt/lei-auth-fail.t	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
#!perl -w
# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use v5.12;
use PublicInbox::TestCommon;
require_mods(qw(Mail::IMAPClient lei));

# TODO: mock IMAP server which fails at authentication so we don't
# have to make external connections to test this:
my $imap_fail = $ENV{TEST_LEI_IMAP_FAIL_URL} //
	'imaps://AzureDiamond:Hunter2@public-inbox.org:994/INBOX';
my ($ro_home, $cfg_path) = setup_public_inboxes;
test_lei(sub {
	for my $pfx ([qw(q z:0.. --only), "$ro_home/t1", '-o'],
			[qw(convert -o mboxrd:/dev/stdout)],
			[qw(convert t/utf8.eml -o), $imap_fail],
			['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;

git clone https://public-inbox.org/public-inbox.git
git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/public-inbox.git