#!/usr/bin/env bash test_description='Decryption of inline PGP messages' . $(dirname "$0")/test-lib.sh || exit 1 ################################################## add_gnupg_home test_begin_subtest "Adding inline PGP encrypted message" mkdir -p "$MAIL_DIR/cur" cat < "$MAIL_DIR/cur/inline-pgp-encrypted.eml" Message-Id: inline-pgp-encrypted@testsuite.notmuchmail.org Content-Type: text/plain Subject: inline PGP encrypted message Date: Sat, 01 Jan 2000 12:00:00 +0000 From: test_suite@notmuchmail.org To: test_suite@notmuchmail.org $(echo "this is the sekrit message" | gpg --no-tty --batch --quiet --trust-model=always --encrypt --armor --recipient test_suite@notmuchmail.org) EOF test_expect_success 'notmuch new' test_begin_subtest "inline PGP decryption, --format=json" test_subtest_broken_gmime_2 output=$(notmuch show --format=json --decrypt=true id:inline-pgp-encrypted@testsuite.notmuchmail.org \ | notmuch_json_show_sanitize) expected=' [[[{"body": [{ "content": "this is the sekrit message\n", "content-type": "text/plain", "encstatus": [{"status": "good" }], "id": 1 }], "date_relative": "2000-01-01", "excluded": false, "filename": ["YYYYY"], "headers": { "Date": "Sat, 01 Jan 2000 12:00:00 +0000", "From": "test_suite@notmuchmail.org", "Subject": "inline PGP encrypted message", "To": "test_suite@notmuchmail.org" }, "id": "XXXXX", "match": true, "tags": ["encrypted", "inbox", "unread"], "timestamp": 946728000 }, []]]]' test_expect_equal_json \ "$output" \ "$expected" test_begin_subtest "inline PGP decryption for reply" test_subtest_broken_gmime_2 output=$(notmuch reply --format=json --decrypt=true id:inline-pgp-encrypted@testsuite.notmuchmail.org \ | notmuch_json_show_sanitize) expected=' {"original": {"body": [{ "content": "this is the sekrit message\n", "content-type": "text/plain", "encstatus": [{"status": "good" }], "id": 1 }], "date_relative": "2000-01-01", "excluded": false, "filename": ["YYYYY"], "headers": { "Date": "Sat, 01 Jan 2000 12:00:00 +0000", "From": "test_suite@notmuchmail.org", "Subject": "inline PGP encrypted message", "To": "test_suite@notmuchmail.org" }, "id": "XXXXX", "match": false, "tags": ["encrypted", "inbox", "unread"], "timestamp": 946728000 }, "reply-headers": { "From": "Notmuch Test Suite ", "In-reply-to": "", "References": "", "Subject": "Re: inline PGP encrypted message" } }' test_expect_equal_json \ "$output" \ "$expected" test_begin_subtest "searching for cleartext of inline PGP encrypted message should fail" output=$(notmuch search 'sekrit') expected='' test_expect_equal "$output" "$expected" test_begin_subtest "reindexing cleartext of inline PGP encrypted message should succeed" test_subtest_broken_gmime_2 notmuch reindex --decrypt=true id:inline-pgp-encrypted@testsuite.notmuchmail.org output=$(notmuch search 'sekrit') expected='thread:0000000000000001 2000-01-01 [1/1] test_suite@notmuchmail.org; inline PGP encrypted message (encrypted inbox unread)' test_expect_equal "$output" "$expected" test_done