]> git.cworth.org Git - obsolete/notmuch-old/blob - test/multipart
test: Produce useful output when the HTML with images test fails
[obsolete/notmuch-old] / test / multipart
1 #!/usr/bin/env bash
2 test_description="output of multipart message"
3 . ./test-lib.sh
4
5 cat <<EOF > embedded_message
6 From: Carl Worth <cworth@cworth.org>
7 To: cworth@cworth.org
8 Subject: html message
9 Date: Fri, 05 Jan 2001 15:42:57 +0000
10 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
11 Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>
12 MIME-Version: 1.0
13 Content-Type: multipart/alternative; boundary="==-=-=="
14
15 --==-=-==
16 Content-Type: text/html
17
18 <p>This is an embedded message, with a multipart/alternative part.</p>
19
20 --==-=-==
21 Content-Type: text/plain
22
23 This is an embedded message, with a multipart/alternative part.
24
25 --==-=-==--
26 EOF
27
28 cat <<EOF > ${MAIL_DIR}/multipart
29 From: Carl Worth <cworth@cworth.org>
30 To: cworth@cworth.org
31 Subject: Multipart message
32 Date: Fri, 05 Jan 2001 15:43:57 +0000
33 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
34 Message-ID: <87liy5ap00.fsf@yoom.home.cworth.org>
35 MIME-Version: 1.0
36 Content-Type: multipart/signed; boundary="==-=-=";
37         micalg=pgp-sha1; protocol="application/pgp-signature"
38
39 --==-=-=
40 Content-Type: multipart/mixed; boundary="=-=-="
41
42 --=-=-=
43 Content-Type: message/rfc822
44 Content-Disposition: inline
45
46 EOF
47 cat embedded_message >> ${MAIL_DIR}/multipart
48 cat <<EOF >> ${MAIL_DIR}/multipart
49
50 --=-=-=
51 Content-Disposition: attachment; filename=attachment
52
53 This is a text attachment.
54
55 --=-=-=
56
57 And this message is signed.
58
59 -Carl
60
61 --=-=-=--
62
63 --==-=-=
64 Content-Type: application/pgp-signature
65
66 -----BEGIN PGP SIGNATURE-----
67 Version: GnuPG v1.4.11 (GNU/Linux)
68
69 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
70 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
71 =zkga
72 -----END PGP SIGNATURE-----
73 --==-=-=--
74 EOF
75
76 cat <<EOF > ${MAIL_DIR}/base64-part-with-crlf
77 From: Carl Worth <cworth@cworth.org>
78 To: cworth@cworth.org
79 Subject: Test message with a BASE64 encoded binary containing CRLF pair
80 Date: Fri, 05 Jan 2001 15:43:57 +0000
81 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
82 Message-ID: <base64-part-with-crlf>
83 MIME-Version: 1.0
84 Content-Type: multipart/mixed; boundary="==-=-=";
85
86 --==-=-=
87
88 The attached BASE64-encoded part expands to a binary containing a CRLF
89 pair (that is one bye of 0x0D followed by one byte of 0x0A). This is
90 designed to ensure that notmuch is not corrupting the output of this
91 part by converting the CRLF pair to an LF only (as would be appropriate
92 for display of a text part on a Linux system, for example).
93
94 The part should be a 3-byte file with the following sequence of 3
95 hexadecimal bytes:
96
97         EF 0D 0A
98
99 --==-=-=
100 Content-Type: application/octet-stream
101 Content-Disposition: attachment; filename=crlf.bin
102 Content-Transfer-Encoding: base64
103
104 7w0K
105 --==-=-=--
106 EOF
107 notmuch new > /dev/null
108
109 test_begin_subtest "--format=text --part=0, full message"
110 notmuch show --format=text --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
111 cat <<EOF >EXPECTED
112 \fmessage{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 excluded:0 filename:${MAIL_DIR}/multipart
113 \fheader{
114 Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox signed unread)
115 Subject: Multipart message
116 From: Carl Worth <cworth@cworth.org>
117 To: cworth@cworth.org
118 Date: Fri, 05 Jan 2001 15:43:57 +0000
119 \fheader}
120 \fbody{
121 \fpart{ ID: 1, Content-type: multipart/signed
122 \fpart{ ID: 2, Content-type: multipart/mixed
123 \fpart{ ID: 3, Content-type: message/rfc822
124 \fheader{
125 Subject: html message
126 From: Carl Worth <cworth@cworth.org>
127 To: cworth@cworth.org
128 Date: Fri, 05 Jan 2001 15:42:57 +0000
129 \fheader}
130 \fbody{
131 \fpart{ ID: 4, Content-type: multipart/alternative
132 \fpart{ ID: 5, Content-type: text/html
133 Non-text part: text/html
134 \fpart}
135 \fpart{ ID: 6, Content-type: text/plain
136 This is an embedded message, with a multipart/alternative part.
137 \fpart}
138 \fpart}
139 \fbody}
140 \fpart}
141 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
142 This is a text attachment.
143 \fattachment}
144 \fpart{ ID: 8, Content-type: text/plain
145 And this message is signed.
146
147 -Carl
148 \fpart}
149 \fpart}
150 \fpart{ ID: 9, Content-type: application/pgp-signature
151 Non-text part: application/pgp-signature
152 \fpart}
153 \fpart}
154 \fbody}
155 \fmessage}
156 EOF
157 test_expect_equal_file OUTPUT EXPECTED
158
159 test_begin_subtest "--format=text --part=1, message body"
160 notmuch show --format=text --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
161 cat <<EOF >EXPECTED
162 \fpart{ ID: 1, Content-type: multipart/signed
163 \fpart{ ID: 2, Content-type: multipart/mixed
164 \fpart{ ID: 3, Content-type: message/rfc822
165 \fheader{
166 Subject: html message
167 From: Carl Worth <cworth@cworth.org>
168 To: cworth@cworth.org
169 Date: Fri, 05 Jan 2001 15:42:57 +0000
170 \fheader}
171 \fbody{
172 \fpart{ ID: 4, Content-type: multipart/alternative
173 \fpart{ ID: 5, Content-type: text/html
174 Non-text part: text/html
175 \fpart}
176 \fpart{ ID: 6, Content-type: text/plain
177 This is an embedded message, with a multipart/alternative part.
178 \fpart}
179 \fpart}
180 \fbody}
181 \fpart}
182 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
183 This is a text attachment.
184 \fattachment}
185 \fpart{ ID: 8, Content-type: text/plain
186 And this message is signed.
187
188 -Carl
189 \fpart}
190 \fpart}
191 \fpart{ ID: 9, Content-type: application/pgp-signature
192 Non-text part: application/pgp-signature
193 \fpart}
194 \fpart}
195 EOF
196 test_expect_equal_file OUTPUT EXPECTED
197
198 test_begin_subtest "--format=text --part=2, multipart/mixed"
199 notmuch show --format=text --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
200 cat <<EOF >EXPECTED
201 \fpart{ ID: 2, Content-type: multipart/mixed
202 \fpart{ ID: 3, Content-type: message/rfc822
203 \fheader{
204 Subject: html message
205 From: Carl Worth <cworth@cworth.org>
206 To: cworth@cworth.org
207 Date: Fri, 05 Jan 2001 15:42:57 +0000
208 \fheader}
209 \fbody{
210 \fpart{ ID: 4, Content-type: multipart/alternative
211 \fpart{ ID: 5, Content-type: text/html
212 Non-text part: text/html
213 \fpart}
214 \fpart{ ID: 6, Content-type: text/plain
215 This is an embedded message, with a multipart/alternative part.
216 \fpart}
217 \fpart}
218 \fbody}
219 \fpart}
220 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
221 This is a text attachment.
222 \fattachment}
223 \fpart{ ID: 8, Content-type: text/plain
224 And this message is signed.
225
226 -Carl
227 \fpart}
228 \fpart}
229 EOF
230 test_expect_equal_file OUTPUT EXPECTED
231
232 test_begin_subtest "--format=text --part=3, rfc822 part"
233 notmuch show --format=text --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
234 cat <<EOF >EXPECTED
235 \fpart{ ID: 3, Content-type: message/rfc822
236 \fheader{
237 Subject: html message
238 From: Carl Worth <cworth@cworth.org>
239 To: cworth@cworth.org
240 Date: Fri, 05 Jan 2001 15:42:57 +0000
241 \fheader}
242 \fbody{
243 \fpart{ ID: 4, Content-type: multipart/alternative
244 \fpart{ ID: 5, Content-type: text/html
245 Non-text part: text/html
246 \fpart}
247 \fpart{ ID: 6, Content-type: text/plain
248 This is an embedded message, with a multipart/alternative part.
249 \fpart}
250 \fpart}
251 \fbody}
252 \fpart}
253 EOF
254 test_expect_equal_file OUTPUT EXPECTED
255
256 test_begin_subtest "--format=text --part=4, rfc822's multipart"
257 notmuch show --format=text --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
258 cat <<EOF >EXPECTED
259 \fpart{ ID: 4, Content-type: multipart/alternative
260 \fpart{ ID: 5, Content-type: text/html
261 Non-text part: text/html
262 \fpart}
263 \fpart{ ID: 6, Content-type: text/plain
264 This is an embedded message, with a multipart/alternative part.
265 \fpart}
266 \fpart}
267 EOF
268 test_expect_equal_file OUTPUT EXPECTED
269
270 test_begin_subtest "--format=text --part=5, rfc822's html part"
271 notmuch show --format=text --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
272 cat <<EOF >EXPECTED
273 \fpart{ ID: 5, Content-type: text/html
274 Non-text part: text/html
275 \fpart}
276 EOF
277 test_expect_equal_file OUTPUT EXPECTED
278
279 test_begin_subtest "--format=text --part=6, rfc822's text part"
280 notmuch show --format=text --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
281 cat <<EOF >EXPECTED
282 \fpart{ ID: 6, Content-type: text/plain
283 This is an embedded message, with a multipart/alternative part.
284 \fpart}
285 EOF
286 test_expect_equal_file OUTPUT EXPECTED
287
288 test_begin_subtest "--format=text --part=7, inline attachement"
289 notmuch show --format=text --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
290 cat <<EOF >EXPECTED
291 \fattachment{ ID: 7, Filename: attachment, Content-type: text/plain
292 This is a text attachment.
293 \fattachment}
294 EOF
295 test_expect_equal_file OUTPUT EXPECTED
296
297 test_begin_subtest "--format=text --part=8, plain text part"
298 notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
299 cat <<EOF >EXPECTED
300 \fpart{ ID: 8, Content-type: text/plain
301 And this message is signed.
302
303 -Carl
304 \fpart}
305 EOF
306 test_expect_equal_file OUTPUT EXPECTED
307
308 test_begin_subtest "--format=text --part=9, pgp signature (unverified)"
309 notmuch show --format=text --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
310 cat <<EOF >EXPECTED
311 \fpart{ ID: 9, Content-type: application/pgp-signature
312 Non-text part: application/pgp-signature
313 \fpart}
314 EOF
315 test_expect_equal_file OUTPUT EXPECTED
316
317 test_expect_success \
318     "--format=text --part=8, no part, expect error" \
319     "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
320
321 test_begin_subtest "--format=json --part=0, full message"
322 notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
323 cat <<EOF >EXPECTED
324 {"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "excluded": false, "filename": "${MAIL_DIR}/multipart", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","signed","unread"], "headers": {"Subject": "Multipart message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [
325 {"id": 1, "content-type": "multipart/signed", "content": [
326 {"id": 2, "content-type": "multipart/mixed", "content": [
327 {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
328 {"id": 4, "content-type": "multipart/alternative", "content": [
329 {"id": 5, "content-type": "text/html"}, 
330 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, 
331 {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, 
332 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, 
333 {"id": 9, "content-type": "application/pgp-signature"}]}]}
334 EOF
335 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
336
337 test_begin_subtest "--format=json --part=1, message body"
338 notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
339 cat <<EOF >EXPECTED
340 {"id": 1, "content-type": "multipart/signed", "content": [
341 {"id": 2, "content-type": "multipart/mixed", "content": [
342 {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
343 {"id": 4, "content-type": "multipart/alternative", "content": [
344 {"id": 5, "content-type": "text/html"}, 
345 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, 
346 {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, 
347 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, 
348 {"id": 9, "content-type": "application/pgp-signature"}]}
349 EOF
350 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
351
352 test_begin_subtest "--format=json --part=2, multipart/mixed"
353 notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
354 cat <<EOF >EXPECTED
355 {"id": 2, "content-type": "multipart/mixed", "content": [
356 {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
357 {"id": 4, "content-type": "multipart/alternative", "content": [
358 {"id": 5, "content-type": "text/html"}, 
359 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, 
360 {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, 
361 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}
362 EOF
363 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
364
365 test_begin_subtest "--format=json --part=3, rfc822 part"
366 notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
367 cat <<EOF >EXPECTED
368 {"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"Subject": "html message", "From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [
369 {"id": 4, "content-type": "multipart/alternative", "content": [
370 {"id": 5, "content-type": "text/html"}, 
371 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}
372 EOF
373 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
374
375 test_begin_subtest "--format=json --part=4, rfc822's multipart/alternative"
376 notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
377 cat <<EOF >EXPECTED
378 {"id": 4, "content-type": "multipart/alternative", "content": [
379 {"id": 5, "content-type": "text/html"}, 
380 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}
381 EOF
382 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
383
384 test_begin_subtest "--format=json --part=5, rfc822's html part"
385 notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
386 cat <<EOF >EXPECTED
387 {"id": 5, "content-type": "text/html"}
388 EOF
389 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
390
391 test_begin_subtest "--format=json --part=6, rfc822's text part"
392 notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
393 cat <<EOF >EXPECTED
394 {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}
395 EOF
396 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
397
398 test_begin_subtest "--format=json --part=7, inline attachment"
399 notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
400 cat <<EOF >EXPECTED
401 {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}
402 EOF
403 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
404
405 test_begin_subtest "--format=json --part=8, plain text part"
406 notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
407 cat <<EOF >EXPECTED
408 {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}
409 EOF
410 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
411
412 test_begin_subtest "--format=json --part=9, pgp signature (unverified)"
413 notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
414 cat <<EOF >EXPECTED
415 {"id": 9, "content-type": "application/pgp-signature"}
416 EOF
417 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
418
419 test_expect_success \
420     "--format=json --part=10, no part, expect error" \
421     "notmuch show --format=json --part=10 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
422
423 test_begin_subtest "--format=raw"
424 notmuch show --format=raw 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
425 test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
426
427 test_begin_subtest "--format=raw --part=0, full message"
428 notmuch show --format=raw --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
429 test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
430
431 test_begin_subtest "--format=raw --part=1, message body"
432 notmuch show --format=raw --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
433 test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
434
435 test_begin_subtest "--format=raw --part=2, multipart/mixed"
436 notmuch show --format=raw --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
437 cat <<EOF >EXPECTED
438 Content-Type: multipart/mixed; boundary="=-=-="
439
440 --=-=-=
441 Content-Type: message/rfc822
442 Content-Disposition: inline
443
444 From: Carl Worth <cworth@cworth.org>
445 To: cworth@cworth.org
446 Subject: html message
447 Date: Fri, 05 Jan 2001 15:42:57 +0000
448 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
449 Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>
450 MIME-Version: 1.0
451 Content-Type: multipart/alternative; boundary="==-=-=="
452
453 --==-=-==
454 Content-Type: text/html
455
456 <p>This is an embedded message, with a multipart/alternative part.</p>
457
458 --==-=-==
459 Content-Type: text/plain
460
461 This is an embedded message, with a multipart/alternative part.
462
463 --==-=-==--
464
465 --=-=-=
466 Content-Disposition: attachment; filename=attachment
467
468 This is a text attachment.
469
470 --=-=-=
471
472 And this message is signed.
473
474 -Carl
475
476 --=-=-=--
477 EOF
478 test_expect_equal_file OUTPUT EXPECTED
479
480 test_begin_subtest "--format=raw --part=3, rfc822 part"
481 notmuch show --format=raw --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
482 test_expect_equal_file OUTPUT embedded_message
483
484 test_begin_subtest "--format=raw --part=4, rfc822's multipart"
485 notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
486 cat <<EOF >EXPECTED
487 From: Carl Worth <cworth@cworth.org>
488 To: cworth@cworth.org
489 Subject: html message
490 Date: Fri, 05 Jan 2001 15:42:57 +0000
491 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
492 Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>
493 MIME-Version: 1.0
494 Content-Type: multipart/alternative; boundary="==-=-=="
495
496 --==-=-==
497 Content-Type: text/html
498
499 <p>This is an embedded message, with a multipart/alternative part.</p>
500
501 --==-=-==
502 Content-Type: text/plain
503
504 This is an embedded message, with a multipart/alternative part.
505
506 --==-=-==--
507 EOF
508 test_expect_equal_file OUTPUT EXPECTED
509
510 test_begin_subtest "--format=raw --part=5, rfc822's html part"
511 notmuch show --format=raw --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
512 cat <<EOF >EXPECTED
513 <p>This is an embedded message, with a multipart/alternative part.</p>
514 EOF
515 test_expect_equal_file OUTPUT EXPECTED
516
517 test_begin_subtest "--format=raw --part=6, rfc822's text part"
518 notmuch show --format=raw --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
519 cat <<EOF >EXPECTED
520 This is an embedded message, with a multipart/alternative part.
521 EOF
522 test_expect_equal_file OUTPUT EXPECTED
523
524 test_begin_subtest "--format=raw --part=7, inline attachment"
525 notmuch show --format=raw --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
526 cat <<EOF >EXPECTED
527 This is a text attachment.
528 EOF
529 test_expect_equal_file OUTPUT EXPECTED
530
531 test_begin_subtest "--format=raw --part=8, plain text part"
532 notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
533 cat <<EOF >EXPECTED
534 And this message is signed.
535
536 -Carl
537 EOF
538 test_expect_equal_file OUTPUT EXPECTED
539
540 test_begin_subtest "--format=raw --part=9, pgp signature (unverified)"
541 notmuch show --format=raw --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
542 # output should *not* include newline
543 echo >>OUTPUT
544 cat <<EOF >EXPECTED
545 -----BEGIN PGP SIGNATURE-----
546 Version: GnuPG v1.4.11 (GNU/Linux)
547
548 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
549 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
550 =zkga
551 -----END PGP SIGNATURE-----
552 EOF
553 test_expect_equal_file OUTPUT EXPECTED
554
555 test_expect_success \
556     "--format=raw --part=10, no part, expect error" \
557     "notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
558
559 test_begin_subtest "--format=mbox"
560 notmuch show --format=mbox 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
561 printf "From cworth@cworth.org Fri Jan  5 15:43:57 2001\n" >EXPECTED
562 cat "${MAIL_DIR}"/multipart >>EXPECTED
563 # mbox output is expected to include a blank line
564 echo >>EXPECTED
565 test_expect_equal_file OUTPUT EXPECTED
566
567 test_expect_success \
568     "--format=mbox --part=1, incompatible, expect error" \
569     "! notmuch show --format=mbox --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
570
571 test_begin_subtest "'notmuch reply' to a multipart message"
572 notmuch reply 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
573 cat <<EOF >EXPECTED
574 From: Notmuch Test Suite <test_suite@notmuchmail.org>
575 Subject: Re: Multipart message
576 To: Carl Worth <cworth@cworth.org>, cworth@cworth.org
577 In-Reply-To: <87liy5ap00.fsf@yoom.home.cworth.org>
578 References: <87liy5ap00.fsf@yoom.home.cworth.org>
579
580 On Fri, 05 Jan 2001 15:43:57 +0000, Carl Worth <cworth@cworth.org> wrote:
581 > From: Carl Worth <cworth@cworth.org>
582 > To: cworth@cworth.org
583 > Subject: html message
584 > Date: Fri, 05 Jan 2001 15:42:57 +0000
585 >
586 Non-text part: text/html
587 > This is an embedded message, with a multipart/alternative part.
588 > This is a text attachment.
589 > And this message is signed.
590
591 > -Carl
592 EOF
593 test_expect_equal_file OUTPUT EXPECTED
594
595 test_begin_subtest "'notmuch reply' to a multipart message with json format"
596 notmuch reply --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org' | notmuch_json_show_sanitize >OUTPUT
597 cat <<EOF >EXPECTED
598 {"reply-headers": {"Subject": "Re: Multipart message",
599  "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
600  "To": "Carl Worth <cworth@cworth.org>, cworth@cworth.org",
601  "In-reply-to": "<87liy5ap00.fsf@yoom.home.cworth.org>",
602  "References": " <87liy5ap00.fsf@yoom.home.cworth.org>"},
603  "original": {"id": "XXXXX",
604  "match": false,
605  "excluded": false,
606  "filename": "YYYYY",
607  "timestamp": 978709437,
608  "date_relative": "2001-01-05",
609  "tags": ["attachment","inbox","signed","unread"],
610  "headers": {"Subject": "Multipart message",
611  "From": "Carl Worth <cworth@cworth.org>",
612  "To": "cworth@cworth.org",
613  "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
614  "body": [{"id": 1,
615  "content-type": "multipart/signed",
616  "content": [{"id": 2,
617  "content-type": "multipart/mixed",
618  "content": [{"id": 3,
619  "content-type": "message/rfc822",
620  "content": [{"headers": {"Subject": "html message",
621  "From": "Carl Worth <cworth@cworth.org>",
622  "To": "cworth@cworth.org",
623  "Date": "Fri, 05 Jan 2001 15:42:57 +0000"},
624  "body": [{"id": 4,
625  "content-type": "multipart/alternative",
626  "content": [{"id": 5,
627  "content-type": "text/html"},
628  {"id": 6,
629  "content-type": "text/plain",
630  "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
631  {"id": 7,
632  "content-type": "text/plain",
633  "filename": "YYYYY",
634  "content": "This is a text attachment.\n"},
635  {"id": 8,
636  "content-type": "text/plain",
637  "content": "And this message is signed.\n\n-Carl\n"}]},
638  {"id": 9,
639  "content-type": "application/pgp-signature"}]}]}}
640 EOF
641 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
642
643 test_begin_subtest "'notmuch show --part' does not corrupt a part with CRLF pair"
644 notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out
645 echo -n -e "\xEF\x0D\x0A" > crlf.expected
646 test_expect_equal_file crlf.out crlf.expected
647
648 test_done