index: repair "Mixed Up" messages before indexing.
[notmuch] / test / T351-pgpmime-mangling.sh
1 #!/usr/bin/env bash
2
3 test_description='PGP/MIME message mangling'
4 . $(dirname "$0")/test-lib.sh || exit 1
5
6 add_gnupg_home
7 add_email_corpus mangling
8
9 bodytext='["body"][0]["content"][1]["content"]="The password is \"abcd1234!\", please do not tell anyone.\n"'
10
11 test_begin_subtest "show 'Mixed-Up' mangled PGP/MIME message correctly"
12 test_subtest_known_broken
13 output=$(notmuch show --format=json --decrypt=true id:mixed-up@mangling.notmuchmail.org)
14 test_json_nodes <<<"$output" \
15                 'body:[0][0][0]'"$bodytext"
16
17 test_begin_subtest "reply to 'Mixed-Up' mangled PGP/MIME message correctly"
18 test_subtest_known_broken
19 output=$(notmuch reply --format=json --decrypt=true id:mixed-up@mangling.notmuchmail.org)
20 test_json_nodes <<<"$output" \
21                 'body:["original"]'"$bodytext"
22
23 test_begin_subtest "repaired 'Mixed-up' messages can be found with index.repaired=mixedup"
24 output=$(notmuch search --output=messages property:index.repaired=mixedup)
25 test_expect_equal "$output" id:mixed-up@mangling.notmuchmail.org
26
27 test_begin_subtest "index cleartext of 'Mixed-Up' mangled PGP/MIME message"
28 test_expect_success 'notmuch reindex --decrypt=true id:mixed-up@mangling.notmuchmail.org'
29
30 test_begin_subtest "search cleartext of 'Mixed-Up' mangled PGP/MIME message"
31 output=$(notmuch search --output=messages body:password)
32 test_expect_equal "$output" id:mixed-up@mangling.notmuchmail.org
33
34 test_done