notmuch/test/T351-pgpmime-mangling.sh
Daniel Kahn Gillmor 4b1a8fd183 index: repair "Mixed Up" messages before indexing.
When encountering a message that has been mangled in the "mixed up"
way by an intermediate MTA, notmuch should instead repair it and index
the repaired form.

When it does this, it also associates the index.repaired=mixedup
property with the message.  If a problem is found with this repair
process, or an improved repair process is proposed later, this should
make it easy for people to reindex the relevant message.  The property
will also hopefully make it easier to diagnose this particular problem
in the future.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-09-15 19:07:06 -04:00

34 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
test_description='PGP/MIME message mangling'
. $(dirname "$0")/test-lib.sh || exit 1
add_gnupg_home
add_email_corpus mangling
bodytext='["body"][0]["content"][1]["content"]="The password is \"abcd1234!\", please do not tell anyone.\n"'
test_begin_subtest "show 'Mixed-Up' mangled PGP/MIME message correctly"
test_subtest_known_broken
output=$(notmuch show --format=json --decrypt=true id:mixed-up@mangling.notmuchmail.org)
test_json_nodes <<<"$output" \
'body:[0][0][0]'"$bodytext"
test_begin_subtest "reply to 'Mixed-Up' mangled PGP/MIME message correctly"
test_subtest_known_broken
output=$(notmuch reply --format=json --decrypt=true id:mixed-up@mangling.notmuchmail.org)
test_json_nodes <<<"$output" \
'body:["original"]'"$bodytext"
test_begin_subtest "repaired 'Mixed-up' messages can be found with index.repaired=mixedup"
output=$(notmuch search --output=messages property:index.repaired=mixedup)
test_expect_equal "$output" id:mixed-up@mangling.notmuchmail.org
test_begin_subtest "index cleartext of 'Mixed-Up' mangled PGP/MIME message"
test_expect_success 'notmuch reindex --decrypt=true id:mixed-up@mangling.notmuchmail.org'
test_begin_subtest "search cleartext of 'Mixed-Up' mangled PGP/MIME message"
output=$(notmuch search --output=messages body:password)
test_expect_equal "$output" id:mixed-up@mangling.notmuchmail.org
test_done