]> diplodocus.org Git - nmh/blob - test/mhical/test-mhical
Removed redundant initialization of local variable tls.
[nmh] / test / mhical / test-mhical
1 #!/bin/sh
2 ######################################################
3 #
4 # Test mhical
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 . "${MH_OBJ_DIR}/test/common.sh"
16
17 setup_test
18
19 check_exit '-eq 1' mhical -
20
21 #### Make sure that html-to-text conversion is what we expect.
22 require_locale en_US.UTF-8 en_US.UTF8 en_US.utf-8 en_US.utf8
23
24 #### Disable colorized output.
25 TERM=dumb; export TERM
26
27 expected="$MH_TEST_DIR/test-mhical$$.expected"
28 expected_err="$MH_TEST_DIR/test-mhical$$.expected_err"
29 actual="$MH_TEST_DIR/test-mhical$$.actual"
30 actual_err="$MH_TEST_DIR/test-mhical$$.actual_err"
31
32
33 # check -help
34 start_test "-help"
35 cat >"$expected" <<EOF
36 Usage: mhical [switches]
37 switches are:
38 -reply accept|decline|tentative
39 -cancel
40 -form formatfile
41 -(forma)t string
42 -infile
43 -outfile
44 -attendee
45 -[no]contenttype
46 -unfold
47 -debug
48 -version
49 -help
50 EOF
51
52 #### Skip nmh intro text.
53 run_prog mhical -help 2>&1 | sed '/^$/,$d' >"$actual"
54 check "$expected" "$actual"
55
56
57 # check -version
58 start_test "-version"
59 case `mhical -version` in
60 mhical\ --*) ;;
61 *) printf '%s: mhical -version generated unexpected output\n' "$0" >&2
62 failed=`expr ${failed:-0} + 1`;;
63 esac
64
65
66 # check display with timezone that only has standard time
67 start_test "display with timezone that only has standard time"
68 cat >"$expected" <<'EOF'
69 Summary: Santa Watch
70 Description: See Santa here first!
71 At: Wed, 24 Dec 2014 12:00 +0000
72 To: Fri, 25 Dec 2015 11:59
73 EOF
74
75 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
76 BEGIN:VCALENDAR
77 VERSION:2.0
78 PRODID:test-mhical
79
80 BEGIN:VTIMEZONE
81 TZID:MHT-12
82 BEGIN:STANDARD
83 DTSTART:16010101T020000
84 TZOFFSETFROM:+1200
85 TZOFFSETTO:+1200
86 END:STANDARD
87 END:VTIMEZONE
88
89 BEGIN:VEVENT
90 DTSTAMP:20141224T140426Z
91 DTSTART;TZID=MHT-12:20141225T000000
92 DTEND;TZID=MHT-12:20151225T235959
93 SUMMARY:Santa Watch
94 DESCRIPTION: See Santa here first!
95 END:VEVENT
96
97 END:VCALENDAR
98 EOF
99
100 TZ=UTC mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
101 check "$expected" "$MH_TEST_DIR/test1.txt"
102
103
104 # check display with 24 hour time format and -outfile
105 start_test "display with 24 hour time format and -outfile"
106 cat >"$expected" <<'EOF'
107 Summary: 4 pm meeting
108 At: Mon, 05 Jan 2015 16:00
109 To: Mon, 05 Jan 2015 16:30
110 EOF
111
112 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
113 BEGIN:VCALENDAR
114 VERSION:2.0
115 PRODID:test-mhical
116
117 BEGIN:VEVENT
118 DTSTAMP:20150101T162400Z
119 DTSTART:20150105T160000
120 DTEND:20150105T163000
121 SUMMARY:4 pm meeting
122 END:VEVENT
123
124 END:VCALENDAR
125 EOF
126
127 mhical -outfile "$MH_TEST_DIR/test1.txt" <"$MH_TEST_DIR/test1.ics"
128 check "$expected" "$MH_TEST_DIR/test1.txt"
129
130
131 # check display with 12 hour time format and -infile
132 start_test "display with 12 hour time format and -infile"
133 cat >"$expected" <<'EOF'
134 Summary: 4 pm meeting
135 At: Mon, 05 Jan 2015 4:00 PM
136 To: Mon, 05 Jan 2015 4:30 PM
137 EOF
138
139 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
140 BEGIN:VCALENDAR
141 VERSION:2.0
142 PRODID:test-mhical
143
144 BEGIN:VEVENT
145 DTSTAMP:20150101T162800Z
146 DTSTART:20150105T160000
147 DTEND:20150105T163000
148 SUMMARY:4 pm meeting
149 END:VEVENT
150
151 END:VCALENDAR
152 EOF
153
154 mhical -form mhical.12hour -infile "$MH_TEST_DIR/test1.ics" \
155 >"$MH_TEST_DIR/test1.txt"
156 check "$expected" "$MH_TEST_DIR/test1.txt"
157
158
159 # check display with DST
160 start_test "display with DST"
161 cat >"$expected" <<'EOF'
162 Method: REQUEST
163 Organizer: Requester
164 Summary: Big Meeting
165 Location: The Office
166 At: Mon, 05 Jan 2015 08:00 -0500
167 To: Mon, 05 Jan 2015 09:00
168 Attendees: Requestee
169 EOF
170
171 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
172 BEGIN:VCALENDAR
173 METHOD:REQUEST
174 PRODID:Microsoft Exchange Server 2010
175 VERSION:2.0
176 BEGIN:VTIMEZONE
177 TZID:Eastern Standard Time
178 BEGIN:STANDARD
179 DTSTART:16010101T020000
180 TZOFFSETFROM:-0400
181 TZOFFSETTO:-0500
182 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
183 END:STANDARD
184 BEGIN:DAYLIGHT
185 DTSTART:16010101T020000
186 TZOFFSETFROM:-0500
187 TZOFFSETTO:-0400
188 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
189 END:DAYLIGHT
190 END:VTIMEZONE
191 BEGIN:VEVENT
192 ORGANIZER;CN=Requester:MAILTO:requester@example.com
193 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=FALSE;CN=Requestee
194 :MAILTO:requestee@example.com
195 DESCRIPTION;LANGUAGE=en-US:\n\n
196 SUMMARY;LANGUAGE=en-US:Big Meeting
197 DTSTART;TZID=Eastern Standard Time:20150105T080000
198 DTEND;TZID=Eastern Standard Time:20150105T090000
199 UID:0123456789
200 CLASS:PUBLIC
201 PRIORITY:5
202 DTSTAMP:20141231T235959Z
203 TRANSP:OPAQUE
204 STATUS:CONFIRMED
205 SEQUENCE:0
206 LOCATION;LANGUAGE=en-US:The Office
207 X-MICROSOFT-CDO-APPT-SEQUENCE:0
208 X-MICROSOFT-CDO-OWNERAPPTID:-0123456789
209 X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE
210 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
211 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
212 X-MICROSOFT-CDO-IMPORTANCE:1
213 X-MICROSOFT-CDO-INSTTYPE:0
214 X-MICROSOFT-DISALLOW-COUNTER:FALSE
215 BEGIN:VALARM
216 ACTION:DISPLAY
217 DESCRIPTION:REMINDER
218 TRIGGER;RELATED=START:-PT15M
219 END:VALARM
220 END:VEVENT
221 END:VCALENDAR
222 EOF
223
224 TZ=EST mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
225 check "$expected" "$MH_TEST_DIR/test1.txt"
226
227
228 # check timezone boundary at transition to daylight saving time
229 start_test "timezone boundary at transition to daylight saving time"
230 # The default mhical display format doesn't show the timezone for the
231 # To: time, but it is different than that of the At: time.
232 cat >"$expected" <<'EOF'
233 Summary: EST to EDT
234 At: Sun, 09 Mar 2014 01:59 -0500
235 To: Sun, 09 Mar 2014 03:30
236 EOF
237
238 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
239 BEGIN:VCALENDAR
240 VERSION:2.0
241 PRODID:test-mhical
242 BEGIN:VTIMEZONE
243 TZID:Eastern Standard Time
244 BEGIN:STANDARD
245 DTSTART:16010101T020000
246 TZOFFSETFROM:-0400
247 TZOFFSETTO:-0500
248 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
249 END:STANDARD
250 BEGIN:DAYLIGHT
251 DTSTART:16010101T020000
252 TZOFFSETFROM:-0500
253 TZOFFSETTO:-0400
254 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
255 END:DAYLIGHT
256 END:VTIMEZONE
257 BEGIN:VEVENT
258 DTSTAMP:20150101T000000Z
259 DTSTART;TZID=Eastern Standard Time:20140309T015959
260 DTEND;TZID=Eastern Standard Time:20140309T023000
261 Summary: EST to EDT
262 END:VEVENT
263 END:VCALENDAR
264 EOF
265
266 TZ=EST5EDT mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
267 check "$expected" "$MH_TEST_DIR/test1.txt"
268
269
270 # check -format, and that timezone is correct in end time
271 start_test "-format, and that timezone is correct in end time"
272 cat >"$expected" <<'EOF'
273 Sun, 09 Mar 2014 03:30:00 -0400
274 EOF
275
276 TZ=EST5EDT mhical -format '%(pretty{dtend})' \
277 -infile "$MH_TEST_DIR/test1.ics" -outfile "$MH_TEST_DIR/test1.txt"
278 check "$expected" "$MH_TEST_DIR/test1.txt"
279
280
281 # check timezone boundary at transition from daylight saving time
282 start_test "timezone boundary at transition from daylight saving time"
283 cat >"$expected" <<'EOF'
284 Summary: EDT to EST
285 At: Sun, 02 Nov 2014 01:59 -0400
286 To: Sun, 02 Nov 2014 02:00
287 EOF
288
289 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
290 BEGIN:VCALENDAR
291 VERSION:2.0
292 PRODID:test-mhical
293 BEGIN:VTIMEZONE
294 TZID:Eastern Standard Time
295 BEGIN:STANDARD
296 DTSTART:16010101T020000
297 TZOFFSETFROM:-0400
298 TZOFFSETTO:-0500
299 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
300 END:STANDARD
301 BEGIN:DAYLIGHT
302 DTSTART:16010101T020000
303 TZOFFSETFROM:-0500
304 TZOFFSETTO:-0400
305 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
306 END:DAYLIGHT
307 END:VTIMEZONE
308 BEGIN:VEVENT
309 DTSTAMP:20150101T000000Z
310 DTSTART;TZID=Eastern Standard Time:20141102T015959
311 DTEND;TZID=Eastern Standard Time:20141102T020000
312 Summary: EDT to EST
313 END:VEVENT
314 END:VCALENDAR
315 EOF
316
317 TZ=EST5EDT mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
318 check "$expected" "$MH_TEST_DIR/test1.txt"
319
320
321 # check -format, and that timezone is correct in end time
322 start_test "-format, and that timezone is correct in end time"
323 cat >"$expected" <<'EOF'
324 Sun, 02 Nov 2014 02:00:00 -0500
325 EOF
326
327 TZ=EST5EDT mhical -format '%(pretty{dtend})' \
328 -infile "$MH_TEST_DIR/test1.ics" -outfile "$MH_TEST_DIR/test1.txt"
329 check "$expected" "$MH_TEST_DIR/test1.txt"
330
331
332 printf 'Local-Mailbox: Requestee2 <requestee2@example.com>\n' >> "$MH"
333
334 # check accept of request
335 start_test "accept of request"
336 cat >"$expected" <<'EOF'
337 BEGIN:VCALENDAR
338 METHOD:REPLY
339 PRODID:nmh mhical v0.5
340 VERSION:2.0
341 BEGIN:VTIMEZONE
342 TZID:Eastern Standard Time
343 BEGIN:STANDARD
344 DTSTART:16010101T020000
345 TZOFFSETFROM:-0400
346 TZOFFSETTO:-0500
347 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
348 END:STANDARD
349 BEGIN:DAYLIGHT
350 DTSTART:16010101T020000
351 TZOFFSETFROM:-0500
352 TZOFFSETTO:-0400
353 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
354 END:DAYLIGHT
355 END:VTIMEZONE
356 BEGIN:VEVENT
357 ORGANIZER;CN=Requester:MAILTO:requester@example.com
358 ATTENDEE;PARTSTAT=ACCEPTED;CN=Requestee2:MAILTO:requestee2@example.com
359 SUMMARY;LANGUAGE=en-US:Accepted: test request
360 DTSTART;TZID=Eastern Standard Time:20150105T090000
361 DTEND;TZID=Eastern Standard Time:20150105T093000
362 UID:0123456789
363 CLASS:PUBLIC
364 PRIORITY:5
365 TRANSP:OPAQUE
366 STATUS:CONFIRMED
367 SEQUENCE:0
368 LOCATION;LANGUAGE=en-US:
369 END:VEVENT
370 END:VCALENDAR
371 EOF
372
373 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
374 BEGIN:VCALENDAR
375 METHOD:REQUEST
376 PRODID:test-mhical
377 VERSION:2.0
378 BEGIN:VTIMEZONE
379 TZID:Eastern Standard Time
380 BEGIN:STANDARD
381 DTSTART:16010101T020000
382 TZOFFSETFROM:-0400
383 TZOFFSETTO:-0500
384 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
385 END:STANDARD
386 BEGIN:DAYLIGHT
387 DTSTART:16010101T020000
388 TZOFFSETFROM:-0500
389 TZOFFSETTO:-0400
390 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
391 END:DAYLIGHT
392 END:VTIMEZONE
393 BEGIN:VEVENT
394 ORGANIZER;CN=Requester:MAILTO:requester@example.com
395 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
396 :MAILTO:requestee1@example.com
397 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
398 :MAILTO:requestee2@example.com
399 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
400 :MAILTO:requestee3@example.com
401 SUMMARY;LANGUAGE=en-US:test request
402 DTSTART;TZID=Eastern Standard Time:20150105T090000
403 DTEND;TZID=Eastern Standard Time:20150105T093000
404 UID:0123456789
405 CLASS:PUBLIC
406 PRIORITY:5
407 DTSTAMP:20150101T171600Z
408 TRANSP:OPAQUE
409 STATUS:CONFIRMED
410 SEQUENCE:0
411 LOCATION;LANGUAGE=en-US:
412 BEGIN:VALARM
413 ACTION:DISPLAY
414 DESCRIPTION:REMINDER
415 TRIGGER;RELATED=START:-PT15M
416 END:VALARM
417 END:VEVENT
418 END:VCALENDAR
419 EOF
420
421 mhical -reply accept <"$MH_TEST_DIR/test1.ics" | egrep -v '^DTSTAMP:' \
422 >"$MH_TEST_DIR/test1.txt"
423 check "$expected" "$MH_TEST_DIR/test1.txt"
424
425
426 # check accept of request with -attendee
427 start_test "accept of request with -attendee"
428 cat >"$expected" <<'EOF'
429 BEGIN:VCALENDAR
430 METHOD:REPLY
431 PRODID:nmh mhical v0.5
432 VERSION:2.0
433 BEGIN:VTIMEZONE
434 TZID:Eastern Standard Time
435 BEGIN:STANDARD
436 DTSTART:16010101T020000
437 TZOFFSETFROM:-0400
438 TZOFFSETTO:-0500
439 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
440 END:STANDARD
441 BEGIN:DAYLIGHT
442 DTSTART:16010101T020000
443 TZOFFSETFROM:-0500
444 TZOFFSETTO:-0400
445 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
446 END:DAYLIGHT
447 END:VTIMEZONE
448 BEGIN:VEVENT
449 ORGANIZER;CN=Requester:MAILTO:requester@example.com
450 ATTENDEE;PARTSTAT=ACCEPTED;CN=Requestee1:MAILTO:requestee1@example.com
451 SUMMARY;LANGUAGE=en-US:Accepted: test request
452 DTSTART;TZID=Eastern Standard Time:20150105T090000
453 DTEND;TZID=Eastern Standard Time:20150105T093000
454 UID:0123456789
455 CLASS:PUBLIC
456 PRIORITY:5
457 TRANSP:OPAQUE
458 STATUS:CONFIRMED
459 SEQUENCE:0
460 LOCATION;LANGUAGE=en-US:
461 END:VEVENT
462 END:VCALENDAR
463 EOF
464
465 cp "$MH" "${MH}.save"
466 printf 'Alternate-Mailboxes: RequesteeToo <requestee1@example.com>\n' >> "$MH"
467 mhical -reply accept -attendee requestee1@example.com <"$MH_TEST_DIR/test1.ics" \
468 | egrep -v '^DTSTAMP:' >"$MH_TEST_DIR/test1.txt"
469 check "$expected" "$MH_TEST_DIR/test1.txt"
470
471
472 # check accept of request with other -attendee
473 start_test "accept of request with other -attendee"
474 cat >"$expected" <<'EOF'
475 BEGIN:VCALENDAR
476 METHOD:REPLY
477 PRODID:nmh mhical v0.5
478 VERSION:2.0
479 BEGIN:VTIMEZONE
480 TZID:Eastern Standard Time
481 BEGIN:STANDARD
482 DTSTART:16010101T020000
483 TZOFFSETFROM:-0400
484 TZOFFSETTO:-0500
485 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
486 END:STANDARD
487 BEGIN:DAYLIGHT
488 DTSTART:16010101T020000
489 TZOFFSETFROM:-0500
490 TZOFFSETTO:-0400
491 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
492 END:DAYLIGHT
493 END:VTIMEZONE
494 BEGIN:VEVENT
495 ORGANIZER;CN=Requester:MAILTO:requester@example.com
496 ATTENDEE;PARTSTAT=ACCEPTED;CN=Requestee2:MAILTO:requestee2@example.com
497 SUMMARY;LANGUAGE=en-US:Accepted: test request
498 DTSTART;TZID=Eastern Standard Time:20150105T090000
499 DTEND;TZID=Eastern Standard Time:20150105T093000
500 UID:0123456789
501 CLASS:PUBLIC
502 PRIORITY:5
503 TRANSP:OPAQUE
504 STATUS:CONFIRMED
505 SEQUENCE:0
506 LOCATION;LANGUAGE=en-US:
507 END:VEVENT
508 END:VCALENDAR
509 EOF
510
511 mhical -reply accept -attendee requestee2@example.com <"$MH_TEST_DIR/test1.ics" \
512 | egrep -v '^DTSTAMP:' >"$MH_TEST_DIR/test1.txt"
513 check "$expected" "$MH_TEST_DIR/test1.txt"
514
515
516 # check accept of request without required -attendee
517 start_test "accept of request without required -attendee"
518 cat >"$expected" <<'EOF'
519 mhical: Multiple attendees match your address, re-run with -attendee switch
520 EOF
521
522 mhical -reply accept <"$MH_TEST_DIR/test1.ics" 2>"$MH_TEST_DIR/test1.txt" \
523 && false
524 check "$expected" "$MH_TEST_DIR/test1.txt"
525 mv "${MH}.save" "$MH"
526
527
528 # check accept of multiple vevent requests in single vcalendar
529 start_test "accept of multiple vevent requests in single vcalendar"
530 cat >"$expected" <<'EOF'
531 BEGIN:VCALENDAR
532 METHOD:REPLY
533 PRODID:nmh mhical v0.5
534 VERSION:2.0
535 BEGIN:VTIMEZONE
536 TZID:Eastern Standard Time
537 BEGIN:STANDARD
538 DTSTART:16010101T020000
539 TZOFFSETFROM:-0400
540 TZOFFSETTO:-0500
541 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
542 END:STANDARD
543 BEGIN:DAYLIGHT
544 DTSTART:16010101T020000
545 TZOFFSETFROM:-0500
546 TZOFFSETTO:-0400
547 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
548 END:DAYLIGHT
549 END:VTIMEZONE
550 BEGIN:VEVENT
551 ORGANIZER;CN=Requester:MAILTO:requester@example.com
552 ATTENDEE;PARTSTAT=ACCEPTED;CN=Requestee2:MAILTO:requestee2@example.com
553 SUMMARY;LANGUAGE=en-US:Accepted: test request
554 DTSTART;TZID=Eastern Standard Time:20150105T090000
555 DTEND;TZID=Eastern Standard Time:20150105T093000
556 UID:0123456790
557 CLASS:PUBLIC
558 PRIORITY:5
559 TRANSP:OPAQUE
560 STATUS:CONFIRMED
561 SEQUENCE:0
562 LOCATION;LANGUAGE=en-US:
563 END:VEVENT
564
565 BEGIN:VEVENT
566 ORGANIZER;CN=Requester:MAILTO:requester@example.com
567 ATTENDEE;PARTSTAT=ACCEPTED;CN=Requestee2:MAILTO:requestee2@example.com
568 SUMMARY;LANGUAGE=en-US:Accepted: test request
569 DTSTART;TZID=Eastern Standard Time:20150105T130000
570 DTEND;TZID=Eastern Standard Time:20150105T134500
571 UID:0123456791
572 CLASS:PUBLIC
573 PRIORITY:5
574 TRANSP:OPAQUE
575 STATUS:CONFIRMED
576 SEQUENCE:0
577 LOCATION;LANGUAGE=en-US:
578 END:VEVENT
579 END:VCALENDAR
580 EOF
581
582 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
583 BEGIN:VCALENDAR
584 METHOD:REQUEST
585 PRODID:test-mhical
586 VERSION:2.0
587
588 BEGIN:VTIMEZONE
589 TZID:Eastern Standard Time
590 BEGIN:STANDARD
591 DTSTART:16010101T020000
592 TZOFFSETFROM:-0400
593 TZOFFSETTO:-0500
594 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
595 END:STANDARD
596 BEGIN:DAYLIGHT
597 DTSTART:16010101T020000
598 TZOFFSETFROM:-0500
599 TZOFFSETTO:-0400
600 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
601 END:DAYLIGHT
602 END:VTIMEZONE
603
604 BEGIN:VEVENT
605 ORGANIZER;CN=Requester:MAILTO:requester@example.com
606 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
607 :MAILTO:requestee1@example.com
608 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
609 :MAILTO:requestee2@example.com
610 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
611 :MAILTO:requestee3@example.com
612 SUMMARY;LANGUAGE=en-US:test request
613 DTSTART;TZID=Eastern Standard Time:20150105T090000
614 DTEND;TZID=Eastern Standard Time:20150105T093000
615 UID:0123456790
616 CLASS:PUBLIC
617 PRIORITY:5
618 DTSTAMP:20150101T171600Z
619 TRANSP:OPAQUE
620 STATUS:CONFIRMED
621 SEQUENCE:0
622 LOCATION;LANGUAGE=en-US:
623 BEGIN:VALARM
624 ACTION:DISPLAY
625 DESCRIPTION:REMINDER
626 TRIGGER;RELATED=START:-PT15M
627 END:VALARM
628 END:VEVENT
629
630 BEGIN:VEVENT
631 ORGANIZER;CN=Requester:MAILTO:requester@example.com
632 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
633 :MAILTO:requestee2@example.com
634 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
635 :MAILTO:requestee3@example.com
636 SUMMARY;LANGUAGE=en-US:test request
637 DTSTART;TZID=Eastern Standard Time:20150105T130000
638 DTEND;TZID=Eastern Standard Time:20150105T134500
639 UID:0123456791
640 CLASS:PUBLIC
641 PRIORITY:5
642 DTSTAMP:20150101T171600Z
643 TRANSP:OPAQUE
644 STATUS:CONFIRMED
645 SEQUENCE:0
646 LOCATION;LANGUAGE=en-US:
647 BEGIN:VALARM
648 ACTION:DISPLAY
649 DESCRIPTION:REMINDER
650 TRIGGER;RELATED=START:-PT15M
651 END:VALARM
652 END:VEVENT
653
654 END:VCALENDAR
655 EOF
656
657 mhical -reply accept <"$MH_TEST_DIR/test1.ics" | egrep -v '^DTSTAMP:' \
658 >"$MH_TEST_DIR/test1.txt"
659 check "$expected" "$MH_TEST_DIR/test1.txt"
660
661
662 # check decline of request
663 start_test "decline of request"
664 cat >"$expected" <<'EOF'
665 BEGIN:VCALENDAR
666 METHOD:REPLY
667 PRODID:nmh mhical v0.5
668 VERSION:2.0
669 BEGIN:VEVENT
670 ORGANIZER;CN=Requester:MAILTO:requester@example.com
671 ATTENDEE;PARTSTAT=DECLINED;CN=Requestee2:MAILTO:requestee2@example.com
672 SUMMARY;LANGUAGE=en-US:Declined: test request
673 DTSTART:20150105T090000
674 DTEND:20150105T093000
675 UID:0123456789
676 CLASS:PUBLIC
677 PRIORITY:5
678 TRANSP:OPAQUE
679 STATUS:CONFIRMED
680 SEQUENCE:0
681 LOCATION;LANGUAGE=en-US:
682 END:VEVENT
683 END:VCALENDAR
684 EOF
685
686 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
687 BEGIN:VCALENDAR
688 METHOD:REQUEST
689 PRODID:test-mhical
690 VERSION:2.0
691 BEGIN:VEVENT
692 ORGANIZER;CN=Requester:MAILTO:requester@example.com
693 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
694 :MAILTO:requestee1@example.com
695 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
696 :MAILTO:requestee2@example.com
697 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
698 :MAILTO:requestee3@example.com
699 SUMMARY;LANGUAGE=en-US:test request
700 DTSTART:20150105T090000
701 DTEND:20150105T093000
702 UID:0123456789
703 CLASS:PUBLIC
704 PRIORITY:5
705 DTSTAMP:20150101T171600Z
706 TRANSP:OPAQUE
707 STATUS:CONFIRMED
708 SEQUENCE:0
709 LOCATION;LANGUAGE=en-US:
710 BEGIN:VALARM
711 ACTION:DISPLAY
712 DESCRIPTION:REMINDER
713 TRIGGER;RELATED=START:-PT15M
714 END:VALARM
715 END:VEVENT
716 END:VCALENDAR
717 EOF
718
719 mhical -reply decline <"$MH_TEST_DIR/test1.ics" | egrep -v '^DTSTAMP:' \
720 >"$MH_TEST_DIR/test1.txt"
721 check "$expected" "$MH_TEST_DIR/test1.txt"
722
723
724 # check response of tentative to request, and -nocontenttype
725 start_test "response of tentative to request, and -nocontenttype"
726 cat >"$expected" <<'EOF'
727 BEGIN:VCALENDAR
728 METHOD:REPLY
729 PRODID:nmh mhical v0.5
730 VERSION:2.0
731 BEGIN:VEVENT
732 ORGANIZER;CN=Requester:MAILTO:requester@example.com
733 ATTENDEE;PARTSTAT=TENTATIVE;CN=Requestee2:MAILTO:requestee2@example.com
734 SUMMARY;LANGUAGE=en-US:Tentative: test request
735 DTSTART:20150105T090000
736 DTEND:20150105T093000
737 UID:0123456789
738 CLASS:PUBLIC
739 PRIORITY:5
740 TRANSP:OPAQUE
741 STATUS:CONFIRMED
742 SEQUENCE:0
743 LOCATION;LANGUAGE=en-US:
744 END:VEVENT
745 END:VCALENDAR
746 EOF
747
748 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
749 BEGIN:VCALENDAR
750 METHOD:REQUEST
751 PRODID:test-mhical
752 VERSION:2.0
753 BEGIN:VEVENT
754 ORGANIZER;CN=Requester:MAILTO:requester@example.com
755 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
756 :MAILTO:requestee1@example.com
757 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
758 :MAILTO:requestee2@example.com
759 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
760 :MAILTO:requestee3@example.com
761 SUMMARY;LANGUAGE=en-US:test request
762 DTSTART:20150105T090000
763 DTEND:20150105T093000
764 UID:0123456789
765 CLASS:PUBLIC
766 PRIORITY:5
767 DTSTAMP:20150101T171600Z
768 TRANSP:OPAQUE
769 STATUS:CONFIRMED
770 SEQUENCE:0
771 LOCATION;LANGUAGE=en-US:
772 BEGIN:VALARM
773 ACTION:DISPLAY
774 DESCRIPTION:REMINDER
775 TRIGGER;RELATED=START:-PT15M
776 END:VALARM
777 END:VEVENT
778 END:VCALENDAR
779 EOF
780
781 mhical -reply tentative -contenttype -nocontenttype \
782 -infile "$MH_TEST_DIR/test1.ics" | egrep -v '^DTSTAMP:' \
783 >"$MH_TEST_DIR/test1.txt"
784 check "$expected" "$MH_TEST_DIR/test1.txt"
785
786
787 # check cancel request, and -contenttype
788 start_test "cancel request, and -contenttype"
789 cat >"$expected" <<'EOF'
790 Content-Type: text/calendar; method="CANCEL"; charset="UTF-8"
791
792 BEGIN:VCALENDAR
793 METHOD:CANCEL
794 PRODID:nmh mhical v0.5
795 VERSION:2.0
796 BEGIN:VEVENT
797 ORGANIZER;CN=Requestee2:MAILTO:requestee2@example.com
798 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
799 :MAILTO:requestee1@example.com
800 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
801 :MAILTO:requestee3@example.com
802 SUMMARY;LANGUAGE=en-US:Cancelled:test request
803 DTSTART:20150105T090000
804 DTEND:20150105T093000
805 UID:0123456789
806 CLASS:PUBLIC
807 PRIORITY:5
808 TRANSP:OPAQUE
809 STATUS:CANCELLED
810 SEQUENCE:1
811 LOCATION;LANGUAGE=en-US:
812 END:VEVENT
813 END:VCALENDAR
814 EOF
815
816 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
817 BEGIN:VCALENDAR
818 METHOD:REQUEST
819 PRODID:test-mhical
820 VERSION:2.0
821 BEGIN:VEVENT
822 ORGANIZER;CN=Requestee2:MAILTO:requestee2@example.com
823 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
824 :MAILTO:requestee1@example.com
825 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
826 :MAILTO:requestee3@example.com
827 SUMMARY;LANGUAGE=en-US:test request
828 DTSTART:20150105T090000
829 DTEND:20150105T093000
830 UID:0123456789
831 CLASS:PUBLIC
832 PRIORITY:5
833 DTSTAMP:20150101T171600Z
834 TRANSP:OPAQUE
835 STATUS:CONFIRMED
836 SEQUENCE:0
837 LOCATION;LANGUAGE=en-US:
838 BEGIN:VALARM
839 ACTION:DISPLAY
840 DESCRIPTION:REMINDER
841 TRIGGER;RELATED=START:-PT15M
842 END:VALARM
843 END:VEVENT
844 END:VCALENDAR
845 EOF
846
847 mhical -cancel -contenttype <"$MH_TEST_DIR/test1.ics" | egrep -v '^DTSTAMP:' \
848 >"$MH_TEST_DIR/test1.txt"
849 check "$expected" "$MH_TEST_DIR/test1.txt"
850
851
852 # Check TZID name wrapped with quotes, this used to cause a segfault.
853 start_test "TZID name wrapped with quotes, this used to cause a segfault."
854 cat >"$expected" <<'EOF'
855 Method: REQUEST
856 Summary: Quoted timezone ID
857 At: Wed, 01 Jan 2014 00:00
858 To: Wed, 01 Jan 2014 01:00
859 EOF
860
861 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
862 BEGIN:VCALENDAR
863 PRODID:Zimbra-Calendar-Provider
864 VERSION:2.0
865 METHOD:REQUEST
866 SUMMARY:Quoted timezone ID
867 BEGIN:VTIMEZONE
868 TZID:Etc/GMT
869 BEGIN:STANDARD
870 DTSTART:19710101T000000
871 TZOFFSETTO:-0000
872 TZOFFSETFROM:-0000
873 TZNAME:GMT
874 END:STANDARD
875 END:VTIMEZONE
876 BEGIN:VEVENT
877 DTSTART:20140101T000000
878 DTEND;TZID="Etc/GMT":20140101T010000
879 SEQUENCE:0
880 END:VEVENT
881 END:VCALENDAR
882 EOF
883
884 TZ=UTC mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
885 check "$expected" "$MH_TEST_DIR/test1.txt"
886
887
888 # Check start datetime without a time, and missing end datetime.
889 start_test "start datetime without a time, and missing end datetime."
890 cat >"$expected" <<'EOF'
891 Method: PUBLISH
892 Summary: Test datetime without time
893 At: Wed, 30 Dec 2015 00:00
894 To: Wed, 30 Dec 2015 23:59
895 EOF
896
897 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
898 BEGIN:VCALENDAR
899 VERSION:2.0
900 PRODID:icalendar-ruby
901 CALSCALE:GREGORIAN
902 METHOD:PUBLISH
903 BEGIN:VEVENT
904 DTSTAMP:20151208T204350Z
905 UID:0123456789
906 DTSTART;VALUE=DATE:20151230
907 CLASS:PRIVATE
908 SUMMARY:Test datetime without time
909 BEGIN:VALARM
910 ACTION:DISPLAY
911 DESCRIPTION:REMINDER
912 TRIGGER;RELATED=START:-PT15M
913 END:VALARM
914 END:VEVENT
915 END:VCALENDAR
916 EOF
917
918 TZ=UTC mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
919 check "$expected" "$MH_TEST_DIR/test1.txt"
920 rm -f "$MH_TEST_DIR/test1.ics"
921
922
923 # check missing final newline
924 start_test "missing final newline"
925
926 cat >"$expected" <<'EOF'
927 Summary: test
928 Description: this file does not end with a newline
929 At: Sun, 14 May 2017 13:00 +0000
930 To: Sun, 14 May 2017 14:00
931 EOF
932
933 printf %s \
934 "BEGIN:VCALENDAR
935 VERSION:2.0
936 PRODID:RevenueWell
937 BEGIN:VEVENT
938 DTSTAMP:20170514T122300Z
939 DTSTART:20170514T130000Z
940 DTEND:20170514T140000Z
941 SUMMARY:test
942 DESCRIPTION:this file does not end with a newline
943 END:VEVENT
944 END:VCALENDAR" | TZ=UTC mhical >"$actual"
945 check "$expected" "$actual"
946
947
948 # check invalid line folding
949 start_test "invalid line folding"
950
951 cat >"$expected" <<'EOF'
952 Summary: test
953 Description: this file does not end with a newline
954 At: Sun, 14 May 2017 13:00 +0000
955 To: Sun, 14 May 2017 14:00
956 EOF
957
958 cat >"$expected_err" <<'EOF'
959 mhical: syntax error, unexpected ICAL_COMMA, expecting ICAL_COLON after " this line is not folded"
960 EOF
961
962 set +e
963 printf %s \
964 "BEGIN:VCALENDAR
965 VERSION:2.0
966 PRODID:-//TDP v3.0//EN
967 BEGIN:VEVENT
968 DTSTAMP:20170514T122300Z
969 DTSTART:20170514T130000Z
970 DTEND:20170514T140000Z
971 SUMMARY:test
972 DESCRIPTION:this file does not end with a newline
973 and this line is not folded,
974 END:VEVENT
975 END:VCALENDAR" | TZ=UTC mhical >"$actual" 2>"$actual_err"
976 set -e
977 check "$expected" "$actual"
978 check "$expected_err" "$actual_err"
979
980
981 # check null input
982 start_test "null input"
983 check_exit '-eq 0' mhical </dev/null
984
985
986 finish_test
987 exit $failed