]> git.notmuchmail.org Git - notmuch/blob - test/multipart
1bcdfa254d788e888cd832d823641ca5fb4643d2
[notmuch] / test / multipart
1 #!/usr/bin/env bash
2 test_description="output of multipart message"
3 . ./test-lib.sh
4
5 cat <<EOF > ${MAIL_DIR}/multipart
6 From: Carl Worth <cworth@cworth.org>
7 To: 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>
12 MIME-Version: 1.0
13 Content-Type: multipart/signed; boundary="==-=-=";
14         micalg=pgp-sha1; protocol="application/pgp-signature"
15
16 --==-=-=
17 Content-Type: multipart/mixed; boundary="=-=-="
18
19 --=-=-=
20 Content-Type: message/rfc822
21 Content-Disposition: inline
22
23 From: Carl Worth <cworth@cworth.org>
24 To: cworth@cworth.org
25 Subject: html message
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>
29 MIME-Version: 1.0
30 Content-Type: text/html
31
32 <p>This is an embedded message, with a single html part.</p>
33
34 --=-=-=
35 Content-Disposition: attachment; filename=attachment
36
37 This is a text attachment.
38
39 --=-=-=
40
41 And this message is signed.
42
43 -Carl
44
45 --=-=-=--
46
47 --==-=-=
48 Content-Type: application/pgp-signature
49
50 -----BEGIN PGP SIGNATURE-----
51 Version: GnuPG v1.4.11 (GNU/Linux)
52
53 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
54 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
55 =zkga
56 -----END PGP SIGNATURE-----
57 --==-=-=--
58 EOF
59 notmuch new > /dev/null
60
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
65 \fheader{
66 Carl Worth <cworth@cworth.org> (2001-01-05) (attachment inbox signed unread)
67 Subject: Multipart message
68 From: Carl Worth <cworth@cworth.org>
69 To: cworth@cworth.org
70 Date: Tue, 05 Jan 2001 15:43:57 -0000
71 \fheader}
72 \fbody{
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
78 \fpart}
79 \fpart}
80 \fattachment{ ID: 5, Content-type: text/plain
81 Attachment: attachment (text/plain)
82 This is a text attachment.
83 \fattachment}
84 \fpart{ ID: 6, Content-type: text/plain
85 And this message is signed.
86
87 -Carl
88 \fpart}
89 \fpart}
90 \fpart{ ID: 7, Content-type: application/pgp-signature
91 Non-text part: application/pgp-signature
92 \fpart}
93 \fpart}
94 \fbody}
95 \fmessage}"
96
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
105 \fpart}
106 \fpart}
107 \fattachment{ ID: 5, Content-type: text/plain
108 Attachment: attachment (text/plain)
109 This is a text attachment.
110 \fattachment}
111 \fpart{ ID: 6, Content-type: text/plain
112 And this message is signed.
113
114 -Carl
115 \fpart}
116 \fpart}
117 \fpart{ ID: 7, Content-type: application/pgp-signature
118 Non-text part: application/pgp-signature
119 \fpart}
120 \fpart}"
121
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
129 \fpart}
130 \fpart}
131 \fattachment{ ID: 5, Content-type: text/plain
132 Attachment: attachment (text/plain)
133 This is a text attachment.
134 \fattachment}
135 \fpart{ ID: 6, Content-type: text/plain
136 And this message is signed.
137
138 -Carl
139 \fpart}
140 \fpart}"
141
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
148 \fpart}
149 \fpart}"
150
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
156 \fpart}"
157
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.
164 \fattachment}"
165
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.
171
172 -Carl
173 \fpart}"
174
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
180 \fpart}"
181
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'"
185
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","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"}]}]}'
190
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"}]}'
195
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"}]}'
200
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"}]}'
205
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"}'
210
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"}'
215
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"}'
220
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"}'
225
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'"
229
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)"
233
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)"
237
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 embedded message, with a single html part.</p>
242 This is a text attachment.
243 And this message is signed.
244
245 -Carl
246 -----BEGIN PGP SIGNATURE-----
247 Version: GnuPG v1.4.11 (GNU/Linux)
248
249 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
250 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
251 =zkga
252 -----END PGP SIGNATURE-----'
253
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 embedded message, with a single html part.</p>
258 This is a text attachment.
259 And this message is signed.
260
261 -Carl'
262
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 embedded message, with a single html part.</p>'
267
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 embedded message, with a single html part.</p>'
272
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.'
277
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.
282
283 -Carl'
284
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)
290
291 iEYEARECAAYFAk3SA/gACgkQ6JDdNq8qSWj0sACghqVJEQJUs3yV8zbTzhgnSIcD
292 W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
293 =zkga
294 -----END PGP SIGNATURE-----'
295
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'"
299
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)"
303
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'"
307
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>
315
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.
323
324 > -Carl
325 Non-text part: application/pgp-signature"
326
327
328 test_done