2 test_description="output of multipart message"
5 cat <<EOF > ${MAIL_DIR}/multipart
6 From: Carl Worth <cworth@cworth.org>
8 Subject: Multipart message
9 Date: Tue, 05 Jan 2001 15:43:57 -0000
10 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
11 Message-ID: <87liy5ap00.fsf@yoom.home.cworth.org>
13 Content-Type: multipart/signed; boundary="==-=-=";
14 micalg=pgp-sha1; protocol="application/pgp-signature"
17 Content-Type: multipart/mixed; boundary="=-=-="
20 Content-Type: message/rfc822
21 Content-Disposition: inline
23 From: Carl Worth <cworth@cworth.org>
26 Date: Tue, 05 Jan 2001 15:42:57 -0000
27 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
28 Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>
30 Content-Type: text/html
32 <p>This is an embedded message, with a single html part.</p>
35 Content-Disposition: attachment; filename=attachment
37 This is a text attachment.
41 And this message is signed.
48 Content-Type: application/pgp-signature
50 -----BEGIN PGP SIGNATURE-----
51 Version: GnuPG v1.4.11 (GNU/Linux)
53 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
54 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
56 -----END PGP SIGNATURE-----
60 cat <<EOF > ${MAIL_DIR}/base64-part-with-crlf
61 From: Carl Worth <cworth@cworth.org>
63 Subject: Test message with a BASE64 encoded binary containing CRLF pair
64 Date: Tue, 05 Jan 2001 15:43:57 -0000
65 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
66 Message-ID: <base64-part-with-crlf>
68 Content-Type: multipart/mixed; boundary="==-=-=";
72 The attached BASE64-encoded part expands to a binary containing a CRLF
73 pair (that is one bye of 0x0D followed by one byte of 0x0A). This is
74 designed to ensure that notmuch is not corrupting the output of this
75 part by converting the CRLF pair to an LF only (as would be appropriate
76 for display of a text part on a Linux system, for example).
78 The part should be a 3-byte file with the following sequence of 3
84 Content-Type: application/octet-stream
85 Content-Disposition: attachment; filename=crlf.bin
86 Content-Transfer-Encoding: base64
91 increment_mtime "$MAIL_DIR"
92 notmuch new > /dev/null
94 test_begin_subtest "--format=text --part=0, full message"
95 notmuch show --format=text --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
97 \fmessage{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 filename:${MAIL_DIR}/multipart
99 Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox signed unread)
100 Subject: Multipart message
101 From: Carl Worth <cworth@cworth.org>
102 To: cworth@cworth.org
103 Date: Tue, 05 Jan 2001 15:43:57 -0000
106 \fpart{ ID: 1, Content-type: multipart/signed
107 \fpart{ ID: 2, Content-type: multipart/mixed
108 \fpart{ ID: 3, Content-type: message/rfc822
109 \fpart{ ID: 4, Content-type: text/html
110 Non-text part: text/html
113 \fattachment{ ID: 5, Filename: attachment, Content-type: text/plain
114 This is a text attachment.
116 \fpart{ ID: 6, Content-type: text/plain
117 And this message is signed.
122 \fpart{ ID: 7, Content-type: application/pgp-signature
123 Non-text part: application/pgp-signature
129 test_expect_equal_file OUTPUT EXPECTED
131 test_begin_subtest "--format=text --part=0, full message"
132 notmuch show --format=text --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
134 \fmessage{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 filename:${MAIL_DIR}/multipart
136 Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox signed unread)
137 Subject: Multipart message
138 From: Carl Worth <cworth@cworth.org>
139 To: cworth@cworth.org
140 Date: Tue, 05 Jan 2001 15:43:57 -0000
143 \fpart{ ID: 1, Content-type: multipart/signed
144 \fpart{ ID: 2, Content-type: multipart/mixed
145 \fpart{ ID: 3, Content-type: message/rfc822
146 \fpart{ ID: 4, Content-type: text/html
147 Non-text part: text/html
150 \fattachment{ ID: 5, Filename: attachment, Content-type: text/plain
151 This is a text attachment.
153 \fpart{ ID: 6, Content-type: text/plain
154 And this message is signed.
159 \fpart{ ID: 7, Content-type: application/pgp-signature
160 Non-text part: application/pgp-signature
166 test_expect_equal_file OUTPUT EXPECTED
168 test_begin_subtest "--format=text --part=2, multipart/mixed"
169 notmuch show --format=text --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
171 \fpart{ ID: 2, Content-type: multipart/mixed
172 \fpart{ ID: 3, Content-type: message/rfc822
173 \fpart{ ID: 4, Content-type: text/html
174 Non-text part: text/html
177 \fattachment{ ID: 5, Filename: attachment, Content-type: text/plain
178 This is a text attachment.
180 \fpart{ ID: 6, Content-type: text/plain
181 And this message is signed.
187 test_expect_equal_file OUTPUT EXPECTED
189 test_begin_subtest "--format=text --part=3, rfc822 multipart"
190 notmuch show --format=text --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
192 \fpart{ ID: 3, Content-type: message/rfc822
193 \fpart{ ID: 4, Content-type: text/html
194 Non-text part: text/html
198 test_expect_equal_file OUTPUT EXPECTED
200 test_begin_subtest "--format=text --part=4, html part"
201 notmuch show --format=text --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
203 \fpart{ ID: 4, Content-type: text/html
204 Non-text part: text/html
207 test_expect_equal_file OUTPUT EXPECTED
209 test_begin_subtest "--format=text --part=5, inline attachment"
210 notmuch show --format=text --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
212 \fattachment{ ID: 5, Filename: attachment, Content-type: text/plain
213 This is a text attachment.
216 test_expect_equal_file OUTPUT EXPECTED
218 test_begin_subtest "--format=text --part=6, plain text part"
219 notmuch show --format=text --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
221 \fpart{ ID: 6, Content-type: text/plain
222 And this message is signed.
227 test_expect_equal_file OUTPUT EXPECTED
229 test_begin_subtest "--format=text --part=7, pgp signature (unverified)"
230 notmuch show --format=text --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
232 \fpart{ ID: 7, Content-type: application/pgp-signature
233 Non-text part: application/pgp-signature
236 test_expect_equal_file OUTPUT EXPECTED
238 test_expect_success \
239 "--format=text --part=8, no part, expect error" \
240 "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
242 test_begin_subtest "--format=json --part=0, full message"
243 output=$(notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org')
244 test_expect_equal "$output" \
245 '{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "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", "Cc": "", "Bcc": "", "Date": "Tue, 05 Jan 2001 15:43:57 -0000"}, "body": [{"id": 1, "content-type": "multipart/signed", "content": [{"id": 2, "content-type": "multipart/mixed", "content": [{"id": 3, "content-type": "message/rfc822", "content": [{"id": 4, "content-type": "text/html"}]}, {"id": 5, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 6, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, {"id": 7, "content-type": "application/pgp-signature"}]}]}'
247 test_begin_subtest "--format=json --part=1, message body"
248 output=$(notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org')
249 test_expect_equal "$output" \
250 '{"id": 1, "content-type": "multipart/signed", "content": [{"id": 2, "content-type": "multipart/mixed", "content": [{"id": 3, "content-type": "message/rfc822", "content": [{"id": 4, "content-type": "text/html"}]}, {"id": 5, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 6, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, {"id": 7, "content-type": "application/pgp-signature"}]}'
252 test_begin_subtest "--format=json --part=2, multipart/mixed"
253 output=$(notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org')
254 test_expect_equal "$output" \
255 '{"id": 2, "content-type": "multipart/mixed", "content": [{"id": 3, "content-type": "message/rfc822", "content": [{"id": 4, "content-type": "text/html"}]}, {"id": 5, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, {"id": 6, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}'
256 test_expect_equal_file OUTPUT EXPECTED
258 test_begin_subtest "--format=json --part=3, rfc822 multipart"
259 output=$(notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org')
260 test_expect_equal "$output" \
261 '{"id": 3, "content-type": "message/rfc822", "content": [{"id": 4, "content-type": "text/html"}]}'
262 test_expect_equal_file OUTPUT EXPECTED
264 test_begin_subtest "--format=json --part=4, html part"
265 output=$(notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org')
266 test_expect_equal "$output" \
267 '{"id": 4, "content-type": "text/html"}'
269 test_begin_subtest "--format=json --part=5, inline attachment"
270 output=$(notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org')
271 test_expect_equal "$output" \
272 '{"id": 5, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}'
274 test_begin_subtest "--format=json --part=6, plain text part"
275 output=$(notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org')
276 test_expect_equal "$output" \
277 '{"id": 6, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}'
279 test_begin_subtest "--format=json --part=7, pgp signature (unverified)"
280 output=$(notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org')
281 test_expect_equal "$output" \
282 '{"id": 7, "content-type": "application/pgp-signature"}'
284 test_expect_success \
285 "--format=json --part=8, no part, expect error" \
286 "notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
288 test_begin_subtest "--format=raw"
289 notmuch show --format=raw 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
290 test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
292 test_begin_subtest "--format=raw --part=0, full message"
293 notmuch show --format=raw --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
294 test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
296 test_begin_subtest "--format=raw --part=1, message body"
297 notmuch show --format=raw --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
298 # output should *not* include newline
301 <p>This is an embedded message, with a single html part.</p>
302 This is a text attachment.
303 And this message is signed.
306 -----BEGIN PGP SIGNATURE-----
307 Version: GnuPG v1.4.11 (GNU/Linux)
309 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
310 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
312 -----END PGP SIGNATURE-----
314 test_expect_equal_file OUTPUT EXPECTED
316 test_begin_subtest "--format=raw --part=2, multipart/mixed"
317 notmuch show --format=raw --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
319 <p>This is an embedded message, with a single html part.</p>
320 This is a text attachment.
321 And this message is signed.
325 test_expect_equal_file OUTPUT EXPECTED
327 test_begin_subtest "--format=raw --part=3, rfc822 multipart"
328 notmuch show --format=raw --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
330 <p>This is an embedded message, with a single html part.</p>
332 test_expect_equal_file OUTPUT EXPECTED
334 test_begin_subtest "--format=raw --part=4, html part"
335 notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
337 <p>This is an embedded message, with a single html part.</p>
339 test_expect_equal_file OUTPUT EXPECTED
341 test_begin_subtest "--format=raw --part=5, inline attachment"
342 notmuch show --format=raw --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
344 This is a text attachment.
346 test_expect_equal_file OUTPUT EXPECTED
348 test_begin_subtest "--format=raw --part=6, plain text part"
349 notmuch show --format=raw --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
351 And this message is signed.
355 test_expect_equal_file OUTPUT EXPECTED
357 test_begin_subtest "--format=raw --part=7, pgp signature (unverified)"
358 notmuch show --format=raw --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
359 # output should *not* include newline
362 -----BEGIN PGP SIGNATURE-----
363 Version: GnuPG v1.4.11 (GNU/Linux)
365 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
366 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
368 -----END PGP SIGNATURE-----
370 test_expect_equal_file OUTPUT EXPECTED
372 test_expect_success \
373 "--format=raw --part=8, no part, expect error" \
374 "notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
376 test_begin_subtest "--format=mbox"
377 notmuch show --format=mbox 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
378 printf "From cworth@cworth.org Fri Jan 5 15:43:57 2001\n" >EXPECTED
379 cat "${MAIL_DIR}"/multipart >>EXPECTED
380 # mbox output is expected to include a blank line
382 test_expect_equal_file OUTPUT EXPECTED
384 test_expect_success \
385 "--format=mbox --part=1, incompatible, expect error" \
386 "! notmuch show --format=mbox --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
388 test_begin_subtest "'notmuch reply' to a multipart message"
389 notmuch reply 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
391 From: Notmuch Test Suite <test_suite@notmuchmail.org>
392 Subject: Re: Multipart message
393 To: Carl Worth <cworth@cworth.org>, cworth@cworth.org
394 In-Reply-To: <87liy5ap00.fsf@yoom.home.cworth.org>
395 References: <87liy5ap00.fsf@yoom.home.cworth.org>
397 On Tue, 05 Jan 2001 15:43:57 -0000, Carl Worth <cworth@cworth.org> wrote:
398 Non-text part: multipart/signed
399 Non-text part: multipart/mixed
400 Non-text part: message/rfc822
401 Non-text part: text/html
402 > This is a text attachment.
403 > And this message is signed.
406 Non-text part: application/pgp-signature
408 test_expect_equal_file OUTPUT EXPECTED
410 test_begin_subtest "'notmuch show --part' does not corrupt a part with CRLF pair"
411 notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out
412 echo -n -e "\xEF\x0D\x0A" > crlf.expected
413 test_expect_equal_file crlf.out crlf.expected