1require "vnd.dovecot.testsuite"; 2require "mime"; 3require "foreverypart"; 4require "editheader"; 5require "relational"; 6require "variables"; 7 8# Example from RFC 6047, Section 2.5: 9test_set "message" text: 10From: user1@example.com 11To: user2@example.com 12Subject: Phone Conference 13Mime-Version: 1.0 14Date: Wed, 07 May 2008 21:30:25 +0400 15Message-ID: <4821E731.5040506@laptop1.example.com> 16Content-Type: text/calendar; method=REQUEST; charset=UTF-8 17Content-Transfer-Encoding: quoted-printable 18 19BEGIN:VCALENDAR 20PRODID:-//Example/ExampleCalendarClient//EN 21METHOD:REQUEST 22VERSION:2.0 23BEGIN:VEVENT 24ORGANIZER:mailto:user1@example.com 25ATTENDEE;ROLE=CHAIR;PARTSTAT=ACCEPTED:mailto:user1@example.com 26ATTENDEE;RSVP=YES;CUTYPE=INDIVIDUAL:mailto:user2@example.com 27DTSTAMP:20080507T170000Z 28DTSTART:20080701T160000Z 29DTEND:20080701T163000Z 30SUMMARY:Phone call to discuss your last visit 31DESCRIPTION:=D1=82=D1=8B =D0=BA=D0=B0=D0=BA - =D0=B4=D0=BE=D0= 32 =B2=D0=BE=D0=BB=D0=B5=D0=BD =D0=BF=D0=BE=D0=B5=D0=B7=D0=B4=D0=BA=D0 33 =BE=D0=B9? 34UID:calsvr.example.com-8739701987387998 35SEQUENCE:0 36STATUS:TENTATIVE 37END:VEVENT 38END:VCALENDAR 39. 40; 41 42test "Calendar only" { 43 foreverypart { 44 if allof( 45 header :mime :count "eq" "Content-Type" "1", 46 header :mime :contenttype "Content-Type" "text/calendar", 47 header :mime :param "method" :matches "Content-Type" "*", 48 header :mime :param "charset" :is "Content-Type" "UTF-8" ) { 49 addheader "X-ICAL" "${1}"; 50 break; 51 } 52 } 53 54 if not header "x-ical" "request" { 55 test_fail "Failed to parse message correctly"; 56 } 57} 58 59# Modified example 60test_set "message" text: 61From: user1@example.com 62To: user2@example.com 63Subject: Phone Conference 64Mime-Version: 1.0 65Date: Wed, 07 May 2008 21:30:25 +0400 66Message-ID: <4821E731.5040506@laptop1.example.com> 67Content-Type: multipart/mixed; boundary=AA 68 69This is a multi-part message in MIME format. 70 71--AA 72Content-Type: text/plain 73 74Hello, 75 76I'd like to discuss your last visit. A tentative meeting schedule is 77attached. 78 79Regards, 80 81User1 82 83--AA 84Content-Type: text/calendar; method=REQUEST; charset=UTF-8 85Content-Transfer-Encoding: quoted-printable 86 87BEGIN:VCALENDAR 88PRODID:-//Example/ExampleCalendarClient//EN 89METHOD:REQUEST 90VERSION:2.0 91BEGIN:VEVENT 92ORGANIZER:mailto:user1@example.com 93ATTENDEE;ROLE=CHAIR;PARTSTAT=ACCEPTED:mailto:user1@example.com 94ATTENDEE;RSVP=YES;CUTYPE=INDIVIDUAL:mailto:user2@example.com 95DTSTAMP:20080507T170000Z 96DTSTART:20080701T160000Z 97DTEND:20080701T163000Z 98SUMMARY:Phone call to discuss your last visit 99DESCRIPTION:=D1=82=D1=8B =D0=BA=D0=B0=D0=BA - =D0=B4=D0=BE=D0= 100 =B2=D0=BE=D0=BB=D0=B5=D0=BD =D0=BF=D0=BE=D0=B5=D0=B7=D0=B4=D0=BA=D0 101 =BE=D0=B9? 102UID:calsvr.example.com-8739701987387998 103SEQUENCE:0 104STATUS:TENTATIVE 105END:VEVENT 106END:VCALENDAR 107 108--AA-- 109. 110; 111 112test "Multipart message" { 113 foreverypart { 114 if allof( 115 header :mime :count "eq" "Content-Type" "1", 116 header :mime :contenttype "Content-Type" "text/calendar", 117 header :mime :param "method" :matches "Content-Type" "*", 118 header :mime :param "charset" :is "Content-Type" "UTF-8" ) { 119 addheader "X-ICAL" "${1}"; 120 break; 121 } 122 } 123 124 if not header "x-ical" "request" { 125 test_fail "Failed to parse message correctly"; 126 } 127} 128 129 130