#!/usr/bin/env bash test_description='PGP/MIME message mangling' . $(dirname "$0")/test-lib.sh || exit 1 add_gnupg_home add_email_corpus mangling test_begin_subtest "handle 'Mixed-Up' mangled PGP/MIME message" output=$(notmuch show --format=json --decrypt=true id:mixed-up@mangling.notmuchmail.org) test_json_nodes <<<"$output" \ 'body:[0][0][0]["body"][0]["content"][1]["content"]="The password is \"abcd1234!\", please do not tell anyone.\n"' 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 "reindex '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