From 725fd624277364402a86262486cdb79458db4ed8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 18 Feb 2021 23:22:25 +0300 Subject: lei: check for IMAP auth errors We need to ensure authentication failures and error codes get propagated to the parent process(es) properly. v2: update MANIFEST v3: LeiAuth.pm ->_lei_cfg bit moved to a previous commit --- xt/lei-auth-fail.t | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 xt/lei-auth-fail.t (limited to 'xt') diff --git a/xt/lei-auth-fail.t b/xt/lei-auth-fail.t new file mode 100644 index 00000000..5308d0f9 --- /dev/null +++ b/xt/lei-auth-fail.t @@ -0,0 +1,20 @@ +#!perl -w +# Copyright (C) 2021 all contributors +# License: AGPL-3.0+ +use strict; use v5.10.1; use PublicInbox::TestCommon; + +# 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'; +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'); +}); +done_testing; -- cgit v1.2.3-24-ge0c7