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