3 # TODO: test index.decryption=failed
5 test_description='indexing decrypted mail'
6 . $(dirname "$0")/test-lib.sh || exit 1
8 ##################################################
12 FINGERPRINT=$(gpg --no-tty --list-secret-keys --with-colons --fingerprint | grep '^fpr:' | cut -d: -f10)
14 # create a test encrypted message
15 test_begin_subtest 'emacs delivery of encrypted message'
18 "test encrypted message for cleartext index 001" \
19 "This is a test encrypted message with a wumpus.\n" \
20 "(mml-secure-message-encrypt)"'
22 test_begin_subtest "search for unindexed cleartext"
23 output=$(notmuch search wumpus)
29 # create a test encrypted message that is indexed in the clear
30 test_begin_subtest 'emacs delivery of encrypted message'
32 'emacs_fcc_message --try-decrypt=true \
33 "test encrypted message for cleartext index 002" \
34 "This is a test encrypted message with a wumpus.\n" \
35 "(mml-secure-message-encrypt)"'
37 test_begin_subtest "emacs delivery of encrypted message, indexed cleartext"
38 output=$(notmuch search wumpus)
39 expected='thread:0000000000000002 2000-01-01 [1/1] Notmuch Test Suite; test encrypted message for cleartext index 002 (encrypted inbox)'
44 # and the same search, but by property ($expected is untouched):
45 test_begin_subtest "emacs search by property for one message"
46 output=$(notmuch search property:index.decryption=success)
52 test_begin_subtest "message should go away after deletion"
53 # cache the message in an env var and remove it:
54 fname=$(notmuch search --output=files wumpus)
55 contents="$(notmuch show --format=raw wumpus)"
58 output=$(notmuch search wumpus)
64 # try reinserting it without decryption, should stay the same:
65 test_begin_subtest "message cleartext not present after insert"
66 notmuch insert --folder=sent <<<"$contents"
67 output=$(notmuch search wumpus)
72 # try reinserting it with decryption, should appear again, but now we
73 # have two copies of the message:
74 test_begin_subtest "message cleartext is present after reinserting with --try-decrypt"
75 notmuch insert --folder=sent --try-decrypt <<<"$contents"
76 output=$(notmuch search wumpus)
77 expected='thread:0000000000000003 2000-01-01 [1/1(2)] Notmuch Test Suite; test encrypted message for cleartext index 002 (encrypted inbox unread)'
83 test_begin_subtest "delete all copies of the message"
84 mid="$(notmuch search --output=messages wumpus)"
85 rm -f $(notmuch search --output=files wumpus)
87 output=$(notmuch search "id:$mid")
93 # try inserting it with decryption, should appear as a single copy
94 # (note: i think thread id skips 4 because of duplicate message-id
96 test_begin_subtest "message cleartext is present with insert --try-decrypt"
97 notmuch insert --folder=sent --try-decrypt <<<"$contents"
98 output=$(notmuch search wumpus)
99 expected='thread:0000000000000005 2000-01-01 [1/1] Notmuch Test Suite; test encrypted message for cleartext index 002 (encrypted inbox unread)'