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