[CalendarServer-changes] [11278] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu May 30 14:38:10 PDT 2013
Revision: 11278
http://trac.calendarserver.org//changeset/11278
Author: cdaboo at apple.com
Date: 2013-05-30 14:38:10 -0700 (Thu, 30 May 2013)
Log Message:
-----------
Make sure ORGANIZER cannot be removed whilst ATTENDEEs remain. Also have CalVerify detect this case.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tools/calverify.py
CalendarServer/trunk/calendarserver/tools/test/test_calverify.py
CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py
Modified: CalendarServer/trunk/calendarserver/tools/calverify.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/calverify.py 2013-05-30 21:36:06 UTC (rev 11277)
+++ CalendarServer/trunk/calendarserver/tools/calverify.py 2013-05-30 21:38:10 UTC (rev 11278)
@@ -1206,6 +1206,9 @@
if component.hasDuplicateAlarms(doFix=False):
raise InvalidICalendarDataError("Duplicate VALARMS")
self.noPrincipalPathCUAddresses(component, doFix=False)
+ if self.options["ical"]:
+ self.attendeesWithoutOrganizer(component, doFix=False)
+
except ValueError, e:
result = False
message = str(e)
@@ -1317,6 +1320,20 @@
raise InvalidICalendarDataError("iCalendar ATTENDEE CALENDARSERVER-OLD-CUA not base64")
+ def attendeesWithoutOrganizer(self, component, doFix):
+ """
+ Look for events with ATTENDEE properties and no ORGANIZER property.
+ """
+
+ organizer = component.getOrganizer()
+ attendees = component.getAttendees()
+ if organizer is None and attendees:
+ if doFix:
+ raise ValueError("ATTENDEEs without ORGANIZER")
+ else:
+ raise InvalidICalendarDataError("ATTENDEEs without ORGANIZER")
+
+
@inlineCallbacks
def fixCalendarData(self, resid, isinbox):
"""
@@ -1342,6 +1359,8 @@
component.validOrganizerForScheduling(doFix=True)
component.hasDuplicateAlarms(doFix=True)
self.noPrincipalPathCUAddresses(component, doFix=True)
+ if self.options["ical"]:
+ self.attendeesWithoutOrganizer(component, doFix=True)
except ValueError:
result = False
message = "Failed fix: "
Modified: CalendarServer/trunk/calendarserver/tools/test/test_calverify.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_calverify.py 2013-05-30 21:36:06 UTC (rev 11277)
+++ CalendarServer/trunk/calendarserver/tools/test/test_calverify.py 2013-05-30 21:38:10 UTC (rev 11278)
@@ -412,8 +412,27 @@
END:VCALENDAR
""".replace("\n", "\r\n")
+BAD13_ICS = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100303T181216Z
+UID:BAD13
+DTEND:20100307T151500Z
+TRANSP:OPAQUE
+SUMMARY:Ancient event
+DTSTART:20100307T111500Z
+DTSTAMP:20100303T181220Z
+ATTENDEE:urn:uuid:D46F3D71-04B7-43C2-A7B6-6F92F92E61D0
+ATTENDEE:urn:uuid:47B16BB4-DB5F-4BF6-85FE-A7DA54230F92
+SEQUENCE:2
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
class CalVerifyDataTests(StoreTestCase):
"""
Tests calverify for iCalendar data problems.
@@ -443,10 +462,13 @@
"bad10.ics" : (BAD10_ICS, metadata,),
"bad11.ics" : (BAD11_ICS, metadata,),
"bad12.ics" : (BAD12_ICS, metadata,),
+ "bad13.ics" : (BAD13_ICS, metadata,),
}
},
}
+ number_to_process = len(requirements["home1"]["calendar_1"])
+
def configure(self):
super(CalVerifyDataTests, self).configure()
self.patch(config.DirectoryService.params, "xmlFile",
@@ -505,7 +527,7 @@
calverify.emailDomain = "example.com"
yield calverify.doAction()
- self.assertEqual(calverify.results["Number of events to process"], 13)
+ self.assertEqual(calverify.results["Number of events to process"], self.number_to_process)
self.verifyResultsByUID(calverify.results["Bad iCalendar data"], set((
("home1", "BAD1",),
("home1", "BAD2",),
@@ -518,6 +540,7 @@
("home1", "BAD10",),
("home1", "BAD11",),
("home1", "BAD12",),
+ ("home1", "BAD13",),
)))
sync_token_new = (yield (yield self.calendarUnderTest()).syncToken())
@@ -552,7 +575,7 @@
calverify.emailDomain = "example.com"
yield calverify.doAction()
- self.assertEqual(calverify.results["Number of events to process"], 13)
+ self.assertEqual(calverify.results["Number of events to process"], self.number_to_process)
self.verifyResultsByUID(calverify.results["Bad iCalendar data"], set((
("home1", "BAD1",),
("home1", "BAD2",),
@@ -565,6 +588,7 @@
("home1", "BAD10",),
("home1", "BAD11",),
("home1", "BAD12",),
+ ("home1", "BAD13",),
)))
# Do scan
@@ -573,9 +597,10 @@
calverify.emailDomain = "example.com"
yield calverify.doAction()
- self.assertEqual(calverify.results["Number of events to process"], 13)
+ self.assertEqual(calverify.results["Number of events to process"], self.number_to_process)
self.verifyResultsByUID(calverify.results["Bad iCalendar data"], set((
("home1", "BAD1",),
+ ("home1", "BAD13",),
)))
sync_token_new = (yield (yield self.calendarUnderTest()).syncToken())
@@ -619,7 +644,7 @@
calverify.emailDomain = "example.com"
yield calverify.doAction()
- self.assertEqual(calverify.results["Number of events to process"], 13)
+ self.assertEqual(calverify.results["Number of events to process"], self.number_to_process)
self.verifyResultsByUID(calverify.results["Bad iCalendar data"], set((
("home1", "BAD4",),
("home1", "BAD5",),
@@ -663,7 +688,7 @@
calverify.emailDomain = "example.com"
yield calverify.doAction()
- self.assertEqual(calverify.results["Number of events to process"], 13)
+ self.assertEqual(calverify.results["Number of events to process"], self.number_to_process)
self.verifyResultsByUID(calverify.results["Bad iCalendar data"], set((
("home1", "BAD4",),
("home1", "BAD5",),
@@ -680,7 +705,7 @@
calverify.emailDomain = "example.com"
yield calverify.doAction()
- self.assertEqual(calverify.results["Number of events to process"], 13)
+ self.assertEqual(calverify.results["Number of events to process"], self.number_to_process)
self.verifyResultsByUID(calverify.results["Bad iCalendar data"], set((
)))
Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py 2013-05-30 21:36:06 UTC (rev 11277)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/implicit.py 2013-05-30 21:38:10 UTC (rev 11278)
@@ -136,6 +136,15 @@
# If action is remove we actually need to get state from the existing scheduling object resource
if self.action == "remove":
+
+ # If the new data has no organizer, then there must also be no attendees
+ if self.organizer is None and self.attendees:
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "organizer-allowed"),
+ "Organizer removal also requires attendees to be removed.",
+ ))
+
# Also make sure that we return the new calendar being written rather than the old one
# when the implicit action is executed
self.return_calendar = calendar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130530/938298f1/attachment.html>
More information about the calendarserver-changes
mailing list