Re: (emacs) Parsing problems replying to encrypted html
[notmuch-archives.git] / c8 / be1d796f6ae31456f94f9ec859ccd470697edd
1 Return-Path: <jrollins@servo.finestructure.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id D6C7A429E34\r
6         for <notmuch@notmuchmail.org>; Sun,  5 Jun 2011 17:29:54 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.921\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.921 tagged_above=-999 required=5\r
12         tests=[NO_DNS_FOR_FROM=0.379, RCVD_IN_DNSWL_MED=-2.3]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id hxUpCsVjKePr for <notmuch@notmuchmail.org>;\r
17         Sun,  5 Jun 2011 17:29:47 -0700 (PDT)\r
18 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
19         [131.215.239.19])\r
20         by olra.theworths.org (Postfix) with ESMTP id 949E9431FB6\r
21         for <notmuch@notmuchmail.org>; Sun,  5 Jun 2011 17:29:41 -0700 (PDT)\r
22 Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
23         by fire-doxen-postvirus (Postfix) with ESMTP id CE54D3280D8;\r
24         Sun,  5 Jun 2011 17:22:38 -0700 (PDT)\r
25 X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
26 Received: from servo.finestructure.net (cpe-98-149-172-122.socal.res.rr.com\r
27         [98.149.172.122]) (Authenticated sender: jrollins)\r
28         by fire-doxen-submit (Postfix) with ESMTP id A5B383280DA;\r
29         Sun,  5 Jun 2011 17:22:29 -0700 (PDT)\r
30 Received: by servo.finestructure.net (Postfix, from userid 1000)\r
31         id 20E5121D; Sun,  5 Jun 2011 17:29:31 -0700 (PDT)\r
32 From: Jameson Graef Rollins <jrollins@finestructure.net>\r
33 To: Notmuch Mail <notmuch@notmuchmail.org>\r
34 Subject: [PATCH 3/5] test: overhaul multipart test to test for improved\r
35         message/rfc822 handling\r
36 Date: Sun,  5 Jun 2011 17:29:27 -0700\r
37 Message-Id: <1307320169-29905-4-git-send-email-jrollins@finestructure.net>\r
38 X-Mailer: git-send-email 1.7.4.4\r
39 In-Reply-To: <1307320169-29905-3-git-send-email-jrollins@finestructure.net>\r
40 References: <87sjrsi2b4.fsf@servo.factory.finestructure.net>\r
41         <1307320169-29905-1-git-send-email-jrollins@finestructure.net>\r
42         <1307320169-29905-2-git-send-email-jrollins@finestructure.net>\r
43         <1307320169-29905-3-git-send-email-jrollins@finestructure.net>\r
44 X-BeenThere: notmuch@notmuchmail.org\r
45 X-Mailman-Version: 2.1.13\r
46 Precedence: list\r
47 List-Id: "Use and development of the notmuch mail system."\r
48         <notmuch.notmuchmail.org>\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
52 List-Post: <mailto:notmuch@notmuchmail.org>\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
56 X-List-Received-Date: Mon, 06 Jun 2011 00:29:55 -0000\r
57 \r
58 The main goal of this overhaul is to define how message/rfc822 parts\r
59 should be handled.  message/rfc822 parts should be output in a similar\r
60 fashion to the outer message, including some subset of the rfc822\r
61 headers.  The following decisions about formatting of message/rfc822\r
62 parts were made:\r
63 \r
64 The format and content of message/rfc822 parts shall be as similar as\r
65 possible to that of full messages.  In particular, for formatted\r
66 outputs, the "content" of rfc822 part output should include "headers"\r
67 and "body" fields).\r
68 \r
69 The "body" field shall include the body of the message.\r
70 \r
71 The "headers" field shall include the following headers, since these\r
72 are the ones available from the GMimeMessage:\r
73 \r
74   "From"\r
75   "To"\r
76   "Cc"\r
77   "Subject"\r
78   "Date"\r
79 \r
80 However, for the case of --format=raw the raw rfc822 should be output,\r
81 including all headers.\r
82 \r
83 A subset of relevant headers shall be output in reply.\r
84 \r
85 The test embedded rfc822 message is also modified to be itself\r
86 multipart, so we can more fully test how all sub parts of the message\r
87 part are output.\r
88 ---\r
89  test/multipart |  368 +++++++++++++++++++++++++++++++++++++++++++-------------\r
90  1 files changed, 283 insertions(+), 85 deletions(-)\r
91 \r
92 diff --git a/test/multipart b/test/multipart\r
93 index 67e04d9..95577dc 100755\r
94 --- a/test/multipart\r
95 +++ b/test/multipart\r
96 @@ -2,6 +2,29 @@\r
97  test_description="output of multipart message"\r
98  . ./test-lib.sh\r
99  \r
100 +cat <<EOF > embedded_message\r
101 +From: Carl Worth <cworth@cworth.org>\r
102 +To: cworth@cworth.org\r
103 +Subject: html message\r
104 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
105 +User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)\r
106 +Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>\r
107 +MIME-Version: 1.0\r
108 +Content-Type: multipart/alternative; boundary="==-=-=="\r
109 +\r
110 +--==-=-==\r
111 +Content-Type: text/html\r
112 +\r
113 +<p>This is an embedded message, with a multipart/alternative part.</p>\r
114 +\r
115 +--==-=-==\r
116 +Content-Type: text/plain\r
117 +\r
118 +This is an embedded message, with a multipart/alternative part.\r
119 +\r
120 +--==-=-==--\r
121 +EOF\r
122 +\r
123  cat <<EOF > ${MAIL_DIR}/multipart\r
124  From: Carl Worth <cworth@cworth.org>\r
125  To: cworth@cworth.org\r
126 @@ -20,17 +43,9 @@ Content-Type: multipart/mixed; boundary="=-=-="\r
127  Content-Type: message/rfc822\r
128  Content-Disposition: inline\r
129  \r
130 -From: Carl Worth <cworth@cworth.org>\r
131 -To: cworth@cworth.org\r
132 -Subject: html message\r
133 -Date: Fri, 05 Jan 2001 15:42:57 +0000\r
134 -User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)\r
135 -Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>\r
136 -MIME-Version: 1.0\r
137 -Content-Type: text/html\r
138 -\r
139 -<p>This is an embedded message, with a single html part.</p>\r
140 -\r
141 +EOF\r
142 +cat embedded_message >> ${MAIL_DIR}/multipart\r
143 +cat <<EOF >> ${MAIL_DIR}/multipart\r
144  --=-=-=\r
145  Content-Disposition: attachment; filename=attachment\r
146  \r
147 @@ -106,21 +121,34 @@ Date: Fri, 05 Jan 2001 15:43:57 +0000\r
148  \f\r
149 part{ ID: 1, Content-type: multipart/signed\r
150  \f\r
151 part{ ID: 2, Content-type: multipart/mixed\r
152  \f\r
153 part{ ID: 3, Content-type: message/rfc822\r
154 -\f\r
155 part{ ID: 4, Content-type: text/html\r
156 +\f\r
157 header{\r
158 +From: Carl Worth <cworth@cworth.org>\r
159 +To: cworth@cworth.org\r
160 +Subject: html message\r
161 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
162 +\f\r
163 header}\r
164 +\f\r
165 body{\r
166 +\f\r
167 part{ ID: 4, Content-type: multipart/alternative\r
168 +\f\r
169 part{ ID: 5, Content-type: text/html\r
170  Non-text part: text/html\r
171  \f\r
172 part}\r
173 +\f\r
174 part{ ID: 6, Content-type: text/plain\r
175 +This is an embedded message, with a multipart/alternative part.\r
176 +\f\r
177 part}\r
178 +\f\r
179 part}\r
180 +\f\r
181 body}\r
182  \f\r
183 part}\r
184 -\f\r
185 attachment{ ID: 5, Content-type: text/plain\r
186 +\f\r
187 attachment{ ID: 7, Content-type: text/plain\r
188  Attachment: attachment (text/plain)\r
189  This is a text attachment.\r
190  \f\r
191 attachment}\r
192 -\f\r
193 part{ ID: 6, Content-type: text/plain\r
194 +\f\r
195 part{ ID: 8, Content-type: text/plain\r
196  And this message is signed.\r
197  \r
198  -Carl\r
199  \f\r
200 part}\r
201  \f\r
202 part}\r
203 -\f\r
204 part{ ID: 7, Content-type: application/pgp-signature\r
205 +\f\r
206 part{ ID: 9, Content-type: application/pgp-signature\r
207  Non-text part: application/pgp-signature\r
208  \f\r
209 part}\r
210  \f\r
211 part}\r
212 @@ -135,21 +163,34 @@ cat <<EOF >EXPECTED\r
213  \f\r
214 part{ ID: 1, Content-type: multipart/signed\r
215  \f\r
216 part{ ID: 2, Content-type: multipart/mixed\r
217  \f\r
218 part{ ID: 3, Content-type: message/rfc822\r
219 -\f\r
220 part{ ID: 4, Content-type: text/html\r
221 +\f\r
222 header{\r
223 +From: Carl Worth <cworth@cworth.org>\r
224 +To: cworth@cworth.org\r
225 +Subject: html message\r
226 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
227 +\f\r
228 header}\r
229 +\f\r
230 body{\r
231 +\f\r
232 part{ ID: 4, Content-type: multipart/alternative\r
233 +\f\r
234 part{ ID: 5, Content-type: text/html\r
235  Non-text part: text/html\r
236  \f\r
237 part}\r
238 +\f\r
239 part{ ID: 6, Content-type: text/plain\r
240 +This is an embedded message, with a multipart/alternative part.\r
241 +\f\r
242 part}\r
243  \f\r
244 part}\r
245 -\f\r
246 attachment{ ID: 5, Content-type: text/plain\r
247 +\f\r
248 body}\r
249 +\f\r
250 part}\r
251 +\f\r
252 attachment{ ID: 7, Content-type: text/plain\r
253  Attachment: attachment (text/plain)\r
254  This is a text attachment.\r
255  \f\r
256 attachment}\r
257 -\f\r
258 part{ ID: 6, Content-type: text/plain\r
259 +\f\r
260 part{ ID: 8, Content-type: text/plain\r
261  And this message is signed.\r
262  \r
263  -Carl\r
264  \f\r
265 part}\r
266  \f\r
267 part}\r
268 -\f\r
269 part{ ID: 7, Content-type: application/pgp-signature\r
270 +\f\r
271 part{ ID: 9, Content-type: application/pgp-signature\r
272  Non-text part: application/pgp-signature\r
273  \f\r
274 part}\r
275  \f\r
276 part}\r
277 @@ -161,15 +202,28 @@ notmuch show --format=text --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OU\r
278  cat <<EOF >EXPECTED\r
279  \f\r
280 part{ ID: 2, Content-type: multipart/mixed\r
281  \f\r
282 part{ ID: 3, Content-type: message/rfc822\r
283 -\f\r
284 part{ ID: 4, Content-type: text/html\r
285 +\f\r
286 header{\r
287 +From: Carl Worth <cworth@cworth.org>\r
288 +To: cworth@cworth.org\r
289 +Subject: html message\r
290 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
291 +\f\r
292 header}\r
293 +\f\r
294 body{\r
295 +\f\r
296 part{ ID: 4, Content-type: multipart/alternative\r
297 +\f\r
298 part{ ID: 5, Content-type: text/html\r
299  Non-text part: text/html\r
300  \f\r
301 part}\r
302 +\f\r
303 part{ ID: 6, Content-type: text/plain\r
304 +This is an embedded message, with a multipart/alternative part.\r
305 +\f\r
306 part}\r
307  \f\r
308 part}\r
309 -\f\r
310 attachment{ ID: 5, Content-type: text/plain\r
311 +\f\r
312 body}\r
313 +\f\r
314 part}\r
315 +\f\r
316 attachment{ ID: 7, Content-type: text/plain\r
317  Attachment: attachment (text/plain)\r
318  This is a text attachment.\r
319  \f\r
320 attachment}\r
321 -\f\r
322 part{ ID: 6, Content-type: text/plain\r
323 +\f\r
324 part{ ID: 8, Content-type: text/plain\r
325  And this message is signed.\r
326  \r
327  -Carl\r
328 @@ -178,40 +232,76 @@ And this message is signed.\r
329  EOF\r
330  test_expect_equal_file OUTPUT EXPECTED\r
331  \r
332 -test_begin_subtest "--format=text --part=3, rfc822 multipart"\r
333 +test_begin_subtest "--format=text --part=3, rfc822 part"\r
334  notmuch show --format=text --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
335  cat <<EOF >EXPECTED\r
336  \f\r
337 part{ ID: 3, Content-type: message/rfc822\r
338 -\f\r
339 part{ ID: 4, Content-type: text/html\r
340 +\f\r
341 header{\r
342 +From: Carl Worth <cworth@cworth.org>\r
343 +To: cworth@cworth.org\r
344 +Subject: html message\r
345 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
346 +\f\r
347 header}\r
348 +\f\r
349 body{\r
350 +\f\r
351 part{ ID: 4, Content-type: multipart/alternative\r
352 +\f\r
353 part{ ID: 5, Content-type: text/html\r
354  Non-text part: text/html\r
355  \f\r
356 part}\r
357 +\f\r
358 part{ ID: 6, Content-type: text/plain\r
359 +This is an embedded message, with a multipart/alternative part.\r
360 +\f\r
361 part}\r
362 +\f\r
363 part}\r
364 +\f\r
365 body}\r
366  \f\r
367 part}\r
368  EOF\r
369  test_expect_equal_file OUTPUT EXPECTED\r
370  \r
371 -test_begin_subtest "--format=text --part=4, html part"\r
372 +test_begin_subtest "--format=text --part=4, rfc822's multipart"\r
373  notmuch show --format=text --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
374  cat <<EOF >EXPECTED\r
375 -\f\r
376 part{ ID: 4, Content-type: text/html\r
377 +\f\r
378 part{ ID: 4, Content-type: multipart/alternative\r
379 +\f\r
380 part{ ID: 5, Content-type: text/html\r
381  Non-text part: text/html\r
382  \f\r
383 part}\r
384 +\f\r
385 part{ ID: 6, Content-type: text/plain\r
386 +This is an embedded message, with a multipart/alternative part.\r
387 +\f\r
388 part}\r
389 +\f\r
390 part}\r
391  EOF\r
392  test_expect_equal_file OUTPUT EXPECTED\r
393  \r
394 -test_begin_subtest "--format=text --part=5, inline attachement"\r
395 +test_begin_subtest "--format=text --part=5, rfc822's html part"\r
396  notmuch show --format=text --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
397  cat <<EOF >EXPECTED\r
398 -\f\r
399 attachment{ ID: 5, Content-type: text/plain\r
400 +\f\r
401 part{ ID: 5, Content-type: text/html\r
402 +Non-text part: text/html\r
403 +\f\r
404 part}\r
405 +EOF\r
406 +test_expect_equal_file OUTPUT EXPECTED\r
407 +\r
408 +test_begin_subtest "--format=text --part=6, rfc822's text part"\r
409 +notmuch show --format=text --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
410 +cat <<EOF >EXPECTED\r
411 +\f\r
412 part{ ID: 6, Content-type: text/plain\r
413 +This is an embedded message, with a multipart/alternative part.\r
414 +\f\r
415 part}\r
416 +EOF\r
417 +test_expect_equal_file OUTPUT EXPECTED\r
418 +\r
419 +test_begin_subtest "--format=text --part=7, inline attachement"\r
420 +notmuch show --format=text --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
421 +cat <<EOF >EXPECTED\r
422 +\f\r
423 attachment{ ID: 7, Content-type: text/plain\r
424  Attachment: attachment (text/plain)\r
425  This is a text attachment.\r
426  \f\r
427 attachment}\r
428  EOF\r
429  test_expect_equal_file OUTPUT EXPECTED\r
430  \r
431 -test_begin_subtest "--format=text --part=6, plain text part"\r
432 -notmuch show --format=text --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
433 +test_begin_subtest "--format=text --part=8, plain text part"\r
434 +notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
435  cat <<EOF >EXPECTED\r
436 -\f\r
437 part{ ID: 6, Content-type: text/plain\r
438 +\f\r
439 part{ ID: 8, Content-type: text/plain\r
440  And this message is signed.\r
441  \r
442  -Carl\r
443 @@ -219,10 +309,10 @@ And this message is signed.\r
444  EOF\r
445  test_expect_equal_file OUTPUT EXPECTED\r
446  \r
447 -test_begin_subtest "--format=text --part=7, pgp signature (unverified)"\r
448 -notmuch show --format=text --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
449 +test_begin_subtest "--format=text --part=9, pgp signature (unverified)"\r
450 +notmuch show --format=text --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
451  cat <<EOF >EXPECTED\r
452 -\f\r
453 part{ ID: 7, Content-type: application/pgp-signature\r
454 +\f\r
455 part{ ID: 9, Content-type: application/pgp-signature\r
456  Non-text part: application/pgp-signature\r
457  \f\r
458 part}\r
459  EOF\r
460 @@ -233,48 +323,126 @@ test_expect_success \\r
461      "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"\r
462  \r
463  test_begin_subtest "--format=json --part=0, full message"\r
464 -output=$(notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
465 -test_expect_equal "$output" \\r
466 -'{"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": "Fri, 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"}]}]}'\r
467 +notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
468 +echo >>OUTPUT # expect *no* newline at end of output\r
469 +cat <<EOF >EXPECTED\r
470 +\r
471 +{"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": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [\r
472 +{"id": 1, "content-type": "multipart/signed", "content": [\r
473 +{"id": 2, "content-type": "multipart/mixed", "content": [\r
474 +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [\r
475 +{"id": 4, "content-type": "multipart/alternative", "content": [\r
476 +{"id": 5, "content-type": "text/html"}, \r
477 +{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, \r
478 +{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, \r
479 +{"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, \r
480 +{"id": 9, "content-type": "application/pgp-signature"}]}]}\r
481 +EOF\r
482 +test_expect_equal_file OUTPUT EXPECTED\r
483  \r
484  test_begin_subtest "--format=json --part=1, message body"\r
485 -output=$(notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
486 -test_expect_equal "$output" \\r
487 -'{"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"}]}'\r
488 +notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
489 +echo >>OUTPUT # expect *no* newline at end of output\r
490 +cat <<EOF >EXPECTED\r
491 +\r
492 +{"id": 1, "content-type": "multipart/signed", "content": [\r
493 +{"id": 2, "content-type": "multipart/mixed", "content": [\r
494 +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [\r
495 +{"id": 4, "content-type": "multipart/alternative", "content": [\r
496 +{"id": 5, "content-type": "text/html"}, \r
497 +{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, \r
498 +{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, \r
499 +{"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, \r
500 +{"id": 9, "content-type": "application/pgp-signature"}]}\r
501 +EOF\r
502 +test_expect_equal_file OUTPUT EXPECTED\r
503  \r
504  test_begin_subtest "--format=json --part=2, multipart/mixed"\r
505 -output=$(notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
506 -test_expect_equal "$output" \\r
507 -'{"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"}]}'\r
508 -\r
509 -test_begin_subtest "--format=json --part=3, rfc822 multipart"\r
510 -output=$(notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
511 -test_expect_equal "$output" \\r
512 -'{"id": 3, "content-type": "message/rfc822", "content": [{"id": 4, "content-type": "text/html"}]}'\r
513 -\r
514 -test_begin_subtest "--format=json --part=4, html part"\r
515 -output=$(notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
516 -test_expect_equal "$output" \\r
517 -'{"id": 4, "content-type": "text/html"}'\r
518 -\r
519 -test_begin_subtest "--format=json --part=5, inline attachment"\r
520 -output=$(notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
521 -test_expect_equal "$output" \\r
522 -'{"id": 5, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}'\r
523 -\r
524 -test_begin_subtest "--format=json --part=6, plain text part"\r
525 -output=$(notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
526 -test_expect_equal "$output" \\r
527 -'{"id": 6, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}'\r
528 -\r
529 -test_begin_subtest "--format=json --part=7, pgp signature (unverified)"\r
530 -output=$(notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org')\r
531 -test_expect_equal "$output" \\r
532 -'{"id": 7, "content-type": "application/pgp-signature"}'\r
533 +notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
534 +echo >>OUTPUT # expect *no* newline at end of output\r
535 +cat <<EOF >EXPECTED\r
536 +\r
537 +{"id": 2, "content-type": "multipart/mixed", "content": [\r
538 +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [\r
539 +{"id": 4, "content-type": "multipart/alternative", "content": [\r
540 +{"id": 5, "content-type": "text/html"}, \r
541 +{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}, \r
542 +{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, \r
543 +{"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}\r
544 +EOF\r
545 +test_expect_equal_file OUTPUT EXPECTED\r
546 +\r
547 +test_begin_subtest "--format=json --part=3, rfc822 part"\r
548 +notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
549 +echo >>OUTPUT # expect *no* newline at end of output\r
550 +cat <<EOF >EXPECTED\r
551 +\r
552 +{"id": 3, "content-type": "message/rfc822", "content": [{"headers": {"From": "Carl Worth <cworth@cworth.org>", "To": "cworth@cworth.org", "Subject": "html message", "Date": "Fri, 05 Jan 2001 15:42:57 +0000"}, "body": [\r
553 +{"id": 4, "content-type": "multipart/alternative", "content": [\r
554 +{"id": 5, "content-type": "text/html"}, \r
555 +{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}\r
556 +EOF\r
557 +test_expect_equal_file OUTPUT EXPECTED\r
558 +\r
559 +test_begin_subtest "--format=json --part=4, rfc822's multipart/alternative"\r
560 +notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
561 +echo >>OUTPUT # expect *no* newline at end of output\r
562 +cat <<EOF >EXPECTED\r
563 +\r
564 +{"id": 4, "content-type": "multipart/alternative", "content": [\r
565 +{"id": 5, "content-type": "text/html"}, \r
566 +{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}\r
567 +EOF\r
568 +test_expect_equal_file OUTPUT EXPECTED\r
569 +\r
570 +test_begin_subtest "--format=json --part=5, rfc822's html part"\r
571 +notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
572 +echo >>OUTPUT # expect *no* newline at end of output\r
573 +cat <<EOF >EXPECTED\r
574 +\r
575 +{"id": 5, "content-type": "text/html"}\r
576 +EOF\r
577 +test_expect_equal_file OUTPUT EXPECTED\r
578 +\r
579 +test_begin_subtest "--format=json --part=6, rfc822's text part"\r
580 +notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
581 +echo >>OUTPUT # expect *no* newline at end of output\r
582 +cat <<EOF >EXPECTED\r
583 +\r
584 +{"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}\r
585 +EOF\r
586 +test_expect_equal_file OUTPUT EXPECTED\r
587 +\r
588 +test_begin_subtest "--format=json --part=7, inline attachment"\r
589 +notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
590 +echo >>OUTPUT # expect *no* newline at end of output\r
591 +cat <<EOF >EXPECTED\r
592 +\r
593 +{"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}\r
594 +EOF\r
595 +test_expect_equal_file OUTPUT EXPECTED\r
596 +\r
597 +test_begin_subtest "--format=json --part=8, plain text part"\r
598 +notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
599 +echo >>OUTPUT # expect *no* newline at end of output\r
600 +cat <<EOF >EXPECTED\r
601 +\r
602 +{"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}\r
603 +EOF\r
604 +test_expect_equal_file OUTPUT EXPECTED\r
605 +\r
606 +test_begin_subtest "--format=json --part=9, pgp signature (unverified)"\r
607 +notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
608 +echo >>OUTPUT # expect *no* newline at end of output\r
609 +cat <<EOF >EXPECTED\r
610 +\r
611 +{"id": 9, "content-type": "application/pgp-signature"}\r
612 +EOF\r
613 +test_expect_equal_file OUTPUT EXPECTED\r
614  \r
615  test_expect_success \\r
616 -    "--format=json --part=8, no part, expect error" \\r
617 -    "notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"\r
618 +    "--format=json --part=10, no part, expect error" \\r
619 +    "notmuch show --format=json --part=10 'id:87liy5ap00.fsf@yoom.home.cworth.org'"\r
620  \r
621  test_begin_subtest "--format=raw"\r
622  notmuch show --format=raw 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
623 @@ -289,7 +457,13 @@ notmuch show --format=raw --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUT\r
624  # output should *not* include newline\r
625  echo >>OUTPUT\r
626  cat <<EOF >EXPECTED\r
627 -<p>This is an embedded message, with a single html part.</p>\r
628 +From: Carl Worth <cworth@cworth.org>\r
629 +To: cworth@cworth.org\r
630 +Subject: html message\r
631 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
632 +\r
633 +<p>This is an embedded message, with a multipart/alternative part.</p>\r
634 +This is an embedded message, with a multipart/alternative part.\r
635  This is a text attachment.\r
636  And this message is signed.\r
637  \r
638 @@ -307,7 +481,13 @@ test_expect_equal_file OUTPUT EXPECTED\r
639  test_begin_subtest "--format=raw --part=2, multipart/mixed"\r
640  notmuch show --format=raw --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
641  cat <<EOF >EXPECTED\r
642 -<p>This is an embedded message, with a single html part.</p>\r
643 +From: Carl Worth <cworth@cworth.org>\r
644 +To: cworth@cworth.org\r
645 +Subject: html message\r
646 +Date: Fri, 05 Jan 2001 15:42:57 +0000\r
647 +\r
648 +<p>This is an embedded message, with a multipart/alternative part.</p>\r
649 +This is an embedded message, with a multipart/alternative part.\r
650  This is a text attachment.\r
651  And this message is signed.\r
652  \r
653 @@ -315,29 +495,41 @@ And this message is signed.\r
654  EOF\r
655  test_expect_equal_file OUTPUT EXPECTED\r
656  \r
657 -test_begin_subtest "--format=raw --part=3, rfc822 multipart"\r
658 +test_begin_subtest "--format=raw --part=3, rfc822 part"\r
659  notmuch show --format=raw --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
660 +test_expect_equal_file OUTPUT embedded_message\r
661 +\r
662 +test_begin_subtest "--format=raw --part=4, rfc822's html part"\r
663 +notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
664  cat <<EOF >EXPECTED\r
665 -<p>This is an embedded message, with a single html part.</p>\r
666 +<p>This is an embedded message, with a multipart/alternative part.</p>\r
667 +This is an embedded message, with a multipart/alternative part.\r
668  EOF\r
669  test_expect_equal_file OUTPUT EXPECTED\r
670  \r
671 -test_begin_subtest "--format=raw --part=4, html part"\r
672 -notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
673 +test_begin_subtest "--format=raw --part=5, rfc822's html part"\r
674 +notmuch show --format=raw --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
675  cat <<EOF >EXPECTED\r
676 -<p>This is an embedded message, with a single html part.</p>\r
677 +<p>This is an embedded message, with a multipart/alternative part.</p>\r
678  EOF\r
679  test_expect_equal_file OUTPUT EXPECTED\r
680  \r
681 -test_begin_subtest "--format=raw --part=5, inline attachment"\r
682 -notmuch show --format=raw --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
683 +test_begin_subtest "--format=raw --part=6, rfc822's text part"\r
684 +notmuch show --format=raw --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
685 +cat <<EOF >EXPECTED\r
686 +This is an embedded message, with a multipart/alternative part.\r
687 +EOF\r
688 +test_expect_equal_file OUTPUT EXPECTED\r
689 +\r
690 +test_begin_subtest "--format=raw --part=7, inline attachment"\r
691 +notmuch show --format=raw --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
692  cat <<EOF >EXPECTED\r
693  This is a text attachment.\r
694  EOF\r
695  test_expect_equal_file OUTPUT EXPECTED\r
696  \r
697 -test_begin_subtest "--format=raw --part=6, plain text part"\r
698 -notmuch show --format=raw --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
699 +test_begin_subtest "--format=raw --part=8, plain text part"\r
700 +notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
701  cat <<EOF >EXPECTED\r
702  And this message is signed.\r
703  \r
704 @@ -345,8 +537,8 @@ And this message is signed.\r
705  EOF\r
706  test_expect_equal_file OUTPUT EXPECTED\r
707  \r
708 -test_begin_subtest "--format=raw --part=7, pgp signature (unverified)"\r
709 -notmuch show --format=raw --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
710 +test_begin_subtest "--format=raw --part=9, pgp signature (unverified)"\r
711 +notmuch show --format=raw --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' >OUTPUT\r
712  # output should *not* include newline\r
713  echo >>OUTPUT\r
714  cat <<EOF >EXPECTED\r
715 @@ -361,7 +553,7 @@ EOF\r
716  test_expect_equal_file OUTPUT EXPECTED\r
717  \r
718  test_expect_success \\r
719 -    "--format=raw --part=8, no part, expect error" \\r
720 +    "--format=raw --part=10, no part, expect error" \\r
721      "notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"\r
722  \r
723  test_begin_subtest "--format=mbox"\r
724 @@ -388,8 +580,14 @@ References: <87liy5ap00.fsf@yoom.home.cworth.org>\r
725  On Fri, 05 Jan 2001 15:43:57 +0000, Carl Worth <cworth@cworth.org> wrote:\r
726  Non-text part: multipart/signed\r
727  Non-text part: multipart/mixed\r
728 -Non-text part: message/rfc822\r
729 +> From: Carl Worth <cworth@cworth.org>\r
730 +> To: cworth@cworth.org\r
731 +> Subject: html message\r
732 +> Date: Fri, 05 Jan 2001 15:42:57 +0000\r
733 +>\r
734 +Non-text part: multipart/alternative\r
735  Non-text part: text/html\r
736 +> This is an embedded message, with a multipart/alternative part.\r
737  > This is a text attachment.\r
738  > And this message is signed.\r
739  > \r
740 -- \r
741 1.7.4.4\r
742 \r