# Copyright (c) 2005 bivio Software, Inc. All Rights Reserved. # $Id: ics-calendar.btest,v 1.4 2008/09/10 22:12:15 nagler Exp $ test_setup('PetShop'); my(undef, undef, $dav_forum_uri) = create_forum(); my($calendar_ics) = "$dav_forum_uri/Calendar.ics"; # Verify that admin can view and get .ics with no calendar send_request(PROPFIND => $dav_forum_uri); verify_text($calendar_ics); send_request(GET => $calendar_ics); get_content() =~ /BEGIN:VCALENDAR.*END:VCALENDAR/s || die; get_content() !~ /BEGIN:VEVENT/s || die; # Verify that admin can put a 2-event .ics, simulating Sunbird output send_request(PUT => $calendar_ics, undef, <<'EOF'); BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN BEGIN:VEVENT CREATED:20051220T222822Z LAST-MODIFIED:20051220T222822Z DTSTAMP:20051220T222822Z UID:uuid:1135117573515 SUMMARY:Event1 CLASS:PUBLIC DTSTART:20051221T110000 DTEND:20051221T123000 LOCATION:Location1 DESCRIPTION:Discuss status of Liberty RFP CATEGORIES:Customer X-LIC-ERROR:No value for STATUS property. Removing entire property: END:VEVENT BEGIN:VEVENT CREATED:20051220T223923Z LAST-MODIFIED:20051220T224201Z DTSTAMP:20051220T223923Z UID:uuid1135118466990 SUMMARY:Event2 PRIORITY:0 CLASS:PUBLIC DTSTART:20060104T140000 DTEND:20060105T103000 X-LIC-ERROR:No value for STATUS property. Removing entire property: LOCATION:Location2 CATEGORIES:Business DESCRIPTION:Greg will be flying in to visit END:VEVENT END:VCALENDAR EOF # Verify that admin can read validated .ics send_request(GET => $calendar_ics); get_content() =~ /BEGIN:VEVENT.*SUMMARY:Event(1|2).*BEGIN:VEVENT.*SUMMARY:Event(1|2)/s || die; # Verify putting unmodified .ics my($ics) = get_content(); send_request(PUT => $calendar_ics, undef, $ics); send_request(GET => $calendar_ics); get_content() eq $ics || die; # Verify adding calendar (my $new_ics = $ics) =~ s/END:VCALENDAR\r\n//m; Bivio::IO::Alert->info($new_ics); send_request(PUT => $calendar_ics, undef, $new_ics . <<'EOF'); BEGIN:VEVENT CREATED:20051225T223923Z LAST-MODIFIED:20051225T224201Z DTSTAMP:20051220T223923Z UID:uuid1135118466991 SUMMARY:Event3 PRIORITY:0 CLASS:PUBLIC DTSTART:20060102T140000 DTEND:20060103T103000 X-LIC-ERROR:No value for STATUS property. Removing entire property: LOCATION:Location2 CATEGORIES:Business DESCRIPTION:Prepare for Greg's trip END:VEVENT END:VCALENDAR EOF # Verify that admin can read modified .ics send_request(GET => $calendar_ics); # TODO: Test correct event order get_content() =~ /BEGIN:VEVENT.*SUMMARY:Event(1|2|3).*BEGIN:VEVENT.*SUMMARY:Event(1|2|3).*BEGIN:VEVENT.*SUMMARY:Event(1|2|3)/s || die; # Verify that non-admin, non-member can't access .ics basic_authorization('demo'); test_deviance(qr{not found}i); send_request(PROPFIND => $dav_forum_uri); send_request(GET => $calendar_ics); test_conformance(); # Add non-admin member and verify read-only access of .ics basic_authorization('root'); my($forum_members) = "$dav_forum_uri/Members.csv"; send_request(GET => $forum_members); send_request(PUT => $forum_members, undef, get_content() . <<"EOF"); @{[generate_local_email('demo')]},1,0,0 EOF basic_authorization('demo'); send_request(PROPFIND => $dav_forum_uri); verify_text($calendar_ics); send_request(GET => $calendar_ics); $ics = get_content(); test_deviance(qr{forbidden}i); send_request(PUT => $calendar_ics, undef, $ics);