[15464] CalendarServer/trunk/twistedcaldav
Revision: 15464 http://trac.calendarserver.org//changeset/15464 Author: cdaboo@apple.com Date: 2016-02-15 11:56:54 -0800 (Mon, 15 Feb 2016) Log Message: ----------- Replies from non-existent sharees should not cause 500 errors. Modified Paths: -------------- CalendarServer/trunk/twistedcaldav/storebridge.py CalendarServer/trunk/twistedcaldav/test/test_sharing.py Modified: CalendarServer/trunk/twistedcaldav/storebridge.py =================================================================== --- CalendarServer/trunk/twistedcaldav/storebridge.py 2016-02-15 16:03:00 UTC (rev 15463) +++ CalendarServer/trunk/twistedcaldav/storebridge.py 2016-02-15 19:56:54 UTC (rev 15464) @@ -3982,8 +3982,6 @@ else: owner = "urn:x-uid:" + ownerPrincipal.principalUID() - shareePrincipal = yield self.principalForUID(jsondata["sharee"]) - if "supported-components" in jsondata: comps = jsondata["supported-components"] if comps: @@ -4023,19 +4021,21 @@ shareePrincipal = yield self.principalForUID(jsondata["sharee"]) # FIXME: use urn:x-uid always? - if jsondata["shared-type"] == "calendar": - # Prefer mailto:, otherwise use principal URL - for cua in shareePrincipal.calendarUserAddresses(): - if cua.startswith("mailto:"): - break + if shareePrincipal is not None: + if jsondata["shared-type"] == "calendar": + # Prefer mailto:, otherwise use principal URL + for cua in shareePrincipal.calendarUserAddresses(): + if cua.startswith("mailto:"): + break + else: + cua = shareePrincipal.principalURL() else: - cua = shareePrincipal.principalURL() + cua = "urn:x-uid:" + shareePrincipal.principalUID() + commonName = shareePrincipal.displayName() else: - cua = "urn:x-uid:" + shareePrincipal.principalUID() + cua = "urn:x-uid:" + jsondata["sharee"] + commonName = "" - commonName = shareePrincipal.displayName() - # record = shareePrincipal.record - typeAttr = {"shared-type": jsondata["shared-type"]} xmldata = customxml.Notification( customxml.DTStamp.fromString(jsondata["dtstamp"]), Modified: CalendarServer/trunk/twistedcaldav/test/test_sharing.py =================================================================== --- CalendarServer/trunk/twistedcaldav/test/test_sharing.py 2016-02-15 16:03:00 UTC (rev 15463) +++ CalendarServer/trunk/twistedcaldav/test/test_sharing.py 2016-02-15 19:56:54 UTC (rev 15464) @@ -1413,6 +1413,50 @@ @inlineCallbacks + def test_shareeReplyWithMissingSharee(self): + + yield self.resource.upgradeToShare() + + yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?> + <CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/"> + <CS:set> + <D:href>mailto:user02@example.com</D:href> + <CS:summary>My Shared Calendar</CS:summary> + <CS:read-write/> + </CS:set> + </CS:share> + """) + propInvite = (yield self.resource.readProperty(customxml.Invite, None)) + uids = self._getUIDElementValues(propInvite) + + yield self._doPOSTSharerAccept("""<?xml version='1.0' encoding='UTF-8'?> + <invite-reply xmlns='http://calendarserver.org/ns/'> + <href xmlns='DAV:'>mailto:user01@example.com</href> + <invite-accepted/> + <hosturl> + <href xmlns='DAV:'>/calendars/__uids__/user01/calendar/</href> + </hosturl> + <in-reply-to>%s</in-reply-to> + <summary>The Shared Calendar</summary> + <common-name>User 02</common-name> + <first-name>user</first-name> + <last-name>02</last-name> + </invite-reply> + """ % (uids["urn:x-uid:user02"],)) + + yield self.directory.removeRecords(((yield self.userUIDFromShortName("user02")),)) + self.assertTrue((yield self.userUIDFromShortName("user02")) is None) + + request = SimpleStoreRequest(self, "GET", "/calendars/__uids__/user01/notification/") + notification = yield request.locateResource("/calendars/__uids__/user01/notification/") + names = yield notification.listChildren() + self.assertEqual(len(names), 1) + note_child = yield notification.getChild(names[0]) + note = yield note_child.text() + self.assertTrue(isinstance(note, str)) + + + @inlineCallbacks def test_hideInvalidSharers(self): yield self.resource.upgradeToShare()
participants (1)
-
source_changes@macosforge.org