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 imbeded 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-----
59 notmuch new > /dev/null
61 test_begin_subtest "--format=text --part=0, full message"
62 output=$(notmuch show --format=text --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org')
63 test_expect_equal "$output" \
64 "
\fmessage{ id:87liy5ap00.fsf@yoom.home.cworth.org depth:0 match:1 filename:${MAIL_DIR}/multipart
66 Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox unread)
67 Subject: Multipart message
68 From: Carl Worth <cworth@cworth.org>
70 Date: Tue, 05 Jan 2001 15:43:57 -0000
73 \fpart{ ID: 1, Content-type: multipart/signed
74 \fpart{ ID: 2, Content-type: multipart/mixed
75 \fpart{ ID: 3, Content-type: message/rfc822
76 \fpart{ ID: 4, Content-type: text/html
77 Non-text part: text/html
80 \fattachment{ ID: 5, Content-type: text/plain
81 Attachment: attachment (text/plain)
82 This is a text attachment.
84 \fpart{ ID: 6, Content-type: text/plain
85 And this message is signed.
90 \fpart{ ID: 7, Content-type: application/pgp-signature
91 Non-text part: application/pgp-signature
97 test_begin_subtest "--format=text --part=1, message body"
98 output=$(notmuch show --format=text --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org')
99 test_expect_equal "$output" \
100 "
\fpart{ ID: 1, Content-type: multipart/signed
101 \fpart{ ID: 2, Content-type: multipart/mixed
102 \fpart{ ID: 3, Content-type: message/rfc822
103 \fpart{ ID: 4, Content-type: text/html
104 Non-text part: text/html
107 \fattachment{ ID: 5, Content-type: text/plain
108 Attachment: attachment (text/plain)
109 This is a text attachment.
111 \fpart{ ID: 6, Content-type: text/plain
112 And this message is signed.
117 \fpart{ ID: 7, Content-type: application/pgp-signature
118 Non-text part: application/pgp-signature
122 test_begin_subtest "--format=text --part=2, multipart/mixed"
123 output=$(notmuch show --format=text --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org')
124 test_expect_equal "$output" \
125 "
\fpart{ ID: 2, Content-type: multipart/mixed
126 \fpart{ ID: 3, Content-type: message/rfc822
127 \fpart{ ID: 4, Content-type: text/html
128 Non-text part: text/html
131 \fattachment{ ID: 5, Content-type: text/plain
132 Attachment: attachment (text/plain)
133 This is a text attachment.
135 \fpart{ ID: 6, Content-type: text/plain
136 And this message is signed.
142 test_begin_subtest "--format=text --part=3, rfc822 multipart"
143 output=$(notmuch show --format=text --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org')
144 test_expect_equal "$output" \
145 "
\fpart{ ID: 3, Content-type: message/rfc822
146 \fpart{ ID: 4, Content-type: text/html
147 Non-text part: text/html
151 test_begin_subtest "--format=text --part=4, html part"
152 output=$(notmuch show --format=text --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org')
153 test_expect_equal "$output" \
154 "
\fpart{ ID: 4, Content-type: text/html
155 Non-text part: text/html
158 test_begin_subtest "--format=text --part=5, inline attachement"
159 output=$(notmuch show --format=text --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org')
160 test_expect_equal "$output" \
161 "
\fattachment{ ID: 5, Content-type: text/plain
162 Attachment: attachment (text/plain)
163 This is a text attachment.
166 test_begin_subtest "--format=text --part=6, plain text part"
167 output=$(notmuch show --format=text --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org')
168 test_expect_equal "$output" \
169 "
\fpart{ ID: 6, Content-type: text/plain
170 And this message is signed.
175 test_begin_subtest "--format=text --part=7, pgp signature (unverified)"
176 output=$(notmuch show --format=text --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org')
177 test_expect_equal "$output" \
178 "
\fpart{ ID: 7, Content-type: application/pgp-signature
179 Non-text part: application/pgp-signature
182 test_expect_success \
183 "--format=text --part=8, no part, expect error" \
184 "notmuch show --format=text --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
186 test_begin_subtest "--format=json --part=0, full message"
187 output=$(notmuch show --format=json --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org')
188 test_expect_equal "$output" \
189 '{"id": "87liy5ap00.fsf@yoom.home.cworth.org", "match": true, "filename": "'"${MAIL_DIR}/multipart"'", "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["attachment","inbox","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"}]}]}'
191 test_begin_subtest "--format=json --part=1, message body"
192 output=$(notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org')
193 test_expect_equal "$output" \
194 '{"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"}]}'
196 test_begin_subtest "--format=json --part=2, multipart/mixed"
197 output=$(notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org')
198 test_expect_equal "$output" \
199 '{"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"}]}'
201 test_begin_subtest "--format=json --part=3, rfc822 multipart"
202 output=$(notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org')
203 test_expect_equal "$output" \
204 '{"id": 3, "content-type": "message/rfc822", "content": [{"id": 4, "content-type": "text/html"}]}'
206 test_begin_subtest "--format=json --part=4, html part"
207 output=$(notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org')
208 test_expect_equal "$output" \
209 '{"id": 4, "content-type": "text/html"}'
211 test_begin_subtest "--format=json --part=5, inline attachment"
212 output=$(notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org')
213 test_expect_equal "$output" \
214 '{"id": 5, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}'
216 test_begin_subtest "--format=json --part=6, plain text part"
217 output=$(notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org')
218 test_expect_equal "$output" \
219 '{"id": 6, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}'
221 test_begin_subtest "--format=json --part=7, pgp signature (unverified)"
222 output=$(notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org')
223 test_expect_equal "$output" \
224 '{"id": 7, "content-type": "application/pgp-signature"}'
226 test_expect_success \
227 "--format=json --part=8, no part, expect error" \
228 "notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
230 test_begin_subtest "--format=raw"
231 output=$(notmuch show --format=raw 'id:87liy5ap00.fsf@yoom.home.cworth.org')
232 test_expect_equal "$output" "$(cat "${MAIL_DIR}"/multipart)"
234 test_begin_subtest "--format=raw --part=0, full message"
235 output=$(notmuch show --format=raw --part=0 'id:87liy5ap00.fsf@yoom.home.cworth.org')
236 test_expect_equal "$output" "$(cat "${MAIL_DIR}"/multipart)"
238 test_begin_subtest "--format=raw --part=1, message body"
239 output=$(notmuch show --format=raw --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org')
240 test_expect_equal "$output" \
241 '<p>This is an imbeded message, with a single html part.</p>
242 This is a text attachment.
243 And this message is signed.
246 -----BEGIN PGP SIGNATURE-----
247 Version: GnuPG v1.4.11 (GNU/Linux)
249 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
250 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
252 -----END PGP SIGNATURE-----'
254 test_begin_subtest "--format=raw --part=2, multipart/mixed"
255 output=$(notmuch show --format=raw --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org')
256 test_expect_equal "$output" \
257 '<p>This is an imbeded message, with a single html part.</p>
258 This is a text attachment.
259 And this message is signed.
263 test_begin_subtest "--format=raw --part=3, rfc822 multipart"
264 output=$(notmuch show --format=raw --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org')
265 test_expect_equal "$output" \
266 '<p>This is an imbeded message, with a single html part.</p>'
268 test_begin_subtest "--format=raw --part=4, html part"
269 output=$(notmuch show --format=raw --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org')
270 test_expect_equal "$output" \
271 '<p>This is an imbeded message, with a single html part.</p>'
273 test_begin_subtest "--format=raw --part=5, inline attachment"
274 output=$(notmuch show --format=raw --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org')
275 test_expect_equal "$output" \
276 'This is a text attachment.'
278 test_begin_subtest "--format=raw --part=6, plain text part"
279 output=$(notmuch show --format=raw --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org')
280 test_expect_equal "$output" \
281 'And this message is signed.
285 test_begin_subtest "--format=raw --part=7, pgp signature (unverified)"
286 output=$(notmuch show --format=raw --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org')
287 test_expect_equal "$output" \
288 '-----BEGIN PGP SIGNATURE-----
289 Version: GnuPG v1.4.11 (GNU/Linux)
291 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
292 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
294 -----END PGP SIGNATURE-----'
296 test_expect_success \
297 "--format=raw --part=8, no part, expect error" \
298 "notmuch show --format=raw --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
300 test_begin_subtest "--format=mbox"
301 output=$(notmuch show --format=mbox 'id:87liy5ap00.fsf@yoom.home.cworth.org')
302 test_expect_equal "$output" "$(printf "From cworth@cworth.org Fri Jan 5 15:43:57 2001\n"; cat "${MAIL_DIR}"/multipart)"
304 test_expect_success \
305 "--format=mbox --part=1, incompatible, expect error" \
306 "! notmuch show --format=mbox --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org'"
308 test_begin_subtest "'notmuch reply' to a multipart message"
309 output=$(notmuch reply 'id:87liy5ap00.fsf@yoom.home.cworth.org')
310 test_expect_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
311 Subject: Re: Multipart message
312 To: Carl Worth <cworth@cworth.org>, cworth@cworth.org
313 In-Reply-To: <87liy5ap00.fsf@yoom.home.cworth.org>
314 References: <87liy5ap00.fsf@yoom.home.cworth.org>
316 On Tue, 05 Jan 2001 15:43:57 -0000, Carl Worth <cworth@cworth.org> wrote:
317 Non-text part: multipart/signed
318 Non-text part: multipart/mixed
319 Non-text part: message/rfc822
320 Non-text part: text/html
321 > This is a text attachment.
322 > And this message is signed.
325 Non-text part: application/pgp-signature"