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