]> git.notmuchmail.org Git - notmuch/blob - test/T358-emacs-protected-headers.sh
test: sort the output of the "prefix" test in T610-message-property
[notmuch] / test / T358-emacs-protected-headers.sh
1 #!/usr/bin/env bash
2
3 test_description="protected headers in emacs interface"
4 . $(dirname "$0")/test-lib.sh || exit 1
5
6 # testing protected headers with emacs
7 add_gnupg_home
8 add_email_corpus protected-headers
9
10 test_begin_subtest "notmuch-search should show not unindexed protected subject header in emacs"
11 test_emacs '(notmuch-search "id:protected-header@crypto.notmuchmail.org")
12             (notmuch-test-wait)
13             (test-output)'
14 cat <<EOF >EXPECTED
15   2000-01-01 [1/1]   test_suite@notmuchmail.org  Subject Unavailable (encrypted inbox unread)
16 End of search results.
17 EOF
18 test_expect_equal_file EXPECTED OUTPUT
19
20 test_begin_subtest "notmuch-show should not show unindexed protected subject header in emacs when nm-c-process-mime is nil"
21 test_emacs '(let ((notmuch-crypto-process-mime nil))
22              (notmuch-show "id:protected-header@crypto.notmuchmail.org")
23              (test-output))'
24 cat <<EOF >EXPECTED
25 test_suite@notmuchmail.org (2000-01-01) (encrypted inbox)
26 Subject: Subject Unavailable
27 To: test_suite@notmuchmail.org
28 Date: Sat, 01 Jan 2000 12:00:00 +0000
29
30 [ multipart/encrypted ]
31 [ Unknown encryption status ]
32 [ application/pgp-encrypted ]
33 [ application/octet-stream ]
34 EOF
35 test_expect_equal_file EXPECTED OUTPUT
36
37 test_begin_subtest "notmuch-show should show protected subject header in emacs"
38 test_emacs '(notmuch-show "id:protected-header@crypto.notmuchmail.org")
39             (test-output)'
40 cat <<EOF >EXPECTED
41 test_suite@notmuchmail.org (2000-01-01) (encrypted inbox)
42 Subject: This is a protected header
43 To: test_suite@notmuchmail.org
44 Date: Sat, 01 Jan 2000 12:00:00 +0000
45
46 [ multipart/encrypted ]
47 [ Decryption successful ]
48 [ application/pgp-encrypted ]
49 [ text/plain ]
50 This is the sekrit message
51 EOF
52 test_expect_equal_file EXPECTED OUTPUT
53
54 # notmuch-emacs still leaks the subject line; as long as it leaks the
55 # subject line, it should emit the external subject, not the protected
56 # subject, even if it knows what the true subject is:
57 test_begin_subtest "Reply within emacs to a message with protected headers, not leaking subject"
58 test_emacs "(let ((message-hidden-headers '()))
59             (notmuch-show \"id:protected-header@crypto.notmuchmail.org\")
60             (notmuch-show-reply)
61             (test-output))"
62 cat <<EOF >EXPECTED
63 From: Notmuch Test Suite <test_suite@notmuchmail.org>
64 To: test_suite@notmuchmail.org
65 Subject: Re: Subject Unavailable
66 In-Reply-To: <protected-header@crypto.notmuchmail.org>
67 Fcc: ${MAIL_DIR}/sent
68 References: <protected-header@crypto.notmuchmail.org>
69 --text follows this line--
70 <#secure method=pgpmime mode=signencrypt>
71 test_suite@notmuchmail.org writes:
72
73 > This is the sekrit message
74 EOF
75 test_expect_equal_file EXPECTED OUTPUT
76
77 # protected headers should behave differently after re-indexing
78 test_begin_subtest 'defaulting to indexing cleartext'
79 test_expect_success 'notmuch config set index.decrypt true'
80 test_begin_subtest 'try reindexing protected header message'
81 test_expect_success 'notmuch reindex id:protected-header@crypto.notmuchmail.org'
82
83 test_begin_subtest "notmuch-search should show indexed protected subject header in emacs"
84 test_emacs '(notmuch-search "id:protected-header@crypto.notmuchmail.org")
85             (notmuch-test-wait)
86             (test-output)'
87 cat <<EOF >EXPECTED
88   2000-01-01 [1/1]   test_suite@notmuchmail.org  This is a protected header (encrypted inbox)
89 End of search results.
90 EOF
91 test_expect_equal_file EXPECTED OUTPUT
92
93 # notmuch-emacs still leaks the subject line:
94 test_begin_subtest "don't leak protected subject during reply, even if indexed"
95 test_emacs "(let ((message-hidden-headers '()))
96             (notmuch-show \"id:protected-header@crypto.notmuchmail.org\")
97             (notmuch-show-reply)
98             (test-output))"
99 cat <<EOF >EXPECTED
100 From: Notmuch Test Suite <test_suite@notmuchmail.org>
101 To: test_suite@notmuchmail.org
102 Subject: Re: Subject Unavailable
103 In-Reply-To: <protected-header@crypto.notmuchmail.org>
104 Fcc: ${MAIL_DIR}/sent
105 References: <protected-header@crypto.notmuchmail.org>
106 --text follows this line--
107 <#secure method=pgpmime mode=signencrypt>
108 test_suite@notmuchmail.org writes:
109
110 > This is the sekrit message
111 EOF
112 test_expect_equal_file EXPECTED OUTPUT
113
114 test_done