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 notmuch new > /dev/null
93 test_begin_subtest "--format=text --part=0, full message"
94 notmuch show --format=text --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
96 \fmessage{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 filename:${MAIL_DIR}/multipart
98 Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox signed unread)
99 Subject: Multipart message
100 From: Carl Worth <cworth@cworth.org>
101 To: cworth@cworth.org
102 Date: Tue, 05 Jan 2001 15:43:57 -0000
105 \fpart{ ID: 1, Content-type: multipart/signed
106 \fpart{ ID: 2, Content-type: multipart/mixed
107 \fpart{ ID: 3, Content-type: message/rfc822
108 \fpart{ ID: 4, Content-type: text/html
109 Non-text part: text/html
112 \fattachment{ ID: 5, Filename: attachment, Content-type: text/plain
113 This is a text attachment.
115 \fpart{ ID: 6, Content-type: text/plain
116 And this message is signed.
121 \fpart{ ID: 7, Content-type: application/pgp-signature
122 Non-text part: application/pgp-signature
128 test_expect_equal_file OUTPUT EXPECTED
130 test_begin_subtest "--format=text --part=0, full message"
131 notmuch show --format=text --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
133 \fmessage{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 filename:${MAIL_DIR}/multipart
135 Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox signed unread)
136 Subject: Multipart message
137 From: Carl Worth <cworth@cworth.org>
138 To: cworth@cworth.org
139 Date: Tue, 05 Jan 2001 15:43:57 -0000
142 \fpart{ ID: 1, Content-type: multipart/signed
143 \fpart{ ID: 2, Content-type: multipart/mixed
144 \fpart{ ID: 3, Content-type: message/rfc822
145 \fpart{ ID: 4, Content-type: text/html
146 Non-text part: text/html
149 \fattachment{ ID: 5, Filename: attachment, Content-type: text/plain
150 This is a text attachment.
152 \fpart{ ID: 6, Content-type: text/plain
153 And this message is signed.
158 \fpart{ ID: 7, Content-type: application/pgp-signature
159 Non-text part: application/pgp-signature
165 test_expect_equal_file OUTPUT EXPECTED
167 test_begin_subtest "--format=text --part=2, multipart/mixed"
168 notmuch show --format=text --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
170 \fpart{ ID: 2, Content-type: multipart/mixed
171 \fpart{ ID: 3, Content-type: message/rfc822
172 \fpart{ ID: 4, Content-type: text/html
173 Non-text part: text/html
176 \fattachment{ ID: 5, Filename: attachment, Content-type: text/plain
177 This is a text attachment.
179 \fpart{ ID: 6, Content-type: text/plain
180 And this message is signed.
186 test_expect_equal_file OUTPUT EXPECTED
188 test_begin_subtest "--format=text --part=3, rfc822 multipart"
189 notmuch show --format=text --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
191 \fpart{ ID: 3, Content-type: message/rfc822
192 \fpart{ ID: 4, Content-type: text/html
193 Non-text part: text/html
197 test_expect_equal_file OUTPUT EXPECTED
199 test_begin_subtest "--format=text --part=4, html part"
200 notmuch show --format=text --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
202 \fpart{ ID: 4, Content-type: text/html
203 Non-text part: text/html
206 test_expect_equal_file OUTPUT EXPECTED
208 test_begin_subtest "--format=text --part=5, inline attachment"
209 notmuch show --format=text --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
211 \fattachment{ ID: 5, Filename: attachment, Content-type: text/plain
212 This is a text attachment.
215 test_expect_equal_file OUTPUT EXPECTED
217 test_begin_subtest "--format=text --part=6, plain text part"
218 notmuch show --format=text --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
220 \fpart{ ID: 6, Content-type: text/plain
221 And this message is signed.
226 test_expect_equal_file OUTPUT EXPECTED
228 test_begin_subtest "--format=text --part=7, pgp signature (unverified)"
229 notmuch show --format=text --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
231 \fpart{ ID: 7, Content-type: application/pgp-signature
232 Non-text part: application/pgp-signature
235 test_expect_equal_file OUTPUT EXPECTED
237 test_expect_success \
238 "--format=text --part=8, no part, expect error" \
239 "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
241 test_begin_subtest "--format=json --part=0, full message"
242 output=$(notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org')
243 test_expect_equal "$output" \
244 '{"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"}]}]}'
246 test_begin_subtest "--format=json --part=1, message body"
247 output=$(notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org')
248 test_expect_equal "$output" \
249 '{"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"}]}'
251 test_begin_subtest "--format=json --part=2, multipart/mixed"
252 output=$(notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org')
253 test_expect_equal "$output" \
254 '{"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"}]}'
255 test_expect_equal_file OUTPUT EXPECTED
257 test_begin_subtest "--format=json --part=3, rfc822 multipart"
258 output=$(notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org')
259 test_expect_equal "$output" \
260 '{"id": 3, "content-type": "message/rfc822", "content": [{"id": 4, "content-type": "text/html"}]}'
261 test_expect_equal_file OUTPUT EXPECTED
263 test_begin_subtest "--format=json --part=4, html part"
264 output=$(notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org')
265 test_expect_equal "$output" \
266 '{"id": 4, "content-type": "text/html"}'
268 test_begin_subtest "--format=json --part=5, inline attachment"
269 output=$(notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org')
270 test_expect_equal "$output" \
271 '{"id": 5, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}'
273 test_begin_subtest "--format=json --part=6, plain text part"
274 output=$(notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org')
275 test_expect_equal "$output" \
276 '{"id": 6, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}'
278 test_begin_subtest "--format=json --part=7, pgp signature (unverified)"
279 output=$(notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org')
280 test_expect_equal "$output" \
281 '{"id": 7, "content-type": "application/pgp-signature"}'
283 test_expect_success \
284 "--format=json --part=8, no part, expect error" \
285 "notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
287 test_begin_subtest "--format=raw"
288 notmuch show --format=raw 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
289 test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
291 test_begin_subtest "--format=raw --part=0, full message"
292 notmuch show --format=raw --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
293 test_expect_equal_file OUTPUT "${MAIL_DIR}"/multipart
295 test_begin_subtest "--format=raw --part=1, message body"
296 notmuch show --format=raw --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
297 # output should *not* include newline
300 <p>This is an embedded message, with a single html part.</p>
301 This is a text attachment.
302 And this message is signed.
305 -----BEGIN PGP SIGNATURE-----
306 Version: GnuPG v1.4.11 (GNU/Linux)
308 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
309 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
311 -----END PGP SIGNATURE-----
313 test_expect_equal_file OUTPUT EXPECTED
315 test_begin_subtest "--format=raw --part=2, multipart/mixed"
316 notmuch show --format=raw --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
318 <p>This is an embedded message, with a single html part.</p>
319 This is a text attachment.
320 And this message is signed.
324 test_expect_equal_file OUTPUT EXPECTED
326 test_begin_subtest "--format=raw --part=3, rfc822 multipart"
327 notmuch show --format=raw --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
329 <p>This is an embedded message, with a single html part.</p>
331 test_expect_equal_file OUTPUT EXPECTED
333 test_begin_subtest "--format=raw --part=4, html part"
334 notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
336 <p>This is an embedded message, with a single html part.</p>
338 test_expect_equal_file OUTPUT EXPECTED
340 test_begin_subtest "--format=raw --part=5, inline attachment"
341 notmuch show --format=raw --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
343 This is a text attachment.
345 test_expect_equal_file OUTPUT EXPECTED
347 test_begin_subtest "--format=raw --part=6, plain text part"
348 notmuch show --format=raw --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
350 And this message is signed.
354 test_expect_equal_file OUTPUT EXPECTED
356 test_begin_subtest "--format=raw --part=7, pgp signature (unverified)"
357 notmuch show --format=raw --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
358 # output should *not* include newline
361 -----BEGIN PGP SIGNATURE-----
362 Version: GnuPG v1.4.11 (GNU/Linux)
364 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
365 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
367 -----END PGP SIGNATURE-----
369 test_expect_equal_file OUTPUT EXPECTED
371 test_expect_success \
372 "--format=raw --part=8, no part, expect error" \
373 "notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
375 test_begin_subtest "--format=mbox"
376 notmuch show --format=mbox 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
377 printf "From cworth@cworth.org Fri Jan 5 15:43:57 2001\n" >EXPECTED
378 cat "${MAIL_DIR}"/multipart >>EXPECTED
379 # mbox output is expected to include a blank line
381 test_expect_equal_file OUTPUT EXPECTED
383 test_expect_success \
384 "--format=mbox --part=1, incompatible, expect error" \
385 "! notmuch show --format=mbox --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
387 test_begin_subtest "'notmuch reply' to a multipart message"
388 notmuch reply 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT
390 From: Notmuch Test Suite <test_suite@notmuchmail.org>
391 Subject: Re: Multipart message
392 To: Carl Worth <cworth@cworth.org>, cworth@cworth.org
393 In-Reply-To: <87liy5ap00.fsf@yoom.home.cworth.org>
394 References: <87liy5ap00.fsf@yoom.home.cworth.org>
396 On Tue, 05 Jan 2001 15:43:57 -0000, Carl Worth <cworth@cworth.org> wrote:
397 Non-text part: multipart/signed
398 Non-text part: multipart/mixed
399 Non-text part: message/rfc822
400 Non-text part: text/html
401 > This is a text attachment.
402 > And this message is signed.
405 Non-text part: application/pgp-signature
407 test_expect_equal_file OUTPUT EXPECTED
409 test_begin_subtest "'notmuch show --part' does not corrupt a part with CRLF pair"
410 notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out
411 echo -n -e "\xEF\x0D\x0A" > crlf.expected
412 test_expect_equal_file crlf.out crlf.expected