[CalendarServer-changes] [13417] CalendarServer/trunk/txdav/caldav/datastore
source_changes at macosforge.org
source_changes at macosforge.org
Fri May 2 18:49:59 PDT 2014
Revision: 13417
http://trac.calendarserver.org//changeset/13417
Author: cdaboo at apple.com
Date: 2014-05-02 18:49:59 -0700 (Fri, 02 May 2014)
Log Message:
-----------
Fix issue where duplicate private comments could prevent scheduling updates.
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/scheduling/caldav/delivery.py
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/caldav/datastore/test/test_implicit.py
Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/caldav/delivery.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/caldav/delivery.py 2014-05-03 01:25:05 UTC (rev 13416)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/caldav/delivery.py 2014-05-03 01:49:59 UTC (rev 13417)
@@ -149,6 +149,21 @@
))
responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=e.msg)
returnValue(False)
+ except Exception as e:
+ log.failure(
+ "Could not process iTIP message",
+ level=LogLevel.debug
+ )
+ log.error(
+ "Could not process iTIP message",
+ )
+ err = HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "recipient-permissions"),
+ "Could not process iTIP message",
+ ))
+ responses.add(recipient.cuaddr, Failure(exc_value=err), reqstatus=iTIPRequestStatus.BAD_REQUEST)
+ returnValue(False)
if store_inbox:
# Copy calendar to inbox
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2014-05-03 01:25:05 UTC (rev 13416)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2014-05-03 01:49:59 UTC (rev 13417)
@@ -2174,7 +2174,7 @@
@inlineCallbacks
- def preservePrivateComments(self, component, inserting):
+ def preservePrivateComments(self, component, inserting, internal_state):
"""
Check for private comments on the old resource and the new resource and re-insert
ones that are lost.
@@ -2207,7 +2207,7 @@
# to raise an error to prevent that so the client bugs can be tracked down.
# Look for properties with duplicate "X-CALENDARSERVER-ATTENDEE-REF" values in the same component
- if component.hasDuplicatePrivateComments(doFix=config.RemoveDuplicatePrivateComments):
+ if component.hasDuplicatePrivateComments(doFix=config.RemoveDuplicatePrivateComments) and internal_state == ComponentUpdateState.NORMAL:
raise DuplicatePrivateCommentsError("Duplicate X-CALENDARSERVER-ATTENDEE-COMMENT properties present.")
@@ -2636,7 +2636,7 @@
self.validAccess(component, inserting, internal_state)
# Preserve private comments
- yield self.preservePrivateComments(component, inserting)
+ yield self.preservePrivateComments(component, inserting, internal_state)
managed_copied, managed_removed = (yield self.resourceCheckAttachments(component, inserting))
@@ -2655,7 +2655,7 @@
yield self._lockUID(component, inserting, internal_state)
# Preserve private comments
- yield self.preservePrivateComments(component, inserting)
+ yield self.preservePrivateComments(component, inserting, internal_state)
# Fix broken VTODOs
yield self.replaceMissingToDoProperties(component, inserting, internal_state)
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_implicit.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_implicit.py 2014-05-03 01:25:05 UTC (rev 13416)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_implicit.py 2014-05-03 01:49:59 UTC (rev 13417)
@@ -17,7 +17,7 @@
from twisted.internet.defer import inlineCallbacks
-from twistedcaldav.ical import Component
+from twistedcaldav.ical import Component, normalize_iCalStr
from txdav.common.datastore.test.util import CommonCommonTests, populateCalendarsFrom
from twisted.trial.unittest import TestCase
@@ -27,9 +27,11 @@
InvalidObjectResourceError, InvalidComponentForStoreError, InvalidUIDError, \
UIDExistsError, UIDExistsElsewhereError
from txdav.caldav.icalendarstore import InvalidComponentTypeError, \
- TooManyAttendeesError, InvalidCalendarAccessError, ComponentUpdateState
+ TooManyAttendeesError, InvalidCalendarAccessError, ComponentUpdateState, \
+ DuplicatePrivateCommentsError
from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE
from txdav.caldav.datastore.test.util import buildCalendarStore
+from txdav.caldav.datastore.sql import CalendarObject
class ImplicitRequests (CommonCommonTests, TestCase):
"""
@@ -1096,3 +1098,179 @@
yield calendar_resource._setComponentInternal(calendar, internal_state=ComponentUpdateState.ORGANIZER_ITIP_UPDATE)
self.assertEqual(calendar_resource.scheduleTag, schedule_tag)
yield self.commit()
+
+
+ @inlineCallbacks
+ def test_validation_duplicatePrivateCommentsOKWIthiTIP(self):
+ """
+ Test that an iTIP update to an organizer event with duplicate private comments
+ does not fail.
+ """
+
+ data1 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data2 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF="urn:uuid:
+ user02";X-CALENDARSERVER-DTSTAMP=20140224T181133Z:Comment
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF="urn:uuid:
+ user02";X-CALENDARSERVER-DTSTAMP=20140224T181133Z:Comment
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data3 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF="urn:uuid:
+ user02";X-CALENDARSERVER-DTSTAMP=20140224T181133Z:Comment
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF="urn:uuid:
+ user02";X-CALENDARSERVER-DTSTAMP=20140224T181133Z:Comment
+END:VEVENT
+END:VCALENDAR
+"""
+
+ calendar_collection = (yield self.calendarUnderTest(home="user01"))
+ calendar = Component.fromString(data1)
+ yield calendar_collection.createCalendarObjectWithName("test.ics", calendar)
+ yield self.commit()
+
+ calendar_resource = (yield self.calendarObjectUnderTest(name="test.ics", home="user01",))
+ calendar = Component.fromString(data2)
+ yield calendar_resource._setComponentInternal(calendar, internal_state=ComponentUpdateState.RAW)
+ yield self.commit()
+
+ calendar_resource = (yield self.calendarObjectUnderTest(name="test.ics", home="user01",))
+ calendar = Component.fromString(data3)
+ yield calendar_resource._setComponentInternal(calendar, internal_state=ComponentUpdateState.ORGANIZER_ITIP_UPDATE)
+ yield self.commit()
+
+ calendar_resource = (yield self.calendarObjectUnderTest(name="test.ics", home="user01",))
+ calendar = Component.fromString(data3)
+ yield self.failUnlessFailure(calendar_resource.setComponent(calendar), DuplicatePrivateCommentsError)
+ yield self.commit()
+
+
+ @inlineCallbacks
+ def test_validation_deleteWithDuplicatePrivateComments(self):
+ """
+ Test that attendee private comments are no longer restored.
+ """
+
+ data1 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data2 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF="urn:uuid:
+ user02";X-CALENDARSERVER-DTSTAMP=20140224T181133Z:Comment
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF="urn:uuid:
+ user02";X-CALENDARSERVER-DTSTAMP=20140224T181133Z:Comment
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data3 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+END:VEVENT
+END:VCALENDAR
+"""
+
+ calendar_collection = (yield self.calendarUnderTest(home="user01"))
+ calendar = Component.fromString(data1)
+ yield calendar_collection.createCalendarObjectWithName("test.ics", calendar)
+ yield self.commit()
+
+ calendar_resource = (yield self.calendarObjectUnderTest(name="test.ics", home="user01",))
+ calendar = Component.fromString(data2)
+ yield calendar_resource._setComponentInternal(calendar, internal_state=ComponentUpdateState.RAW)
+ yield self.commit()
+
+ def raiseHere(otherself, component, inserting, internal_state):
+ if component.hasDuplicatePrivateComments(doFix=False):
+ raise ValueError
+
+ self.patch(CalendarObject, "preservePrivateComments", raiseHere)
+
+ calendar2 = (yield self.calendarUnderTest(name="calendar_1", home="user02"))
+ cobjs = (yield calendar2.calendarObjects())
+ self.assertTrue(len(cobjs) == 1)
+ yield cobjs[0].setComponent(Component.fromString(data3))
+ yield self.commit()
+
+ calendar2 = (yield self.calendarUnderTest(name="calendar_1", home="user02"))
+ cobjs = (yield calendar2.calendarObjects())
+ calendar = yield cobjs[0].component()
+ self.assertTrue('SCHEDULE-STATUS=5.0' in normalize_iCalStr(calendar))
+ yield self.commit()
+
+ calendar2 = (yield self.calendarUnderTest(name="calendar_1", home="user02"))
+ cobjs = (yield calendar2.calendarObjects())
+ self.assertTrue(len(cobjs) == 1)
+ yield cobjs[0].remove()
+ yield self.commit()
+
+ calendar2 = (yield self.calendarUnderTest(name="calendar_1", home="user02"))
+ cobjs = (yield calendar2.calendarObjects())
+ self.assertTrue(len(cobjs) == 0)
+ yield self.commit()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140502/6b95ce90/attachment-0001.html>
More information about the calendarserver-changes
mailing list