X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/13015c3c27462cb98027d644636ff526e10dd1d0..refs/heads/master:/test/mhical/test-mhical diff --git a/test/mhical/test-mhical b/test/mhical/test-mhical index 85962f29..cd77a495 100755 --- a/test/mhical/test-mhical +++ b/test/mhical/test-mhical @@ -31,6 +31,7 @@ actual_err="$MH_TEST_DIR/test-mhical$$.actual_err" # check -help +start_test "-help" cat >"$expected" <"$actual" 2>&1 +run_prog mhical -help 2>&1 | sed '/^$/,$d' >"$actual" check "$expected" "$actual" # check -version +start_test "-version" case `mhical -version` in mhical\ --*) ;; *) printf '%s: mhical -version generated unexpected output\n' "$0" >&2 @@ -61,6 +64,7 @@ esac # check display with timezone that only has standard time +start_test "display with timezone that only has standard time" cat >"$expected" <<'EOF' Summary: Santa Watch Description: See Santa here first! @@ -98,6 +102,7 @@ check "$expected" "$MH_TEST_DIR/test1.txt" # check display with 24 hour time format and -outfile +start_test "display with 24 hour time format and -outfile" cat >"$expected" <<'EOF' Summary: 4 pm meeting At: Mon, 05 Jan 2015 16:00 @@ -124,6 +129,7 @@ check "$expected" "$MH_TEST_DIR/test1.txt" # check display with 12 hour time format and -infile +start_test "display with 12 hour time format and -infile" cat >"$expected" <<'EOF' Summary: 4 pm meeting At: Mon, 05 Jan 2015 4:00 PM @@ -151,6 +157,7 @@ check "$expected" "$MH_TEST_DIR/test1.txt" # check display with DST +start_test "display with DST" cat >"$expected" <<'EOF' Method: REQUEST Organizer: Requester @@ -219,6 +226,7 @@ check "$expected" "$MH_TEST_DIR/test1.txt" # check timezone boundary at transition to daylight saving time +start_test "timezone boundary at transition to daylight saving time" # The default mhical display format doesn't show the timezone for the # To: time, but it is different than that of the At: time. cat >"$expected" <<'EOF' @@ -260,6 +268,7 @@ check "$expected" "$MH_TEST_DIR/test1.txt" # check -format, and that timezone is correct in end time +start_test "-format, and that timezone is correct in end time" cat >"$expected" <<'EOF' Sun, 09 Mar 2014 03:30:00 -0400 EOF @@ -270,6 +279,7 @@ check "$expected" "$MH_TEST_DIR/test1.txt" # check timezone boundary at transition from daylight saving time +start_test "timezone boundary at transition from daylight saving time" cat >"$expected" <<'EOF' Summary: EDT to EST At: Sun, 02 Nov 2014 01:59 -0400 @@ -309,6 +319,7 @@ check "$expected" "$MH_TEST_DIR/test1.txt" # check -format, and that timezone is correct in end time +start_test "-format, and that timezone is correct in end time" cat >"$expected" <<'EOF' Sun, 02 Nov 2014 02:00:00 -0500 EOF @@ -321,10 +332,11 @@ check "$expected" "$MH_TEST_DIR/test1.txt" printf 'Local-Mailbox: Requestee2 \n' >> "$MH" # check accept of request +start_test "accept of request" cat >"$expected" <<'EOF' BEGIN:VCALENDAR METHOD:REPLY -PRODID:nmh mhical v0.1 +PRODID:nmh mhical v0.5 VERSION:2.0 BEGIN:VTIMEZONE TZID:Eastern Standard Time @@ -410,11 +422,115 @@ mhical -reply accept <"$MH_TEST_DIR/test1.ics" | egrep -v '^DTSTAMP:' \ >"$MH_TEST_DIR/test1.txt" check "$expected" "$MH_TEST_DIR/test1.txt" + +# check accept of request with -attendee +start_test "accept of request with -attendee" +cat >"$expected" <<'EOF' +BEGIN:VCALENDAR +METHOD:REPLY +PRODID:nmh mhical v0.5 +VERSION:2.0 +BEGIN:VTIMEZONE +TZID:Eastern Standard Time +BEGIN:STANDARD +DTSTART:16010101T020000 +TZOFFSETFROM:-0400 +TZOFFSETTO:-0500 +RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:16010101T020000 +TZOFFSETFROM:-0500 +TZOFFSETTO:-0400 +RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +ORGANIZER;CN=Requester:MAILTO:requester@example.com +ATTENDEE;PARTSTAT=ACCEPTED;CN=Requestee1:MAILTO:requestee1@example.com +SUMMARY;LANGUAGE=en-US:Accepted: test request +DTSTART;TZID=Eastern Standard Time:20150105T090000 +DTEND;TZID=Eastern Standard Time:20150105T093000 +UID:0123456789 +CLASS:PUBLIC +PRIORITY:5 +TRANSP:OPAQUE +STATUS:CONFIRMED +SEQUENCE:0 +LOCATION;LANGUAGE=en-US: +END:VEVENT +END:VCALENDAR +EOF + +cp "$MH" "${MH}.save" +printf 'Alternate-Mailboxes: RequesteeToo \n' >> "$MH" +mhical -reply accept -attendee requestee1@example.com <"$MH_TEST_DIR/test1.ics" \ + | egrep -v '^DTSTAMP:' >"$MH_TEST_DIR/test1.txt" +check "$expected" "$MH_TEST_DIR/test1.txt" + + +# check accept of request with other -attendee +start_test "accept of request with other -attendee" +cat >"$expected" <<'EOF' +BEGIN:VCALENDAR +METHOD:REPLY +PRODID:nmh mhical v0.5 +VERSION:2.0 +BEGIN:VTIMEZONE +TZID:Eastern Standard Time +BEGIN:STANDARD +DTSTART:16010101T020000 +TZOFFSETFROM:-0400 +TZOFFSETTO:-0500 +RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:16010101T020000 +TZOFFSETFROM:-0500 +TZOFFSETTO:-0400 +RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +ORGANIZER;CN=Requester:MAILTO:requester@example.com +ATTENDEE;PARTSTAT=ACCEPTED;CN=Requestee2:MAILTO:requestee2@example.com +SUMMARY;LANGUAGE=en-US:Accepted: test request +DTSTART;TZID=Eastern Standard Time:20150105T090000 +DTEND;TZID=Eastern Standard Time:20150105T093000 +UID:0123456789 +CLASS:PUBLIC +PRIORITY:5 +TRANSP:OPAQUE +STATUS:CONFIRMED +SEQUENCE:0 +LOCATION;LANGUAGE=en-US: +END:VEVENT +END:VCALENDAR +EOF + +mhical -reply accept -attendee requestee2@example.com <"$MH_TEST_DIR/test1.ics" \ + | egrep -v '^DTSTAMP:' >"$MH_TEST_DIR/test1.txt" +check "$expected" "$MH_TEST_DIR/test1.txt" + + +# check accept of request without required -attendee +start_test "accept of request without required -attendee" +cat >"$expected" <<'EOF' +mhical: Multiple attendees match your address, re-run with -attendee switch +EOF + +mhical -reply accept <"$MH_TEST_DIR/test1.ics" 2>"$MH_TEST_DIR/test1.txt" \ + && false +check "$expected" "$MH_TEST_DIR/test1.txt" +mv "${MH}.save" "$MH" + + # check accept of multiple vevent requests in single vcalendar +start_test "accept of multiple vevent requests in single vcalendar" cat >"$expected" <<'EOF' BEGIN:VCALENDAR METHOD:REPLY -PRODID:nmh mhical v0.1 +PRODID:nmh mhical v0.5 VERSION:2.0 BEGIN:VTIMEZONE TZID:Eastern Standard Time @@ -544,10 +660,11 @@ check "$expected" "$MH_TEST_DIR/test1.txt" # check decline of request +start_test "decline of request" cat >"$expected" <<'EOF' BEGIN:VCALENDAR METHOD:REPLY -PRODID:nmh mhical v0.1 +PRODID:nmh mhical v0.5 VERSION:2.0 BEGIN:VEVENT ORGANIZER;CN=Requester:MAILTO:requester@example.com @@ -605,10 +722,11 @@ check "$expected" "$MH_TEST_DIR/test1.txt" # check response of tentative to request, and -nocontenttype +start_test "response of tentative to request, and -nocontenttype" cat >"$expected" <<'EOF' BEGIN:VCALENDAR METHOD:REPLY -PRODID:nmh mhical v0.1 +PRODID:nmh mhical v0.5 VERSION:2.0 BEGIN:VEVENT ORGANIZER;CN=Requester:MAILTO:requester@example.com @@ -667,12 +785,13 @@ check "$expected" "$MH_TEST_DIR/test1.txt" # check cancel request, and -contenttype +start_test "cancel request, and -contenttype" cat >"$expected" <<'EOF' Content-Type: text/calendar; method="CANCEL"; charset="UTF-8" BEGIN:VCALENDAR METHOD:CANCEL -PRODID:nmh mhical v0.1 +PRODID:nmh mhical v0.5 VERSION:2.0 BEGIN:VEVENT ORGANIZER;CN=Requestee2:MAILTO:requestee2@example.com @@ -731,6 +850,7 @@ check "$expected" "$MH_TEST_DIR/test1.txt" # Check TZID name wrapped with quotes, this used to cause a segfault. +start_test "TZID name wrapped with quotes, this used to cause a segfault." cat >"$expected" <<'EOF' Method: REQUEST Summary: Quoted timezone ID @@ -766,6 +886,7 @@ check "$expected" "$MH_TEST_DIR/test1.txt" # Check start datetime without a time, and missing end datetime. +start_test "start datetime without a time, and missing end datetime." cat >"$expected" <<'EOF' Method: PUBLISH Summary: Test datetime without time @@ -799,4 +920,153 @@ check "$expected" "$MH_TEST_DIR/test1.txt" rm -f "$MH_TEST_DIR/test1.ics" +# check missing final newline +start_test "missing final newline" + +cat >"$expected" <<'EOF' +Summary: test +Description: this file does not end with a newline +At: Sun, 14 May 2017 13:00 +0000 +To: Sun, 14 May 2017 14:00 +EOF + +printf %s \ +"BEGIN:VCALENDAR +VERSION:2.0 +PRODID:RevenueWell +BEGIN:VEVENT +DTSTAMP:20170514T122300Z +DTSTART:20170514T130000Z +DTEND:20170514T140000Z +SUMMARY:test +DESCRIPTION:this file does not end with a newline +END:VEVENT +END:VCALENDAR" | TZ=UTC mhical >"$actual" +check "$expected" "$actual" + + +# check invalid line folding +start_test "invalid line folding" + +cat >"$expected" <<'EOF' +Summary: test +Description: test of invalid line folding +At: Sun, 14 May 2017 13:00 +0000 +To: Sun, 14 May 2017 14:00 +EOF + +set +e +printf %s \ +"BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//TDP v3.0//EN +BEGIN:VEVENT +DTSTAMP:20170514T122300Z +DTSTART:20170514T130000Z +DTEND:20170514T140000Z +SUMMARY:test +DESCRIPTION:test of invalid line folding +where this line is not folded, +END:VEVENT +END:VCALENDAR" | TZ=UTC mhical >"$actual" 2>"$actual_err" +set -e +check "$expected" "$actual" +grep "mhical: syntax error.*this line is not folded\"" "$actual_err" >/dev/null +test `wc -l <"$actual_err"` -eq 1 + + +# check null input +start_test "null input" +check_exit '-eq 1' mhical "$expected" <<'EOF' +Summary: BST to GMT +At: Sat, 22 Oct 1994 23:33 +0000 +To: Sun, 23 Oct 1994 07:34 +EOF + +cat >"$MH_TEST_DIR/test1.ics" <<'EOF' +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:test-mhical +BEGIN:VTIMEZONE +TZID:London +BEGIN:STANDARD +TZNAME:GMT +DTSTART:19931018T020000 +TZOFFSETFROM:+0100 +TZOFFSETTO:+0000 +RRULE:FREQ=YEARLY;BYDAY=-2SU;BYMONTH=10 +END:STANDARD +BEGIN:DAYLIGHT +TZNAME:BST +DTSTART:19810329T010000 +TZOFFSETFROM:+0000 +TZOFFSETTO:+0100 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +DTSTAMP:19941002T115852Z +DTSTART;TZID=London:19941022T233300 +DTEND;TZID=London:19941023T073400 +Summary: BST to GMT +END:VEVENT +END:VCALENDAR +EOF + +TZ=GMT mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt" +check "$expected" "$MH_TEST_DIR/test1.txt" +rm -f "$MH_TEST_DIR/test1.ics" + + +# check timezone boundary at transition to daylight saving time, -1SU +start_test "timezone boundary at transition to daylight saving time, -1SU" +# Specifically looking at "last Sunday of the month" type transitions. +cat >"$expected" <<'EOF' +Summary: GMT to BST +At: Sat, 27 Mar 1982 23:31 +0000 +To: Sun, 28 Mar 1982 07:32 +EOF + +cat >"$MH_TEST_DIR/test1.ics" <<'EOF' +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:test-mhical +BEGIN:VTIMEZONE +TZID:London +BEGIN:STANDARD +TZNAME:GMT +DTSTART:19781025T030000 +TZOFFSETFROM:+0100 +TZOFFSETTO:+0000 +RRULE:FREQ=YEARLY;UNTIL=19811025T010000Z;BYDAY=-1SU;BYMONTH=10 +END:STANDARD +BEGIN:DAYLIGHT +TZNAME:BST +DTSTART:19810329T010000 +TZOFFSETFROM:+0000 +TZOFFSETTO:+0100 +RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +DTSTAMP:19820302T115852Z +DTSTART;TZID=London:19820327T233100 +DTEND;TZID=London:19820328T073200 +Summary: GMT to BST +END:VEVENT +END:VCALENDAR +EOF + +TZ=GMT mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt" +check "$expected" "$MH_TEST_DIR/test1.txt" +rm -f "$MH_TEST_DIR/test1.ics" + + +finish_test exit $failed