]>
diplodocus.org Git - nmh/blob - test/mhical/test-mhical
2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir
=`dirname $0`/..
/..
12 MH_OBJ_DIR
=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 .
"${MH_OBJ_DIR}/test/common.sh"
19 check_exit
'-eq 1' mhical
-
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
24 #### Disable colorized output.
25 TERM
=dumb
; export TERM
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"
35 cat >"$expected" <<EOF
36 Usage: mhical [switches]
38 -reply accept|decline|tentative
51 #### Skip nmh intro text.
52 run_prog mhical
-help | sed '/^$/,$d' >"$actual" 2>&1
53 check
"$expected" "$actual"
58 case `mhical -version` in
60 *) printf '%s: mhical -version generated unexpected output\n' "$0" >&2
61 failed
=`expr ${failed:-0} + 1`;;
65 # check display with timezone that only has standard time
66 start_test
"display with timezone that only has standard time"
67 cat >"$expected" <<'EOF'
69 Description: See Santa here first!
70 At: Wed, 24 Dec 2014 12:00 +0000
71 To: Fri, 25 Dec 2015 11:59
74 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
82 DTSTART:16010101T020000
89 DTSTAMP:20141224T140426Z
90 DTSTART;TZID=MHT-12:20141225T000000
91 DTEND;TZID=MHT-12:20151225T235959
93 DESCRIPTION: See Santa here first!
99 TZ
=UTC mhical
<"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
100 check
"$expected" "$MH_TEST_DIR/test1.txt"
103 # check display with 24 hour time format and -outfile
104 start_test
"display with 24 hour time format and -outfile"
105 cat >"$expected" <<'EOF'
106 Summary: 4 pm meeting
107 At: Mon, 05 Jan 2015 16:00
108 To: Mon, 05 Jan 2015 16:30
111 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
117 DTSTAMP:20150101T162400Z
118 DTSTART:20150105T160000
119 DTEND:20150105T163000
126 mhical
-outfile "$MH_TEST_DIR/test1.txt" <"$MH_TEST_DIR/test1.ics"
127 check
"$expected" "$MH_TEST_DIR/test1.txt"
130 # check display with 12 hour time format and -infile
131 start_test
"display with 12 hour time format and -infile"
132 cat >"$expected" <<'EOF'
133 Summary: 4 pm meeting
134 At: Mon, 05 Jan 2015 4:00 PM
135 To: Mon, 05 Jan 2015 4:30 PM
138 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
144 DTSTAMP:20150101T162800Z
145 DTSTART:20150105T160000
146 DTEND:20150105T163000
153 mhical
-form mhical
.12hour
-infile "$MH_TEST_DIR/test1.ics" \
154 >"$MH_TEST_DIR/test1.txt"
155 check
"$expected" "$MH_TEST_DIR/test1.txt"
158 # check display with DST
159 start_test
"display with DST"
160 cat >"$expected" <<'EOF'
165 At: Mon, 05 Jan 2015 08:00 -0500
166 To: Mon, 05 Jan 2015 09:00
170 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
173 PRODID:Microsoft Exchange Server 2010
176 TZID:Eastern Standard Time
178 DTSTART:16010101T020000
181 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
184 DTSTART:16010101T020000
187 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
191 ORGANIZER;CN=Requester:MAILTO:requester@example.com
192 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=FALSE;CN=Requestee
193 :MAILTO:requestee@example.com
194 DESCRIPTION;LANGUAGE=en-US:\n\n
195 SUMMARY;LANGUAGE=en-US:Big Meeting
196 DTSTART;TZID=Eastern Standard Time:20150105T080000
197 DTEND;TZID=Eastern Standard Time:20150105T090000
201 DTSTAMP:20141231T235959Z
205 LOCATION;LANGUAGE=en-US:The Office
206 X-MICROSOFT-CDO-APPT-SEQUENCE:0
207 X-MICROSOFT-CDO-OWNERAPPTID:-0123456789
208 X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE
209 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
210 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
211 X-MICROSOFT-CDO-IMPORTANCE:1
212 X-MICROSOFT-CDO-INSTTYPE:0
213 X-MICROSOFT-DISALLOW-COUNTER:FALSE
217 TRIGGER;RELATED=START:-PT15M
223 TZ
=EST mhical
<"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
224 check
"$expected" "$MH_TEST_DIR/test1.txt"
227 # check timezone boundary at transition to daylight saving time
228 start_test
"timezone boundary at transition to daylight saving time"
229 # The default mhical display format doesn't show the timezone for the
230 # To: time, but it is different than that of the At: time.
231 cat >"$expected" <<'EOF'
233 At: Sun, 09 Mar 2014 01:59 -0500
234 To: Sun, 09 Mar 2014 03:30
237 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
242 TZID:Eastern Standard Time
244 DTSTART:16010101T020000
247 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
250 DTSTART:16010101T020000
253 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
257 DTSTAMP:20150101T000000Z
258 DTSTART;TZID=Eastern Standard Time:20140309T015959
259 DTEND;TZID=Eastern Standard Time:20140309T023000
265 TZ
=EST5EDT mhical
<"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
266 check
"$expected" "$MH_TEST_DIR/test1.txt"
269 # check -format, and that timezone is correct in end time
270 start_test
"-format, and that timezone is correct in end time"
271 cat >"$expected" <<'EOF'
272 Sun, 09 Mar 2014 03:30:00 -0400
275 TZ
=EST5EDT mhical
-format '%(pretty{dtend})' \
276 -infile "$MH_TEST_DIR/test1.ics" -outfile "$MH_TEST_DIR/test1.txt"
277 check
"$expected" "$MH_TEST_DIR/test1.txt"
280 # check timezone boundary at transition from daylight saving time
281 start_test
"timezone boundary at transition from daylight saving time"
282 cat >"$expected" <<'EOF'
284 At: Sun, 02 Nov 2014 01:59 -0400
285 To: Sun, 02 Nov 2014 02:00
288 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
293 TZID:Eastern Standard Time
295 DTSTART:16010101T020000
298 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
301 DTSTART:16010101T020000
304 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
308 DTSTAMP:20150101T000000Z
309 DTSTART;TZID=Eastern Standard Time:20141102T015959
310 DTEND;TZID=Eastern Standard Time:20141102T020000
316 TZ
=EST5EDT mhical
<"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
317 check
"$expected" "$MH_TEST_DIR/test1.txt"
320 # check -format, and that timezone is correct in end time
321 start_test
"-format, and that timezone is correct in end time"
322 cat >"$expected" <<'EOF'
323 Sun, 02 Nov 2014 02:00:00 -0500
326 TZ
=EST5EDT mhical
-format '%(pretty{dtend})' \
327 -infile "$MH_TEST_DIR/test1.ics" -outfile "$MH_TEST_DIR/test1.txt"
328 check
"$expected" "$MH_TEST_DIR/test1.txt"
331 printf 'Local-Mailbox: Requestee2 <requestee2@example.com>\n' >> "$MH"
333 # check accept of request
334 start_test
"accept of request"
335 cat >"$expected" <<'EOF'
338 PRODID:nmh mhical v0.1
341 TZID:Eastern Standard Time
343 DTSTART:16010101T020000
346 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
349 DTSTART:16010101T020000
352 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
356 ORGANIZER;CN=Requester:MAILTO:requester@example.com
357 ATTENDEE;PARTSTAT=ACCEPTED;CN=Requestee2:MAILTO:requestee2@example.com
358 SUMMARY;LANGUAGE=en-US:Accepted: test request
359 DTSTART;TZID=Eastern Standard Time:20150105T090000
360 DTEND;TZID=Eastern Standard Time:20150105T093000
367 LOCATION;LANGUAGE=en-US:
372 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
378 TZID:Eastern Standard Time
380 DTSTART:16010101T020000
383 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
386 DTSTART:16010101T020000
389 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
393 ORGANIZER;CN=Requester:MAILTO:requester@example.com
394 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
395 :MAILTO:requestee1@example.com
396 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
397 :MAILTO:requestee2@example.com
398 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
399 :MAILTO:requestee3@example.com
400 SUMMARY;LANGUAGE=en-US:test request
401 DTSTART;TZID=Eastern Standard Time:20150105T090000
402 DTEND;TZID=Eastern Standard Time:20150105T093000
406 DTSTAMP:20150101T171600Z
410 LOCATION;LANGUAGE=en-US:
414 TRIGGER;RELATED=START:-PT15M
420 mhical
-reply accept
<"$MH_TEST_DIR/test1.ics" | egrep -v '^DTSTAMP:' \
421 >"$MH_TEST_DIR/test1.txt"
422 check
"$expected" "$MH_TEST_DIR/test1.txt"
424 # check accept of multiple vevent requests in single vcalendar
425 start_test
"accept of multiple vevent requests in single vcalendar"
426 cat >"$expected" <<'EOF'
429 PRODID:nmh mhical v0.1
432 TZID:Eastern Standard Time
434 DTSTART:16010101T020000
437 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
440 DTSTART:16010101T020000
443 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
447 ORGANIZER;CN=Requester:MAILTO:requester@example.com
448 ATTENDEE;PARTSTAT=ACCEPTED;CN=Requestee2:MAILTO:requestee2@example.com
449 SUMMARY;LANGUAGE=en-US:Accepted: test request
450 DTSTART;TZID=Eastern Standard Time:20150105T090000
451 DTEND;TZID=Eastern Standard Time:20150105T093000
458 LOCATION;LANGUAGE=en-US:
462 ORGANIZER;CN=Requester:MAILTO:requester@example.com
463 ATTENDEE;PARTSTAT=ACCEPTED;CN=Requestee2:MAILTO:requestee2@example.com
464 SUMMARY;LANGUAGE=en-US:Accepted: test request
465 DTSTART;TZID=Eastern Standard Time:20150105T130000
466 DTEND;TZID=Eastern Standard Time:20150105T134500
473 LOCATION;LANGUAGE=en-US:
478 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
485 TZID:Eastern Standard Time
487 DTSTART:16010101T020000
490 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
493 DTSTART:16010101T020000
496 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
501 ORGANIZER;CN=Requester:MAILTO:requester@example.com
502 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
503 :MAILTO:requestee1@example.com
504 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
505 :MAILTO:requestee2@example.com
506 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
507 :MAILTO:requestee3@example.com
508 SUMMARY;LANGUAGE=en-US:test request
509 DTSTART;TZID=Eastern Standard Time:20150105T090000
510 DTEND;TZID=Eastern Standard Time:20150105T093000
514 DTSTAMP:20150101T171600Z
518 LOCATION;LANGUAGE=en-US:
522 TRIGGER;RELATED=START:-PT15M
527 ORGANIZER;CN=Requester:MAILTO:requester@example.com
528 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
529 :MAILTO:requestee2@example.com
530 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
531 :MAILTO:requestee3@example.com
532 SUMMARY;LANGUAGE=en-US:test request
533 DTSTART;TZID=Eastern Standard Time:20150105T130000
534 DTEND;TZID=Eastern Standard Time:20150105T134500
538 DTSTAMP:20150101T171600Z
542 LOCATION;LANGUAGE=en-US:
546 TRIGGER;RELATED=START:-PT15M
553 mhical
-reply accept
<"$MH_TEST_DIR/test1.ics" | egrep -v '^DTSTAMP:' \
554 >"$MH_TEST_DIR/test1.txt"
555 check
"$expected" "$MH_TEST_DIR/test1.txt"
558 # check decline of request
559 start_test
"decline of request"
560 cat >"$expected" <<'EOF'
563 PRODID:nmh mhical v0.1
566 ORGANIZER;CN=Requester:MAILTO:requester@example.com
567 ATTENDEE;PARTSTAT=DECLINED;CN=Requestee2:MAILTO:requestee2@example.com
568 SUMMARY;LANGUAGE=en-US:Declined: test request
569 DTSTART:20150105T090000
570 DTEND:20150105T093000
577 LOCATION;LANGUAGE=en-US:
582 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
588 ORGANIZER;CN=Requester:MAILTO:requester@example.com
589 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
590 :MAILTO:requestee1@example.com
591 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
592 :MAILTO:requestee2@example.com
593 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
594 :MAILTO:requestee3@example.com
595 SUMMARY;LANGUAGE=en-US:test request
596 DTSTART:20150105T090000
597 DTEND:20150105T093000
601 DTSTAMP:20150101T171600Z
605 LOCATION;LANGUAGE=en-US:
609 TRIGGER;RELATED=START:-PT15M
615 mhical
-reply decline
<"$MH_TEST_DIR/test1.ics" | egrep -v '^DTSTAMP:' \
616 >"$MH_TEST_DIR/test1.txt"
617 check
"$expected" "$MH_TEST_DIR/test1.txt"
620 # check response of tentative to request, and -nocontenttype
621 start_test
"response of tentative to request, and -nocontenttype"
622 cat >"$expected" <<'EOF'
625 PRODID:nmh mhical v0.1
628 ORGANIZER;CN=Requester:MAILTO:requester@example.com
629 ATTENDEE;PARTSTAT=TENTATIVE;CN=Requestee2:MAILTO:requestee2@example.com
630 SUMMARY;LANGUAGE=en-US:Tentative: test request
631 DTSTART:20150105T090000
632 DTEND:20150105T093000
639 LOCATION;LANGUAGE=en-US:
644 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
650 ORGANIZER;CN=Requester:MAILTO:requester@example.com
651 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
652 :MAILTO:requestee1@example.com
653 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee2
654 :MAILTO:requestee2@example.com
655 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
656 :MAILTO:requestee3@example.com
657 SUMMARY;LANGUAGE=en-US:test request
658 DTSTART:20150105T090000
659 DTEND:20150105T093000
663 DTSTAMP:20150101T171600Z
667 LOCATION;LANGUAGE=en-US:
671 TRIGGER;RELATED=START:-PT15M
677 mhical
-reply tentative
-contenttype -nocontenttype \
678 -infile "$MH_TEST_DIR/test1.ics" | egrep -v '^DTSTAMP:' \
679 >"$MH_TEST_DIR/test1.txt"
680 check
"$expected" "$MH_TEST_DIR/test1.txt"
683 # check cancel request, and -contenttype
684 start_test
"cancel request, and -contenttype"
685 cat >"$expected" <<'EOF'
686 Content-Type: text/calendar; method="CANCEL"; charset="UTF-8"
690 PRODID:nmh mhical v0.1
693 ORGANIZER;CN=Requestee2:MAILTO:requestee2@example.com
694 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
695 :MAILTO:requestee1@example.com
696 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
697 :MAILTO:requestee3@example.com
698 SUMMARY;LANGUAGE=en-US:Cancelled:test request
699 DTSTART:20150105T090000
700 DTEND:20150105T093000
707 LOCATION;LANGUAGE=en-US:
712 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
718 ORGANIZER;CN=Requestee2:MAILTO:requestee2@example.com
719 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee1
720 :MAILTO:requestee1@example.com
721 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Requestee3
722 :MAILTO:requestee3@example.com
723 SUMMARY;LANGUAGE=en-US:test request
724 DTSTART:20150105T090000
725 DTEND:20150105T093000
729 DTSTAMP:20150101T171600Z
733 LOCATION;LANGUAGE=en-US:
737 TRIGGER;RELATED=START:-PT15M
743 mhical
-cancel -contenttype <"$MH_TEST_DIR/test1.ics" | egrep -v '^DTSTAMP:' \
744 >"$MH_TEST_DIR/test1.txt"
745 check
"$expected" "$MH_TEST_DIR/test1.txt"
748 # Check TZID name wrapped with quotes, this used to cause a segfault.
749 start_test
"TZID name wrapped with quotes, this used to cause a segfault."
750 cat >"$expected" <<'EOF'
752 Summary: Quoted timezone ID
753 At: Wed, 01 Jan 2014 00:00
754 To: Wed, 01 Jan 2014 01:00
757 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
759 PRODID:Zimbra-Calendar-Provider
762 SUMMARY:Quoted timezone ID
766 DTSTART:19710101T000000
773 DTSTART:20140101T000000
774 DTEND;TZID="Etc/GMT":20140101T010000
780 TZ
=UTC mhical
<"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
781 check
"$expected" "$MH_TEST_DIR/test1.txt"
784 # Check start datetime without a time, and missing end datetime.
785 start_test
"start datetime without a time, and missing end datetime."
786 cat >"$expected" <<'EOF'
788 Summary: Test datetime without time
789 At: Wed, 30 Dec 2015 00:00
790 To: Wed, 30 Dec 2015 23:59
793 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
796 PRODID:icalendar-ruby
800 DTSTAMP:20151208T204350Z
802 DTSTART;VALUE=DATE:20151230
804 SUMMARY:Test datetime without time
808 TRIGGER;RELATED=START:-PT15M
814 TZ
=UTC mhical
<"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
815 check
"$expected" "$MH_TEST_DIR/test1.txt"
816 rm -f "$MH_TEST_DIR/test1.ics"
819 # check missing final newline
820 start_test
"missing final newline"
822 cat >"$expected" <<'EOF'
824 Description: this file does not end with a newline
825 At: Sun, 14 May 2017 13:00 +0000
826 To: Sun, 14 May 2017 14:00
834 DTSTAMP:20170514T122300Z
835 DTSTART:20170514T130000Z
836 DTEND:20170514T140000Z
838 DESCRIPTION:this file does not end with a newline
840 END:VCALENDAR" | TZ
=UTC mhical
>"$actual"
841 check
"$expected" "$actual"
844 # check invalid line folding
845 start_test
"invalid line folding"
847 cat >"$expected" <<'EOF'
849 Description: this file does not end with a newline
850 At: Sun, 14 May 2017 13:00 +0000
851 To: Sun, 14 May 2017 14:00
854 cat >"$expected_err" <<'EOF'
855 mhical: syntax error, unexpected ICAL_COMMA, expecting ICAL_COLON after " this line is not folded"
862 PRODID:-//TDP v3.0//EN
864 DTSTAMP:20170514T122300Z
865 DTSTART:20170514T130000Z
866 DTEND:20170514T140000Z
868 DESCRIPTION:this file does not end with a newline
869 and this line is not folded,
871 END:VCALENDAR" | TZ
=UTC mhical
>"$actual" 2>"$actual_err"
873 check
"$expected" "$actual"
874 check
"$expected_err" "$actual_err"