]> diplodocus.org Git - nmh/blob - test/mhical/test-mhical
Merge branch 'fix-post-bcc'
[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 -[no]contenttype
45 -unfold
46 -debug
47 -version
48 -help
49 EOF
50
51 #### Skip nmh intro text.
52 run_prog mhical -help | sed '/^$/,$d' >"$actual" 2>&1
53 check "$expected" "$actual"
54
55
56 # check -version
57 start_test "-version"
58 case `mhical -version` in
59 mhical\ --*) ;;
60 *) printf '%s: mhical -version generated unexpected output\n' "$0" >&2
61 failed=`expr ${failed:-0} + 1`;;
62 esac
63
64
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'
68 Summary: Santa Watch
69 Description: See Santa here first!
70 At: Wed, 24 Dec 2014 12:00 +0000
71 To: Fri, 25 Dec 2015 11:59
72 EOF
73
74 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
75 BEGIN:VCALENDAR
76 VERSION:2.0
77 PRODID:test-mhical
78
79 BEGIN:VTIMEZONE
80 TZID:MHT-12
81 BEGIN:STANDARD
82 DTSTART:16010101T020000
83 TZOFFSETFROM:+1200
84 TZOFFSETTO:+1200
85 END:STANDARD
86 END:VTIMEZONE
87
88 BEGIN:VEVENT
89 DTSTAMP:20141224T140426Z
90 DTSTART;TZID=MHT-12:20141225T000000
91 DTEND;TZID=MHT-12:20151225T235959
92 SUMMARY:Santa Watch
93 DESCRIPTION: See Santa here first!
94 END:VEVENT
95
96 END:VCALENDAR
97 EOF
98
99 TZ=UTC mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
100 check "$expected" "$MH_TEST_DIR/test1.txt"
101
102
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
109 EOF
110
111 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
112 BEGIN:VCALENDAR
113 VERSION:2.0
114 PRODID:test-mhical
115
116 BEGIN:VEVENT
117 DTSTAMP:20150101T162400Z
118 DTSTART:20150105T160000
119 DTEND:20150105T163000
120 SUMMARY:4 pm meeting
121 END:VEVENT
122
123 END:VCALENDAR
124 EOF
125
126 mhical -outfile "$MH_TEST_DIR/test1.txt" <"$MH_TEST_DIR/test1.ics"
127 check "$expected" "$MH_TEST_DIR/test1.txt"
128
129
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
136 EOF
137
138 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
139 BEGIN:VCALENDAR
140 VERSION:2.0
141 PRODID:test-mhical
142
143 BEGIN:VEVENT
144 DTSTAMP:20150101T162800Z
145 DTSTART:20150105T160000
146 DTEND:20150105T163000
147 SUMMARY:4 pm meeting
148 END:VEVENT
149
150 END:VCALENDAR
151 EOF
152
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"
156
157
158 # check display with DST
159 start_test "display with DST"
160 cat >"$expected" <<'EOF'
161 Method: REQUEST
162 Organizer: Requester
163 Summary: Big Meeting
164 Location: The Office
165 At: Mon, 05 Jan 2015 08:00 -0500
166 To: Mon, 05 Jan 2015 09:00
167 Attendees: Requestee
168 EOF
169
170 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
171 BEGIN:VCALENDAR
172 METHOD:REQUEST
173 PRODID:Microsoft Exchange Server 2010
174 VERSION:2.0
175 BEGIN:VTIMEZONE
176 TZID:Eastern Standard Time
177 BEGIN:STANDARD
178 DTSTART:16010101T020000
179 TZOFFSETFROM:-0400
180 TZOFFSETTO:-0500
181 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
182 END:STANDARD
183 BEGIN:DAYLIGHT
184 DTSTART:16010101T020000
185 TZOFFSETFROM:-0500
186 TZOFFSETTO:-0400
187 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
188 END:DAYLIGHT
189 END:VTIMEZONE
190 BEGIN:VEVENT
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
198 UID:0123456789
199 CLASS:PUBLIC
200 PRIORITY:5
201 DTSTAMP:20141231T235959Z
202 TRANSP:OPAQUE
203 STATUS:CONFIRMED
204 SEQUENCE:0
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
214 BEGIN:VALARM
215 ACTION:DISPLAY
216 DESCRIPTION:REMINDER
217 TRIGGER;RELATED=START:-PT15M
218 END:VALARM
219 END:VEVENT
220 END:VCALENDAR
221 EOF
222
223 TZ=EST mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
224 check "$expected" "$MH_TEST_DIR/test1.txt"
225
226
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'
232 Summary: EST to EDT
233 At: Sun, 09 Mar 2014 01:59 -0500
234 To: Sun, 09 Mar 2014 03:30
235 EOF
236
237 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
238 BEGIN:VCALENDAR
239 VERSION:2.0
240 PRODID:test-mhical
241 BEGIN:VTIMEZONE
242 TZID:Eastern Standard Time
243 BEGIN:STANDARD
244 DTSTART:16010101T020000
245 TZOFFSETFROM:-0400
246 TZOFFSETTO:-0500
247 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
248 END:STANDARD
249 BEGIN:DAYLIGHT
250 DTSTART:16010101T020000
251 TZOFFSETFROM:-0500
252 TZOFFSETTO:-0400
253 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
254 END:DAYLIGHT
255 END:VTIMEZONE
256 BEGIN:VEVENT
257 DTSTAMP:20150101T000000Z
258 DTSTART;TZID=Eastern Standard Time:20140309T015959
259 DTEND;TZID=Eastern Standard Time:20140309T023000
260 Summary: EST to EDT
261 END:VEVENT
262 END:VCALENDAR
263 EOF
264
265 TZ=EST5EDT mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
266 check "$expected" "$MH_TEST_DIR/test1.txt"
267
268
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
273 EOF
274
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"
278
279
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'
283 Summary: EDT to EST
284 At: Sun, 02 Nov 2014 01:59 -0400
285 To: Sun, 02 Nov 2014 02:00
286 EOF
287
288 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
289 BEGIN:VCALENDAR
290 VERSION:2.0
291 PRODID:test-mhical
292 BEGIN:VTIMEZONE
293 TZID:Eastern Standard Time
294 BEGIN:STANDARD
295 DTSTART:16010101T020000
296 TZOFFSETFROM:-0400
297 TZOFFSETTO:-0500
298 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
299 END:STANDARD
300 BEGIN:DAYLIGHT
301 DTSTART:16010101T020000
302 TZOFFSETFROM:-0500
303 TZOFFSETTO:-0400
304 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
305 END:DAYLIGHT
306 END:VTIMEZONE
307 BEGIN:VEVENT
308 DTSTAMP:20150101T000000Z
309 DTSTART;TZID=Eastern Standard Time:20141102T015959
310 DTEND;TZID=Eastern Standard Time:20141102T020000
311 Summary: EDT to EST
312 END:VEVENT
313 END:VCALENDAR
314 EOF
315
316 TZ=EST5EDT mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
317 check "$expected" "$MH_TEST_DIR/test1.txt"
318
319
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
324 EOF
325
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"
329
330
331 printf 'Local-Mailbox: Requestee2 <requestee2@example.com>\n' >> "$MH"
332
333 # check accept of request
334 start_test "accept of request"
335 cat >"$expected" <<'EOF'
336 BEGIN:VCALENDAR
337 METHOD:REPLY
338 PRODID:nmh mhical v0.1
339 VERSION:2.0
340 BEGIN:VTIMEZONE
341 TZID:Eastern Standard Time
342 BEGIN:STANDARD
343 DTSTART:16010101T020000
344 TZOFFSETFROM:-0400
345 TZOFFSETTO:-0500
346 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
347 END:STANDARD
348 BEGIN:DAYLIGHT
349 DTSTART:16010101T020000
350 TZOFFSETFROM:-0500
351 TZOFFSETTO:-0400
352 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
353 END:DAYLIGHT
354 END:VTIMEZONE
355 BEGIN:VEVENT
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
361 UID:0123456789
362 CLASS:PUBLIC
363 PRIORITY:5
364 TRANSP:OPAQUE
365 STATUS:CONFIRMED
366 SEQUENCE:0
367 LOCATION;LANGUAGE=en-US:
368 END:VEVENT
369 END:VCALENDAR
370 EOF
371
372 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
373 BEGIN:VCALENDAR
374 METHOD:REQUEST
375 PRODID:test-mhical
376 VERSION:2.0
377 BEGIN:VTIMEZONE
378 TZID:Eastern Standard Time
379 BEGIN:STANDARD
380 DTSTART:16010101T020000
381 TZOFFSETFROM:-0400
382 TZOFFSETTO:-0500
383 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
384 END:STANDARD
385 BEGIN:DAYLIGHT
386 DTSTART:16010101T020000
387 TZOFFSETFROM:-0500
388 TZOFFSETTO:-0400
389 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
390 END:DAYLIGHT
391 END:VTIMEZONE
392 BEGIN:VEVENT
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
403 UID:0123456789
404 CLASS:PUBLIC
405 PRIORITY:5
406 DTSTAMP:20150101T171600Z
407 TRANSP:OPAQUE
408 STATUS:CONFIRMED
409 SEQUENCE:0
410 LOCATION;LANGUAGE=en-US:
411 BEGIN:VALARM
412 ACTION:DISPLAY
413 DESCRIPTION:REMINDER
414 TRIGGER;RELATED=START:-PT15M
415 END:VALARM
416 END:VEVENT
417 END:VCALENDAR
418 EOF
419
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"
423
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'
427 BEGIN:VCALENDAR
428 METHOD:REPLY
429 PRODID:nmh mhical v0.1
430 VERSION:2.0
431 BEGIN:VTIMEZONE
432 TZID:Eastern Standard Time
433 BEGIN:STANDARD
434 DTSTART:16010101T020000
435 TZOFFSETFROM:-0400
436 TZOFFSETTO:-0500
437 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
438 END:STANDARD
439 BEGIN:DAYLIGHT
440 DTSTART:16010101T020000
441 TZOFFSETFROM:-0500
442 TZOFFSETTO:-0400
443 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
444 END:DAYLIGHT
445 END:VTIMEZONE
446 BEGIN:VEVENT
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
452 UID:0123456790
453 CLASS:PUBLIC
454 PRIORITY:5
455 TRANSP:OPAQUE
456 STATUS:CONFIRMED
457 SEQUENCE:0
458 LOCATION;LANGUAGE=en-US:
459 END:VEVENT
460
461 BEGIN:VEVENT
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
467 UID:0123456791
468 CLASS:PUBLIC
469 PRIORITY:5
470 TRANSP:OPAQUE
471 STATUS:CONFIRMED
472 SEQUENCE:0
473 LOCATION;LANGUAGE=en-US:
474 END:VEVENT
475 END:VCALENDAR
476 EOF
477
478 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
479 BEGIN:VCALENDAR
480 METHOD:REQUEST
481 PRODID:test-mhical
482 VERSION:2.0
483
484 BEGIN:VTIMEZONE
485 TZID:Eastern Standard Time
486 BEGIN:STANDARD
487 DTSTART:16010101T020000
488 TZOFFSETFROM:-0400
489 TZOFFSETTO:-0500
490 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
491 END:STANDARD
492 BEGIN:DAYLIGHT
493 DTSTART:16010101T020000
494 TZOFFSETFROM:-0500
495 TZOFFSETTO:-0400
496 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
497 END:DAYLIGHT
498 END:VTIMEZONE
499
500 BEGIN:VEVENT
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
511 UID:0123456790
512 CLASS:PUBLIC
513 PRIORITY:5
514 DTSTAMP:20150101T171600Z
515 TRANSP:OPAQUE
516 STATUS:CONFIRMED
517 SEQUENCE:0
518 LOCATION;LANGUAGE=en-US:
519 BEGIN:VALARM
520 ACTION:DISPLAY
521 DESCRIPTION:REMINDER
522 TRIGGER;RELATED=START:-PT15M
523 END:VALARM
524 END:VEVENT
525
526 BEGIN:VEVENT
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
535 UID:0123456791
536 CLASS:PUBLIC
537 PRIORITY:5
538 DTSTAMP:20150101T171600Z
539 TRANSP:OPAQUE
540 STATUS:CONFIRMED
541 SEQUENCE:0
542 LOCATION;LANGUAGE=en-US:
543 BEGIN:VALARM
544 ACTION:DISPLAY
545 DESCRIPTION:REMINDER
546 TRIGGER;RELATED=START:-PT15M
547 END:VALARM
548 END:VEVENT
549
550 END:VCALENDAR
551 EOF
552
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"
556
557
558 # check decline of request
559 start_test "decline of request"
560 cat >"$expected" <<'EOF'
561 BEGIN:VCALENDAR
562 METHOD:REPLY
563 PRODID:nmh mhical v0.1
564 VERSION:2.0
565 BEGIN:VEVENT
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
571 UID:0123456789
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 BEGIN:VEVENT
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
598 UID:0123456789
599 CLASS:PUBLIC
600 PRIORITY:5
601 DTSTAMP:20150101T171600Z
602 TRANSP:OPAQUE
603 STATUS:CONFIRMED
604 SEQUENCE:0
605 LOCATION;LANGUAGE=en-US:
606 BEGIN:VALARM
607 ACTION:DISPLAY
608 DESCRIPTION:REMINDER
609 TRIGGER;RELATED=START:-PT15M
610 END:VALARM
611 END:VEVENT
612 END:VCALENDAR
613 EOF
614
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"
618
619
620 # check response of tentative to request, and -nocontenttype
621 start_test "response of tentative to request, and -nocontenttype"
622 cat >"$expected" <<'EOF'
623 BEGIN:VCALENDAR
624 METHOD:REPLY
625 PRODID:nmh mhical v0.1
626 VERSION:2.0
627 BEGIN:VEVENT
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
633 UID:0123456789
634 CLASS:PUBLIC
635 PRIORITY:5
636 TRANSP:OPAQUE
637 STATUS:CONFIRMED
638 SEQUENCE:0
639 LOCATION;LANGUAGE=en-US:
640 END:VEVENT
641 END:VCALENDAR
642 EOF
643
644 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
645 BEGIN:VCALENDAR
646 METHOD:REQUEST
647 PRODID:test-mhical
648 VERSION:2.0
649 BEGIN:VEVENT
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
660 UID:0123456789
661 CLASS:PUBLIC
662 PRIORITY:5
663 DTSTAMP:20150101T171600Z
664 TRANSP:OPAQUE
665 STATUS:CONFIRMED
666 SEQUENCE:0
667 LOCATION;LANGUAGE=en-US:
668 BEGIN:VALARM
669 ACTION:DISPLAY
670 DESCRIPTION:REMINDER
671 TRIGGER;RELATED=START:-PT15M
672 END:VALARM
673 END:VEVENT
674 END:VCALENDAR
675 EOF
676
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"
681
682
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"
687
688 BEGIN:VCALENDAR
689 METHOD:CANCEL
690 PRODID:nmh mhical v0.1
691 VERSION:2.0
692 BEGIN:VEVENT
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
701 UID:0123456789
702 CLASS:PUBLIC
703 PRIORITY:5
704 TRANSP:OPAQUE
705 STATUS:CANCELLED
706 SEQUENCE:1
707 LOCATION;LANGUAGE=en-US:
708 END:VEVENT
709 END:VCALENDAR
710 EOF
711
712 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
713 BEGIN:VCALENDAR
714 METHOD:REQUEST
715 PRODID:test-mhical
716 VERSION:2.0
717 BEGIN:VEVENT
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
726 UID:0123456789
727 CLASS:PUBLIC
728 PRIORITY:5
729 DTSTAMP:20150101T171600Z
730 TRANSP:OPAQUE
731 STATUS:CONFIRMED
732 SEQUENCE:0
733 LOCATION;LANGUAGE=en-US:
734 BEGIN:VALARM
735 ACTION:DISPLAY
736 DESCRIPTION:REMINDER
737 TRIGGER;RELATED=START:-PT15M
738 END:VALARM
739 END:VEVENT
740 END:VCALENDAR
741 EOF
742
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"
746
747
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'
751 Method: REQUEST
752 Summary: Quoted timezone ID
753 At: Wed, 01 Jan 2014 00:00
754 To: Wed, 01 Jan 2014 01:00
755 EOF
756
757 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
758 BEGIN:VCALENDAR
759 PRODID:Zimbra-Calendar-Provider
760 VERSION:2.0
761 METHOD:REQUEST
762 SUMMARY:Quoted timezone ID
763 BEGIN:VTIMEZONE
764 TZID:Etc/GMT
765 BEGIN:STANDARD
766 DTSTART:19710101T000000
767 TZOFFSETTO:-0000
768 TZOFFSETFROM:-0000
769 TZNAME:GMT
770 END:STANDARD
771 END:VTIMEZONE
772 BEGIN:VEVENT
773 DTSTART:20140101T000000
774 DTEND;TZID="Etc/GMT":20140101T010000
775 SEQUENCE:0
776 END:VEVENT
777 END:VCALENDAR
778 EOF
779
780 TZ=UTC mhical <"$MH_TEST_DIR/test1.ics" >"$MH_TEST_DIR/test1.txt"
781 check "$expected" "$MH_TEST_DIR/test1.txt"
782
783
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'
787 Method: PUBLISH
788 Summary: Test datetime without time
789 At: Wed, 30 Dec 2015 00:00
790 To: Wed, 30 Dec 2015 23:59
791 EOF
792
793 cat >"$MH_TEST_DIR/test1.ics" <<'EOF'
794 BEGIN:VCALENDAR
795 VERSION:2.0
796 PRODID:icalendar-ruby
797 CALSCALE:GREGORIAN
798 METHOD:PUBLISH
799 BEGIN:VEVENT
800 DTSTAMP:20151208T204350Z
801 UID:0123456789
802 DTSTART;VALUE=DATE:20151230
803 CLASS:PRIVATE
804 SUMMARY:Test datetime without time
805 BEGIN:VALARM
806 ACTION:DISPLAY
807 DESCRIPTION:REMINDER
808 TRIGGER;RELATED=START:-PT15M
809 END:VALARM
810 END:VEVENT
811 END:VCALENDAR
812 EOF
813
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"
817
818
819 # check missing final newline
820 start_test "missing final newline"
821
822 cat >"$expected" <<'EOF'
823 Summary: test
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
827 EOF
828
829 printf %s \
830 "BEGIN:VCALENDAR
831 VERSION:2.0
832 PRODID:RevenueWell
833 BEGIN:VEVENT
834 DTSTAMP:20170514T122300Z
835 DTSTART:20170514T130000Z
836 DTEND:20170514T140000Z
837 SUMMARY:test
838 DESCRIPTION:this file does not end with a newline
839 END:VEVENT
840 END:VCALENDAR" | TZ=UTC mhical >"$actual"
841 check "$expected" "$actual"
842
843
844 # check invalid line folding
845 start_test "invalid line folding"
846
847 cat >"$expected" <<'EOF'
848 Summary: test
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
852 EOF
853
854 cat >"$expected_err" <<'EOF'
855 mhical: syntax error, unexpected ICAL_COMMA, expecting ICAL_COLON after " this line is not folded"
856 EOF
857
858 set +e
859 printf %s \
860 "BEGIN:VCALENDAR
861 VERSION:2.0
862 PRODID:-//TDP v3.0//EN
863 BEGIN:VEVENT
864 DTSTAMP:20170514T122300Z
865 DTSTART:20170514T130000Z
866 DTEND:20170514T140000Z
867 SUMMARY:test
868 DESCRIPTION:this file does not end with a newline
869 and this line is not folded,
870 END:VEVENT
871 END:VCALENDAR" | TZ=UTC mhical >"$actual" 2>"$actual_err"
872 set -e
873 check "$expected" "$actual"
874 check "$expected_err" "$actual_err"
875
876
877 finish_test
878 exit $failed