]> diplodocus.org Git - nmh/blob - test/repl/test-convert
For the autoconf/automake stuff to replace getline, the following
[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 en_US.utf-8 en_US.utf8
80
81
82 # check -convertarg with multiple parts, 7 bit
83 start_test '-convertarg with multiple parts, 7 bit'
84 cat >"$expected" <<'EOF'
85 From: recipient@example.com
86 To: sender@example.com
87 cc:
88 Fcc: +outbox
89 Subject: Re: test
90 Comments: In-reply-to sender@example.com
91 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
92 MIME-Version: 1.0
93 Content-Type: text/plain; charset="UTF-8"
94
95 sender@example.com writes:
96
97 > This is part 1.
98
99 > This is part 2.
100 EOF
101
102 cat >`mhpath new` <<'EOF'
103 From: sender@example.com
104 To: recipient@example.com
105 Subject: test
106 Date: Thu, 11 Dec 2014 08:19:02 -0600
107 Content-Type: multipart/mixed; boundary="_001_"
108 MIME-Version: 1.0
109
110 --_001_
111 Content-Type: text/plain
112
113 This is part 1.
114
115 --_001_
116 Content-Type: text/plain; charset="UTF-8"
117
118 This is part 2.
119
120 --_001_--
121 EOF
122
123 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
124 mhbuild "$actual"
125 check "$actual" "$expected"
126
127
128 # check -convertarg with multiple parts, 8 bit
129 start_test '-convertarg with multiple parts, 8 bit'
130 cat >"$expected" <<'EOF'
131 From: recipient@example.com
132 To: sender@example.com
133 cc:
134 Fcc: +outbox
135 Subject: Re: test
136 Comments: In-reply-to sender@example.com
137 message dated "Thu, 11 Dec 2014 08:19:02 -0600."
138 MIME-Version: 1.0
139 Content-Type: text/plain; charset="UTF-8"
140 Content-Transfer-Encoding: 8bit
141
142 sender@example.com writes:
143
144 > This is part 1.
145
146 > This is §2, with a non-ASCII character.
147 EOF
148
149 cat >`mhpath new` <<'EOF'
150 From: sender@example.com
151 To: recipient@example.com
152 Subject: test
153 Date: Thu, 11 Dec 2014 08:19:02 -0600
154 Content-Type: multipart/mixed; boundary="_001_"
155 MIME-Version: 1.0
156
157 --_001_
158 Content-Type: text/plain
159
160 This is part 1.
161
162 --_001_
163 Content-Type: text/plain; charset="UTF-8"
164
165 This is §2, with a non-ASCII character.
166
167 --_001_--
168 EOF
169
170 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
171 mhbuild "$actual"
172 check "$actual" "$expected"
173
174
175 # check message with text part in multipart/related
176 start_test 'check message with text part in multipart/related'
177 cat >"$expected" <<'EOF'
178 From: recipient@example.com
179 To: sender@example.com
180 cc:
181 Fcc: +outbox
182 Subject: Re: test with text part in multipart/related
183 Comments: In-reply-to sender@example.com
184 message dated "."
185 MIME-Version: 1.0
186 Content-Type: text/plain; charset="UTF-8"
187
188 sender@example.com writes:
189
190 > This is a test.
191 EOF
192
193 cat >`mhpath new` <<'EOF'
194 From: sender@example.com
195 To: recipient@example.com
196 Subject: test with text part in multipart/related
197 Content-Type: multipart/alternative; boundary="_001_"
198 MIME-Version: 1.0
199
200 --_001_
201 Content-Type: multipart/related; type="text/plain"; boundary="_002_"
202
203 --_002_
204 Content-Type: text/plain; charset="UTF-8"
205
206 This is a test.
207
208 --_002_--
209
210 --_001_--
211 EOF
212
213 repl -filter mhl.replywithoutbody -convertarg text/plain '' -nowhatnowproc last
214 mhbuild "$actual"
215 check "$actual" "$expected"
216
217
218 # check reply to calendar request
219 start_test 'check reply to calendar request'
220 cat >"$expected" <<'EOF'
221 From: recipient@example.com
222 To: sender@example.com
223 cc:
224 Fcc: +outbox
225 Subject: Re: test iCalendar reply
226 Comments: In-reply-to sender@example.com
227 message dated "."
228 MIME-Version: 1.0
229 Content-Type: text/calendar; method="REPLY"; charset="UTF-8"
230
231 BEGIN:VCALENDAR
232 METHOD:REPLY
233 PRODID:nmh mhical v0.1
234 VERSION:2.0
235 BEGIN:VTIMEZONE
236 TZID:Eastern Standard Time
237 BEGIN:STANDARD
238 DTSTART:16010101T020000
239 TZOFFSETFROM:-0400
240 TZOFFSETTO:-0500
241 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
242 END:STANDARD
243 BEGIN:DAYLIGHT
244 DTSTART:16010101T020000
245 TZOFFSETFROM:-0500
246 TZOFFSETTO:-0400
247 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
248 END:DAYLIGHT
249 END:VTIMEZONE
250 BEGIN:VEVENT
251 ORGANIZER;CN=Requester:MAILTO:requester@example.com
252 ATTENDEE;PARTSTAT=ACCEPTED;CN=Recip:MAILTO:recipient@example.com
253 SUMMARY;LANGUAGE=en-US:Accepted: test request
254 DTSTART;TZID=Eastern Standard Time:20150105T090000
255 DTEND;TZID=Eastern Standard Time:20150105T093000
256 UID:0123456789
257 CLASS:PUBLIC
258 PRIORITY:5
259 TRANSP:OPAQUE
260 STATUS:CONFIRMED
261 SEQUENCE:0
262 LOCATION;LANGUAGE=en-US:
263 END:VEVENT
264 END:VCALENDAR
265 EOF
266
267 cat >`mhpath new` <<'EOF'
268 From: sender@example.com
269 To: recipient@example.com
270 Subject: test iCalendar reply
271 Content-Type: text/calendar; charset="UTF-8"
272 MIME-Version: 1.0
273
274 BEGIN:VCALENDAR
275 METHOD:REQUEST
276 PRODID:test-convert
277 VERSION:2.0
278 BEGIN:VTIMEZONE
279 TZID:Eastern Standard Time
280 BEGIN:STANDARD
281 DTSTART:16010101T020000
282 TZOFFSETFROM:-0400
283 TZOFFSETTO:-0500
284 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
285 END:STANDARD
286 BEGIN:DAYLIGHT
287 DTSTART:16010101T020000
288 TZOFFSETFROM:-0500
289 TZOFFSETTO:-0400
290 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
291 END:DAYLIGHT
292 END:VTIMEZONE
293 BEGIN:VEVENT
294 ORGANIZER;CN=Requester:MAILTO:requester@example.com
295 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
296 :MAILTO:requestee1@example.com
297 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
298 :MAILTO:requestee2@example.com
299 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
300 :MAILTO:requestee3@example.com
301 SUMMARY;LANGUAGE=en-US:test request
302 DTSTART;TZID=Eastern Standard Time:20150105T090000
303 DTEND;TZID=Eastern Standard Time:20150105T093000
304 UID:0123456789
305 CLASS:PUBLIC
306 PRIORITY:5
307 DTSTAMP:20150101T171600Z
308 TRANSP:OPAQUE
309 STATUS:CONFIRMED
310 SEQUENCE:0
311 LOCATION;LANGUAGE=en-US:
312 BEGIN:VALARM
313 ACTION:DISPLAY
314 DESCRIPTION:REMINDER
315 TRIGGER;RELATED=START:-PT15M
316 END:VALARM
317 END:VEVENT
318 END:VCALENDAR
319 EOF
320
321 actual="$MH_TEST_DIR/test-convert$$.actual"
322 repl -noformat \
323 -convertargs text/calendar '-reply accept -contenttype' -nowhatnowproc last
324 SIGNATURE=Recip mhbuild - <`mhpath +`/draft | egrep -v '^DTSTAMP:' >"$actual"
325 check "$actual" "$expected"
326
327
328 finish_test
329 exit $failed