[CalendarServer-changes] [14364] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Tue Feb 3 18:09:55 PST 2015
Revision: 14364
http://trac.calendarserver.org//changeset/14364
Author: cdaboo at apple.com
Date: 2015-02-03 18:09:55 -0800 (Tue, 03 Feb 2015)
Log Message:
-----------
More fixes for missing sharers.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/resource.py
CalendarServer/trunk/twistedcaldav/sharing.py
CalendarServer/trunk/twistedcaldav/storebridge.py
CalendarServer/trunk/twistedcaldav/test/test_sharing.py
CalendarServer/trunk/txweb2/dav/resource.py
Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py 2015-02-02 21:09:23 UTC (rev 14363)
+++ CalendarServer/trunk/twistedcaldav/resource.py 2015-02-04 02:09:55 UTC (rev 14364)
@@ -776,7 +776,7 @@
else:
home = self._newStoreObject.ownerHome()
principal = (yield self.principalForUID(home.uid()))
- returnValue(element.HRef(principal.principalURL()))
+ returnValue(element.HRef(principal.principalURL()) if principal else None)
else:
parent = (yield self.locateParent(request, request.urlForResource(self)))
if parent and isinstance(parent, CalDAVResource):
@@ -1162,7 +1162,8 @@
sharedParent = None
if self.isShareeResource():
# A sharee collection's quota root is the resource owner's root
- sharedParent = (yield request.locateResource(parentForURL(self._share_url)))
+ if self._share_url:
+ sharedParent = (yield request.locateResource(parentForURL(self._share_url)))
else:
parent = (yield self.locateParent(request, request.urlForResource(self)))
if isCalendarCollectionResource(parent) or isAddressBookCollectionResource(parent):
Modified: CalendarServer/trunk/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/sharing.py 2015-02-02 21:09:23 UTC (rev 14363)
+++ CalendarServer/trunk/twistedcaldav/sharing.py 2015-02-04 02:09:55 UTC (rev 14364)
@@ -424,8 +424,7 @@
if principal:
if request:
ownerPrincipal = (yield self.ownerPrincipal(request))
- owner = ownerPrincipal.principalURL()
- if owner == principal.principalURL():
+ if ownerPrincipal is None or ownerPrincipal.principalURL() == principal.principalURL():
returnValue(None)
returnValue(principal.principalURL())
Modified: CalendarServer/trunk/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/storebridge.py 2015-02-02 21:09:23 UTC (rev 14363)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py 2015-02-04 02:09:55 UTC (rev 14364)
@@ -301,7 +301,7 @@
def owner_url(self):
if self.isShareeResource():
- return joinURL(self._share_url, "/")
+ return joinURL(self._share_url, "/") if self._share_url else ""
else:
return self.url()
@@ -3920,15 +3920,21 @@
if jsondata["notification-type"] == "invite-notification":
ownerPrincipal = yield self.principalForUID(jsondata["owner"])
- ownerCN = ownerPrincipal.displayName()
- ownerHomeURL = ownerPrincipal.calendarHomeURLs()[0] if jsondata["shared-type"] == "calendar" else ownerPrincipal.addressBookHomeURLs()[0]
-
- # FIXME: use urn:uuid always?
- if jsondata["shared-type"] == "calendar":
- owner = ownerPrincipal.principalURL()
+ if ownerPrincipal is None:
+ ownerCN = ""
+ ownerCollectionURL = ""
+ owner = "urn:x-uid:" + jsondata["owner"]
else:
- owner = "urn:x-uid:" + ownerPrincipal.principalUID()
+ ownerCN = ownerPrincipal.displayName()
+ ownerHomeURL = ownerPrincipal.calendarHomeURLs()[0] if jsondata["shared-type"] == "calendar" else ownerPrincipal.addressBookHomeURLs()[0]
+ ownerCollectionURL = urljoin(ownerHomeURL, jsondata["ownerName"])
+ # FIXME: use urn:uuid always?
+ if jsondata["shared-type"] == "calendar":
+ owner = ownerPrincipal.principalURL()
+ else:
+ owner = "urn:x-uid:" + ownerPrincipal.principalUID()
+
shareePrincipal = yield self.principalForUID(jsondata["sharee"])
if "supported-components" in jsondata:
@@ -3952,7 +3958,7 @@
invitationBindStatusToXMLMap[jsondata["status"]](),
customxml.InviteAccess(invitationBindModeToXMLMap[jsondata["access"]]()),
customxml.HostURL(
- element.HRef.fromString(urljoin(ownerHomeURL, jsondata["ownerName"])),
+ element.HRef.fromString(ownerCollectionURL),
),
customxml.Organizer(
element.HRef.fromString(owner),
Modified: CalendarServer/trunk/twistedcaldav/test/test_sharing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_sharing.py 2015-02-02 21:09:23 UTC (rev 14363)
+++ CalendarServer/trunk/twistedcaldav/test/test_sharing.py 2015-02-04 02:09:55 UTC (rev 14364)
@@ -102,6 +102,66 @@
@inlineCallbacks
+ def _doPROPFINDHome(self, resultcode=responsecode.MULTI_STATUS):
+ body = """<?xml version="1.0" encoding="UTF-8"?>
+<A:propfind xmlns:A="DAV:">
+ <A:prop>
+ <A:add-member/>
+ <C:allowed-sharing-modes xmlns:C="http://calendarserver.org/ns/"/>
+ <D:autoprovisioned xmlns:D="http://apple.com/ns/ical/"/>
+ <E:bulk-requests xmlns:E="http://me.com/_namespace/"/>
+ <D:calendar-color xmlns:D="http://apple.com/ns/ical/"/>
+ <B:calendar-description xmlns:B="urn:ietf:params:xml:ns:caldav"/>
+ <B:calendar-free-busy-set xmlns:B="urn:ietf:params:xml:ns:caldav"/>
+ <D:calendar-order xmlns:D="http://apple.com/ns/ical/"/>
+ <B:calendar-timezone xmlns:B="urn:ietf:params:xml:ns:caldav"/>
+ <A:current-user-privilege-set/>
+ <B:default-alarm-vevent-date xmlns:B="urn:ietf:params:xml:ns:caldav"/>
+ <B:default-alarm-vevent-datetime xmlns:B="urn:ietf:params:xml:ns:caldav"/>
+ <A:displayname/>
+ <C:getctag xmlns:C="http://calendarserver.org/ns/"/>
+ <C:invite xmlns:C="http://calendarserver.org/ns/"/>
+ <D:language-code xmlns:D="http://apple.com/ns/ical/"/>
+ <D:location-code xmlns:D="http://apple.com/ns/ical/"/>
+ <A:owner/>
+ <C:pre-publish-url xmlns:C="http://calendarserver.org/ns/"/>
+ <C:publish-url xmlns:C="http://calendarserver.org/ns/"/>
+ <C:push-transports xmlns:C="http://calendarserver.org/ns/"/>
+ <C:pushkey xmlns:C="http://calendarserver.org/ns/"/>
+ <A:quota-available-bytes/>
+ <A:quota-used-bytes/>
+ <D:refreshrate xmlns:D="http://apple.com/ns/ical/"/>
+ <A:resource-id/>
+ <A:resourcetype/>
+ <B:schedule-calendar-transp xmlns:B="urn:ietf:params:xml:ns:caldav"/>
+ <B:schedule-default-calendar-URL xmlns:B="urn:ietf:params:xml:ns:caldav"/>
+ <C:source xmlns:C="http://calendarserver.org/ns/"/>
+ <C:subscribed-strip-alarms xmlns:C="http://calendarserver.org/ns/"/>
+ <C:subscribed-strip-attachments xmlns:C="http://calendarserver.org/ns/"/>
+ <C:subscribed-strip-todos xmlns:C="http://calendarserver.org/ns/"/>
+ <B:supported-calendar-component-set xmlns:B="urn:ietf:params:xml:ns:caldav"/>
+ <B:supported-calendar-component-sets xmlns:B="urn:ietf:params:xml:ns:caldav"/>
+ <A:supported-report-set/>
+ <A:sync-token/>
+ </A:prop>
+</A:propfind>
+"""
+ authPrincipal = yield self.actualRoot.findPrincipalForAuthID("user02")
+ request = SimpleStoreRequest(self, "PROPFIND", "/calendars/__uids__/user02/", content=body, authPrincipal=authPrincipal)
+ request.headers.setHeader("content-type", MimeType("text", "xml"))
+ request.headers.setHeader("depth", "1")
+ response = yield self.send(request)
+ response = IResponse(response)
+ self.assertEqual(response.code, resultcode)
+
+ if response.stream:
+ data = yield allDataFromStream(response.stream)
+ returnValue(data)
+ else:
+ returnValue(None)
+
+
+ @inlineCallbacks
def _getResource(self):
request = SimpleStoreRequest(self, "GET", "/calendars/__uids__/user01/calendar/")
resource = yield request.locateResource("/calendars/__uids__/user01/calendar/")
@@ -1234,6 +1294,9 @@
record = yield self.userRecordWithShortName("user01")
yield self.changeRecord(record, self.directory.fieldName.hasCalendars, False)
+ data = yield self._doPROPFINDHome()
+ self.assertTrue(data is not None)
+
resource = (yield self._getResourceSharer(href))
propInvite = yield resource.inviteProperty(None)
self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite(
@@ -1297,6 +1360,9 @@
yield self.directory.removeRecords(((yield self.userUIDFromShortName("user01")),))
self.assertTrue((yield self.userUIDFromShortName("user01")) is None)
+ data = yield self._doPROPFINDHome()
+ self.assertTrue(data is not None)
+
resource = (yield self._getResourceSharer(href))
propInvite = yield resource.inviteProperty(None)
self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite(
@@ -1314,6 +1380,33 @@
@inlineCallbacks
+ def test_shareeNotificationWithMissingSharer(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 at example.com</D:href>
+ <CS:summary>My Shared Calendar</CS:summary>
+ <CS:read-write/>
+ </CS:set>
+ </CS:share>
+ """)
+
+ yield self.directory.removeRecords(((yield self.userUIDFromShortName("user01")),))
+ self.assertTrue((yield self.userUIDFromShortName("user01")) is None)
+
+ request = SimpleStoreRequest(self, "GET", "/calendars/__uids__/user02/notification/")
+ notification = yield request.locateResource("/calendars/__uids__/user02/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()
Modified: CalendarServer/trunk/txweb2/dav/resource.py
===================================================================
--- CalendarServer/trunk/txweb2/dav/resource.py 2015-02-02 21:09:23 UTC (rev 14363)
+++ CalendarServer/trunk/txweb2/dav/resource.py 2015-02-04 02:09:55 UTC (rev 14364)
@@ -706,7 +706,7 @@
def gotChildren(listChildrenResult):
children[:] = list(listChildrenResult)
getChild()
- maybeDeferred(self.listChildren).addCallback(gotChildren)
+ maybeDeferred(self.listChildren).addCallback(gotChildren).addErrback(completionDeferred.errback)
return completionDeferred
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150203/6822906f/attachment-0001.html>
More information about the calendarserver-changes
mailing list