]> git.notmuchmail.org Git - notmuch/blob - test/T450-emacs-show.sh
smime: Index cleartext of envelopedData when requested
[notmuch] / test / T450-emacs-show.sh
1 #!/usr/bin/env bash
2
3 test_description="emacs notmuch-show view"
4 . $(dirname "$0")/test-lib.sh || exit 1
5
6 EXPECTED=$NOTMUCH_SRCDIR/test/emacs-show.expected-output
7
8 add_email_corpus
9
10 test_begin_subtest "Hiding Original Message region at beginning of a message"
11 message_id='OriginalMessageHiding.1@notmuchmail.org'
12 add_message \
13     [id]="$message_id" \
14     '[subject]="Hiding Original Message region at beginning of a message"' \
15     '[body]="-----Original Message-----
16 Text here."'
17
18 cat <<EOF >EXPECTED
19 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
20 Subject: Hiding Original Message region at beginning of a message
21 To: Notmuch Test Suite <test_suite@notmuchmail.org>
22 Date: GENERATED_DATE
23
24 [ 2-line hidden original message. Click/Enter to show. ]
25 EOF
26
27 test_emacs "(notmuch-show \"id:$message_id\")
28             (test-visible-output \"OUTPUT.raw\")"
29 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
30 test_expect_equal_file EXPECTED OUTPUT
31
32 test_begin_subtest "Bare subject #1"
33 output=$(test_emacs '(notmuch-show-strip-re "Re: subject")')
34 test_expect_equal "$output" '"subject"'
35
36 test_begin_subtest "Bare subject #2"
37 output=$(test_emacs '(notmuch-show-strip-re "re:Re: re:  Re:  re:subject")')
38 test_expect_equal "$output" '"subject"'
39
40 test_begin_subtest "Bare subject #3"
41 output=$(test_emacs '(notmuch-show-strip-re "the cure: fix the regexp")')
42 test_expect_equal "$output" '"the cure: fix the regexp"'
43
44 test_begin_subtest "don't process cryptographic MIME parts"
45 test_emacs '(let ((notmuch-crypto-process-mime nil))
46         (notmuch-show "id:20091117203301.GV3165@dottiness.seas.harvard.edu")
47         (test-visible-output))'
48 test_expect_equal_file $EXPECTED/notmuch-show-process-crypto-mime-parts-off OUTPUT
49
50 test_begin_subtest "process cryptographic MIME parts"
51 test_emacs '(let ((notmuch-crypto-process-mime t))
52         (notmuch-show "id:20091117203301.GV3165@dottiness.seas.harvard.edu")
53         (test-visible-output))'
54 test_expect_equal_file $EXPECTED/notmuch-show-process-crypto-mime-parts-on OUTPUT
55
56 test_begin_subtest "process cryptographic MIME parts (w/ notmuch-show-toggle-process-crypto)"
57 test_emacs '(let ((notmuch-crypto-process-mime nil))
58         (notmuch-show "id:20091117203301.GV3165@dottiness.seas.harvard.edu")
59         (notmuch-show-toggle-process-crypto)
60         (test-visible-output))'
61 test_expect_equal_file $EXPECTED/notmuch-show-process-crypto-mime-parts-on OUTPUT
62
63 test_begin_subtest "notmuch-show: don't elide non-matching messages"
64 test_emacs '(let ((notmuch-show-only-matching-messages nil))
65         (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
66         (notmuch-test-wait)
67         (notmuch-search-show-thread)
68         (notmuch-test-wait)
69         (test-visible-output))'
70 test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-off OUTPUT
71
72 test_begin_subtest "notmuch-show: elide non-matching messages"
73 test_emacs '(let ((notmuch-show-only-matching-messages t))
74         (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
75         (notmuch-test-wait)
76         (notmuch-search-show-thread)
77         (notmuch-test-wait)
78         (test-visible-output))'
79 test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-on OUTPUT
80
81 test_begin_subtest "notmuch-show: elide non-matching messages (w/ notmuch-show-toggle-elide-non-matching)"
82 test_emacs '(let ((notmuch-show-only-matching-messages nil))
83         (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
84         (notmuch-test-wait)
85         (notmuch-search-show-thread)
86         (notmuch-test-wait)
87         (notmuch-show-toggle-elide-non-matching)
88         (test-visible-output))'
89 test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-on OUTPUT
90
91 test_begin_subtest "notmuch-show: elide non-matching messages (w/ prefix arg to notmuch-show)"
92 test_emacs '(let ((notmuch-show-only-matching-messages nil))
93         (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
94         (notmuch-test-wait)
95         (notmuch-search-show-thread t)
96         (notmuch-test-wait)
97         (test-visible-output))'
98 test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-on OUTPUT
99
100 test_begin_subtest "notmuch-show: disable indentation of thread content (w/ notmuch-show-toggle-thread-indentation)"
101 test_emacs '(notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
102         (notmuch-test-wait)
103         (notmuch-search-show-thread)
104         (notmuch-test-wait)
105         (notmuch-show-toggle-thread-indentation)
106         (test-visible-output)'
107 test_expect_equal_file $EXPECTED/notmuch-show-indent-thread-content-off OUTPUT
108
109 test_begin_subtest "id buttonization"
110 add_message '[body]="
111 id:abc
112 id:abc.def. id:abc,def, id:abc;def; id:abc:def:
113 id:foo@bar.?baz? id:foo@bar!.baz!
114 (id:foo@bar.baz) [id:foo@bar.baz]
115 id:foo@bar.baz...
116 id:2+2=5
117 id:=_-:/.[]@$%+
118 id:abc)def
119 id:ab\"c def
120 id:\"abc\"def
121 id:\"ab\"\"c\"def
122 id:\"ab c\"def
123 id:\"abc\".def
124 id:\"abc
125 \"
126 id:)
127 id:
128 cid:xxx
129 mid:abc mid:abc/def
130 mid:abc%20def
131 mid:abc. mid:abc, mid:abc;"'
132 test_emacs '(notmuch-show "id:'$gen_msg_id'")
133         (notmuch-test-mark-links)
134         (test-visible-output "OUTPUT.raw")'
135 cat <<EOF >EXPECTED
136 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
137 Subject: id buttonization
138 To: Notmuch Test Suite <test_suite@notmuchmail.org>
139 Date: GENERATED_DATE
140
141 <<id:abc>>
142 <<id:abc.def>>. <<id:abc,def>>, <<id:abc;def>>; <<id:abc:def>>:
143 <<id:foo@bar.?baz>>? <<id:foo@bar!.baz>>!
144 (<<id:foo@bar.baz>>) [<<id:foo@bar.baz>>]
145 <<id:foo@bar.baz>>...
146 <<id:2+2=5>>
147 <<id:=_-:/.[]@$%+>>
148 <<id:abc>>)def
149 <<id:ab"c>> def
150 <<id:"abc">>def
151 <<id:"ab""c">>def
152 <<id:"ab c">>def
153 <<id:"abc">>.def
154 id:"abc
155 "
156 id:)
157 id:
158 cid:xxx
159 <<mid:abc>> <<mid:abc/def>>
160 <<mid:abc%20def>>
161 <<mid:abc>>. <<mid:abc>>, <<mid:abc>>;
162 EOF
163 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
164 test_expect_equal_file EXPECTED OUTPUT
165
166
167 test_begin_subtest "Show handles subprocess errors"
168 cat > notmuch_fail <<EOF
169 #!/bin/sh
170 echo This is output
171 echo This is an error >&2
172 exit 1
173 EOF
174 chmod a+x notmuch_fail
175 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
176                (with-current-buffer \"*Messages*\"
177                   (let ((inhibit-read-only t)) (erase-buffer)))
178                (condition-case err
179                    (notmuch-show \"*\")
180                  (error (message \"%s\" (cadr err))))
181                (notmuch-test-wait)
182                (with-current-buffer \"*Messages*\"
183                   (test-output \"MESSAGES\"))
184                (with-current-buffer \"*Notmuch errors*\"
185                   (test-output \"ERROR\"))
186                (test-output))"
187 test_expect_equal "$(notmuch_emacs_error_sanitize notmuch_fail OUTPUT MESSAGES ERROR)" "\
188 === OUTPUT ===
189 === MESSAGES ===
190 This is an error (see *Notmuch errors* for more details)
191 === ERROR ===
192 [XXX]
193 This is an error
194 command: YYY/notmuch_fail show --format\\=sexp --format-version\\=4 --decrypt\\=true --exclude\\=false \\' \\* \\'
195 exit status: 1
196 stderr:
197 This is an error
198 stdout:
199 This is output"
200
201 test_begin_subtest "text/enriched exploit mitigation"
202 add_message '[content-type]="text/enriched"
203              [body]="
204 <x-display><param>(when (progn (read-only-mode -1) (insert ?p ?0 ?w ?n ?e ?d)) nil)</param>test</x-display>
205 "'
206 test_emacs '(notmuch-show "id:'$gen_msg_id'")
207         (test-visible-output "OUTPUT.raw")'
208 output=$(head -1 OUTPUT.raw|cut -f1-4 -d' ')
209 test_expect_equal "$output" "Notmuch Test Suite <test_suite@notmuchmail.org>"
210
211
212 # switching to the crypto corpus, using gpg from here on:
213 add_gnupg_home
214 add_email_corpus crypto
215
216 test_begin_subtest "show decrypted message"
217 test_emacs '(notmuch-show "id:basic-encrypted@crypto.notmuchmail.org")
218             (test-visible-output)'
219 test_expect_equal_file $EXPECTED/notmuch-show-decrypted-message OUTPUT
220
221 test_begin_subtest "show undecryptable message"
222 test_emacs '(notmuch-show "id:simple-encrypted@crypto.notmuchmail.org")
223             (test-visible-output)'
224 test_expect_equal_file $EXPECTED/notmuch-show-undecryptable-message OUTPUT
225
226 test_begin_subtest "show encrypted message when not processing crypto"
227 test_emacs '(let ((notmuch-crypto-process-mime nil))
228              (notmuch-show "id:basic-encrypted@crypto.notmuchmail.org")
229              (test-visible-output))'
230 test_expect_equal_file $EXPECTED/notmuch-show-decrypted-message-no-crypto OUTPUT
231
232 test_done