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