]> diplodocus.org Git - nmh/blob - test/repl/test-convert
Merge branch 'welcome'
[nmh] / test / repl / test-convert
1 #!/bin/sh
2 ######################################################
3 #
4 # Test repl -convertarg
5 #
6 ######################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "${srcdir}/test/post/test-post-common.sh"
16
17 expected="$MH_TEST_DIR/test-convert$$.expected"
18 actual=`mhpath +`/draft
19
20 printf 'Local-Mailbox: recipient@example.com' >>"$MH"
21
22
23 #### Make sure that this works with 7-bit encoding.
24 LC_ALL=C; export LC_ALL
25
26
27 # check -convertarg with multiple parts and additional text in draft
28 start_test '-convertarg with multiple parts and additional text in draft'
29 cat >"$expected" <<'EOF'
30 From: recipient@example.com
31 To: sender@example.com
32 cc:
33 Fcc: +outbox
34 Subject: Re: test
35 Comments: In-reply-to sender@example.com
36 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
37 MIME-Version: 1.0
38 Content-Type: text/plain; charset="US-ASCII"
39
40 > This is part 1.
41
42 > This is part 2.
43 EOF
44
45 cat >`mhpath new` <<'EOF'
46 From: sender@example.com
47 To: recipient@example.com
48 Subject: test
49 Date: Thu, 11 Dec 2014 08:19:02 -0600
50 Content-Type: multipart/mixed; boundary="_001_"
51 MIME-Version: 1.0
52
53 --_001_
54 Content-Type: text/plain
55
56 This is part 1.
57
58 --_001_
59 Content-Type: text/plain
60
61 This is part 2.
62
63 --_001_
64 Content-Type: text/enriched
65
66 This should not appear in the reply
67 because the content type isn't matched.
68
69 --_001_--
70 EOF
71
72 repl -noformat -convertarg text/plain '' -nowhatnowproc last
73 mhbuild "$actual"
74 check "$actual" "$expected"
75
76
77 #### Make sure that this works with 8-bit encoding.
78 finish_test
79 require_locale en_US.utf-8 en_US.utf8
80 LC_ALL=en_US.UTF-8; export LC_ALL
81
82
83 # check -convertarg with multiple parts, 7 bit
84 start_test '-convertarg with multiple parts, 7 bit'
85 cat >"$expected" <<'EOF'
86 From: recipient@example.com
87 To: sender@example.com
88 cc:
89 Fcc: +outbox
90 Subject: Re: test
91 Comments: In-reply-to sender@example.com
92 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
93 MIME-Version: 1.0
94 Content-Type: text/plain; charset="UTF-8"
95
96 sender@example.com writes:
97
98 > This is part 1.
99
100 > This is part 2.
101 EOF
102
103 cat >`mhpath new` <<'EOF'
104 From: sender@example.com
105 To: recipient@example.com
106 Subject: test
107 Date: Thu, 11 Dec 2014 08:19:02 -0600
108 Content-Type: multipart/mixed; boundary="_001_"
109 MIME-Version: 1.0
110
111 --_001_
112 Content-Type: text/plain
113
114 This is part 1.
115
116 --_001_
117 Content-Type: text/plain; charset="UTF-8"
118
119 This is part 2.
120
121 --_001_--
122 EOF
123
124 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
125 mhbuild "$actual"
126 check "$actual" "$expected"
127
128
129 # check -convertarg with multiple parts, 8 bit
130 start_test '-convertarg with multiple parts, 8 bit'
131 cat >"$expected" <<'EOF'
132 From: recipient@example.com
133 To: sender@example.com
134 cc:
135 Fcc: +outbox
136 Subject: Re: test
137 Comments: In-reply-to sender@example.com
138 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
139 MIME-Version: 1.0
140 Content-Type: text/plain; charset="UTF-8"
141 Content-Transfer-Encoding: 8bit
142
143 sender@example.com writes:
144
145 > This is part 1.
146
147 > This is §2, with a non-ASCII character.
148 EOF
149
150 cat >`mhpath new` <<'EOF'
151 From: sender@example.com
152 To: recipient@example.com
153 Subject: test
154 Date: Thu, 11 Dec 2014 08:19:02 -0600
155 Content-Type: multipart/mixed; boundary="_001_"
156 MIME-Version: 1.0
157
158 --_001_
159 Content-Type: text/plain
160
161 This is part 1.
162
163 --_001_
164 Content-Type: text/plain; charset="UTF-8"
165
166 This is §2, with a non-ASCII character.
167
168 --_001_--
169 EOF
170
171 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
172 mhbuild "$actual"
173 check "$actual" "$expected"
174
175
176 # check message with text part in multipart/related
177 start_test 'check message with text part in multipart/related'
178 cat >"$expected" <<'EOF'
179 From: recipient@example.com
180 To: sender@example.com
181 cc:
182 Fcc: +outbox
183 Subject: Re: test with text part in multipart/related
184 Comments: In-reply-to sender@example.com
185 message dated "."
186 MIME-Version: 1.0
187 Content-Type: text/plain; charset="UTF-8"
188
189 sender@example.com writes:
190
191 > This is a test.
192 EOF
193
194 cat >`mhpath new` <<'EOF'
195 From: sender@example.com
196 To: recipient@example.com
197 Subject: test with text part in multipart/related
198 Content-Type: multipart/alternative; boundary="_001_"
199 MIME-Version: 1.0
200
201 --_001_
202 Content-Type: multipart/related; type="text/plain"; boundary="_002_"
203
204 --_002_
205 Content-Type: text/plain; charset="UTF-8"
206
207 This is a test.
208
209 --_002_--
210
211 --_001_--
212 EOF
213
214 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
215 mhbuild "$actual"
216 check "$actual" "$expected"
217
218
219 # check reply to calendar request
220 start_test 'check reply to calendar request'
221 cat >"$expected" <<'EOF'
222 From: recipient@example.com
223 To: sender@example.com
224 cc:
225 Fcc: +outbox
226 Subject: Re: test iCalendar reply
227 Comments: In-reply-to sender@example.com
228 message dated "."
229 MIME-Version: 1.0
230 Content-Type: text/calendar; method="REPLY"; charset="UTF-8"
231
232 BEGIN:VCALENDAR
233 METHOD:REPLY
234 PRODID:nmh mhical v0.1
235 VERSION:2.0
236 BEGIN:VTIMEZONE
237 TZID:Eastern Standard Time
238 BEGIN:STANDARD
239 DTSTART:16010101T020000
240 TZOFFSETFROM:-0400
241 TZOFFSETTO:-0500
242 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
243 END:STANDARD
244 BEGIN:DAYLIGHT
245 DTSTART:16010101T020000
246 TZOFFSETFROM:-0500
247 TZOFFSETTO:-0400
248 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
249 END:DAYLIGHT
250 END:VTIMEZONE
251 BEGIN:VEVENT
252 ORGANIZER;CN=Requester:MAILTO:requester@example.com
253 ATTENDEE;PARTSTAT=ACCEPTED;CN=Recip:MAILTO:recipient@example.com
254 SUMMARY;LANGUAGE=en-US:Accepted: test request
255 DTSTART;TZID=Eastern Standard Time:20150105T090000
256 DTEND;TZID=Eastern Standard Time:20150105T093000
257 UID:0123456789
258 CLASS:PUBLIC
259 PRIORITY:5
260 TRANSP:OPAQUE
261 STATUS:CONFIRMED
262 SEQUENCE:0
263 LOCATION;LANGUAGE=en-US:
264 END:VEVENT
265 END:VCALENDAR
266 EOF
267
268 cat >`mhpath new` <<'EOF'
269 From: sender@example.com
270 To: recipient@example.com
271 Subject: test iCalendar reply
272 Content-Type: text/calendar; charset="UTF-8"
273 MIME-Version: 1.0
274
275 BEGIN:VCALENDAR
276 METHOD:REQUEST
277 PRODID:test-convert
278 VERSION:2.0
279 BEGIN:VTIMEZONE
280 TZID:Eastern Standard Time
281 BEGIN:STANDARD
282 DTSTART:16010101T020000
283 TZOFFSETFROM:-0400
284 TZOFFSETTO:-0500
285 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
286 END:STANDARD
287 BEGIN:DAYLIGHT
288 DTSTART:16010101T020000
289 TZOFFSETFROM:-0500
290 TZOFFSETTO:-0400
291 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
292 END:DAYLIGHT
293 END:VTIMEZONE
294 BEGIN:VEVENT
295 ORGANIZER;CN=Requester:MAILTO:requester@example.com
296 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
297 :MAILTO:requestee1@example.com
298 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
299 :MAILTO:requestee2@example.com
300 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
301 :MAILTO:requestee3@example.com
302 SUMMARY;LANGUAGE=en-US:test request
303 DTSTART;TZID=Eastern Standard Time:20150105T090000
304 DTEND;TZID=Eastern Standard Time:20150105T093000
305 UID:0123456789
306 CLASS:PUBLIC
307 PRIORITY:5
308 DTSTAMP:20150101T171600Z
309 TRANSP:OPAQUE
310 STATUS:CONFIRMED
311 SEQUENCE:0
312 LOCATION;LANGUAGE=en-US:
313 BEGIN:VALARM
314 ACTION:DISPLAY
315 DESCRIPTION:REMINDER
316 TRIGGER;RELATED=START:-PT15M
317 END:VALARM
318 END:VEVENT
319 END:VCALENDAR
320 EOF
321
322 actual="$MH_TEST_DIR/test-convert$$.actual"
323 repl -noformat \
324 -convertargs text/calendar '-reply accept -contenttype' -nowhatnowproc last
325 SIGNATURE=Recip mhbuild - <`mhpath +`/draft | egrep -v '^DTSTAMP:' >"$actual"
326 check "$actual" "$expected"
327
328
329 finish_test
330 exit $failed