[CalendarServer-changes] [14282] CalendarServer/branches/release/CalendarServer-5.4-dev/ twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jan 9 07:49:15 PST 2015
Revision: 14282
http://trac.calendarserver.org//changeset/14282
Author: cdaboo at apple.com
Date: 2015-01-09 07:49:15 -0800 (Fri, 09 Jan 2015)
Log Message:
-----------
Handle sharee actions where the sharer is no longer active or in the directory.
Modified Paths:
--------------
CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/sharing.py
CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/test/test_sharing.py
Modified: CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/sharing.py 2015-01-09 15:46:35 UTC (rev 14281)
+++ CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/sharing.py 2015-01-09 15:49:15 UTC (rev 14282)
@@ -1322,16 +1322,18 @@
ownerPrincipalUID = ownerPrincipal.principalUID()
sharedResource = (yield request.locateResource(hostUrl))
if sharedResource is None:
- # FIXME: have to return here rather than raise to allow removal of a share for a sharer
- # whose principal is no longer valid yet still exists in the store. Really we need to get rid of
- # locateResource calls and just do everything via store objects.
- returnValue(None)
- # Original shared collection is gone - nothing we can do except ignore it
- raise HTTPError(ErrorResponse(
- responsecode.FORBIDDEN,
- (customxml.calendarserver_namespace, "valid-request"),
- "Invalid shared collection",
- ))
+ if state == _BIND_STATUS_DECLINED:
+ # FIXME: have to return here rather than raise to allow removal of a share for a sharer
+ # whose principal is no longer valid yet still exists in the store. Really we need to get rid of
+ # locateResource calls and just do everything via store objects.
+ returnValue(None)
+ else:
+ # Original shared collection is gone - nothing we can do except ignore it
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (customxml.calendarserver_namespace, "valid-request"),
+ "Invalid shared collection",
+ ))
# Change the record
if not processed:
Modified: CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/test/test_sharing.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/test/test_sharing.py 2015-01-09 15:46:35 UTC (rev 14281)
+++ CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/test/test_sharing.py 2015-01-09 15:49:15 UTC (rev 14282)
@@ -733,6 +733,7 @@
)
))
+ self.directory.destroyRecord("users", "user02")
self.patch(FakePrincipal, "invalid_names", set(("user02",)))
propInvite = (yield self.resource.readProperty(customxml.Invite, None))
@@ -867,6 +868,7 @@
),
))
+ self.directory.destroyRecord("users", "user02")
self.patch(FakePrincipal, "invalid_names", set(("user02",)))
yield self.resource.downgradeFromShare(norequest())
@@ -897,6 +899,7 @@
),
))
+ self.directory.destroyRecord("users", "user02")
self.patch(FakePrincipal, "invalid_names", set(("user02",)))
yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
@@ -958,6 +961,7 @@
)
href = self._getHRefElementValue(result) + "/"
+ self.directory.destroyRecord("users", "user01")
self.patch(FakePrincipal, "invalid_names", set(("user01",)))
resource = (yield self._getResourceSharer(href))
@@ -1011,6 +1015,7 @@
)
href = self._getHRefElementValue(result) + "/"
+ self.directory.destroyRecord("users", "user01")
self.patch(FakePrincipal, "invalid_names", set(("user01",)))
resource = (yield self._getResourceSharer(href))
@@ -1021,6 +1026,276 @@
@inlineCallbacks
+ def test_POSTShareeAcceptNewWithMissingSharer(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>
+ """)
+
+ propInvite = (yield self.resource.readProperty(customxml.Invite, None))
+ uid = self._getUIDElementValue(propInvite)
+ self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite(
+ customxml.InviteUser(
+ customxml.UID.fromString(""),
+ davxml.HRef.fromString("urn:uuid:user02"),
+ customxml.CommonName.fromString("USER02"),
+ customxml.InviteAccess(customxml.ReadWriteAccess()),
+ customxml.InviteStatusNoResponse(),
+ ),
+ ))
+
+ self.directory.destroyRecord("users", "user01")
+ self.patch(FakePrincipal, "invalid_names", set(("user01",)))
+
+ yield self._doPOSTSharerAccept("""<?xml version='1.0' encoding='UTF-8'?>
+ <invite-reply xmlns='http://calendarserver.org/ns/'>
+ <href xmlns='DAV:'>mailto:user01 at 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>USER02</common-name>
+ <first-name>user</first-name>
+ <last-name>02</last-name>
+ </invite-reply>
+ """ % (uid,),
+ resultcode=responsecode.FORBIDDEN,
+ )
+
+
+ @inlineCallbacks
+ def test_POSTShareeAcceptExistingWithMissingSharer(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>
+ """)
+
+ propInvite = (yield self.resource.readProperty(customxml.Invite, None))
+ uid = self._getUIDElementValue(propInvite)
+ self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite(
+ customxml.InviteUser(
+ customxml.UID.fromString(""),
+ davxml.HRef.fromString("urn:uuid:user02"),
+ customxml.CommonName.fromString("USER02"),
+ customxml.InviteAccess(customxml.ReadWriteAccess()),
+ customxml.InviteStatusNoResponse(),
+ ),
+ ))
+
+ yield self._doPOSTSharerAccept("""<?xml version='1.0' encoding='UTF-8'?>
+ <invite-reply xmlns='http://calendarserver.org/ns/'>
+ <href xmlns='DAV:'>mailto:user01 at 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>USER02</common-name>
+ <first-name>user</first-name>
+ <last-name>02</last-name>
+ </invite-reply>
+ """ % (uid,),
+ resultcode=responsecode.OK,
+ )
+
+ 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/>
+ </CS:set>
+ </CS:share>
+ """)
+
+ propInvite = (yield self.resource.readProperty(customxml.Invite, None))
+ uid = self._getUIDElementValue(propInvite)
+ self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite(
+ customxml.InviteUser(
+ customxml.UID.fromString(""),
+ davxml.HRef.fromString("urn:uuid:user02"),
+ customxml.CommonName.fromString("USER02"),
+ customxml.InviteAccess(customxml.ReadAccess()),
+ customxml.InviteStatusAccepted(),
+ ),
+ ))
+
+ self.directory.destroyRecord("users", "user01")
+ self.patch(FakePrincipal, "invalid_names", set(("user01",)))
+
+ yield self._doPOSTSharerAccept("""<?xml version='1.0' encoding='UTF-8'?>
+ <invite-reply xmlns='http://calendarserver.org/ns/'>
+ <href xmlns='DAV:'>mailto:user01 at 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>USER02</common-name>
+ <first-name>user</first-name>
+ <last-name>02</last-name>
+ </invite-reply>
+ """ % (uid,),
+ resultcode=responsecode.FORBIDDEN,
+ )
+
+
+ @inlineCallbacks
+ def test_POSTShareeDeclineNewWithMissingSharer(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>
+ """)
+
+ propInvite = (yield self.resource.readProperty(customxml.Invite, None))
+ uid = self._getUIDElementValue(propInvite)
+ self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite(
+ customxml.InviteUser(
+ customxml.UID.fromString(""),
+ davxml.HRef.fromString("urn:uuid:user02"),
+ customxml.CommonName.fromString("USER02"),
+ customxml.InviteAccess(customxml.ReadWriteAccess()),
+ customxml.InviteStatusNoResponse(),
+ ),
+ ))
+
+ self.directory.destroyRecord("users", "user01")
+ self.patch(FakePrincipal, "invalid_names", set(("user01",)))
+
+ yield self._doPOSTSharerAccept("""<?xml version='1.0' encoding='UTF-8'?>
+ <invite-reply xmlns='http://calendarserver.org/ns/'>
+ <href xmlns='DAV:'>mailto:user01 at example.com</href>
+ <invite-declined/>
+ <hosturl>
+ <href xmlns='DAV:'>/calendars/__uids__/user01/calendar/</href>
+ </hosturl>
+ <in-reply-to>%s</in-reply-to>
+ <summary>The Shared Calendar</summary>
+ <common-name>USER02</common-name>
+ <first-name>user</first-name>
+ <last-name>02</last-name>
+ </invite-reply>
+ """ % (uid,),
+ resultcode=responsecode.NO_CONTENT,
+ )
+
+
+ @inlineCallbacks
+ def test_POSTShareeDeclineExistingWithMissingSharer(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>
+ """)
+
+ propInvite = (yield self.resource.readProperty(customxml.Invite, None))
+ uid = self._getUIDElementValue(propInvite)
+ self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite(
+ customxml.InviteUser(
+ customxml.UID.fromString(""),
+ davxml.HRef.fromString("urn:uuid:user02"),
+ customxml.CommonName.fromString("USER02"),
+ customxml.InviteAccess(customxml.ReadWriteAccess()),
+ customxml.InviteStatusNoResponse(),
+ ),
+ ))
+
+ yield self._doPOSTSharerAccept("""<?xml version='1.0' encoding='UTF-8'?>
+ <invite-reply xmlns='http://calendarserver.org/ns/'>
+ <href xmlns='DAV:'>mailto:user01 at 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>USER02</common-name>
+ <first-name>user</first-name>
+ <last-name>02</last-name>
+ </invite-reply>
+ """ % (uid,),
+ resultcode=responsecode.OK,
+ )
+
+ 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/>
+ </CS:set>
+ </CS:share>
+ """)
+
+ propInvite = (yield self.resource.readProperty(customxml.Invite, None))
+ uid = self._getUIDElementValue(propInvite)
+ self.assertEquals(self._clearUIDElementValue(propInvite), customxml.Invite(
+ customxml.InviteUser(
+ customxml.UID.fromString(""),
+ davxml.HRef.fromString("urn:uuid:user02"),
+ customxml.CommonName.fromString("USER02"),
+ customxml.InviteAccess(customxml.ReadAccess()),
+ customxml.InviteStatusAccepted(),
+ ),
+ ))
+
+ self.directory.destroyRecord("users", "user01")
+ self.patch(FakePrincipal, "invalid_names", set(("user01",)))
+
+ yield self._doPOSTSharerAccept("""<?xml version='1.0' encoding='UTF-8'?>
+ <invite-reply xmlns='http://calendarserver.org/ns/'>
+ <href xmlns='DAV:'>mailto:user01 at example.com</href>
+ <invite-declined/>
+ <hosturl>
+ <href xmlns='DAV:'>/calendars/__uids__/user01/calendar/</href>
+ </hosturl>
+ <in-reply-to>%s</in-reply-to>
+ <summary>The Shared Calendar</summary>
+ <common-name>USER02</common-name>
+ <first-name>user</first-name>
+ <last-name>02</last-name>
+ </invite-reply>
+ """ % (uid,),
+ resultcode=responsecode.NO_CONTENT,
+ )
+
+
+ @inlineCallbacks
def test_shareeInviteWithDisabledSharer(self):
yield self.resource.upgradeToShare()
@@ -1064,6 +1339,7 @@
)
href = self._getHRefElementValue(result) + "/"
+ self.directory.destroyRecord("users", "user01")
self.patch(FakePrincipal, "invalid_names", set(("user01",)))
resource = (yield self._getResourceSharer(href))
@@ -1115,6 +1391,7 @@
)
href = self._getHRefElementValue(result) + "/"
+ self.directory.destroyRecord("users", "user01")
self.patch(FakePrincipal, "invalid_names", set(("user01",)))
resource = (yield self._getResourceSharer(href))
@@ -1194,6 +1471,7 @@
sharer="user03"
)
+ self.directory.destroyRecord("users", "user02")
self.patch(FakePrincipal, "invalid_names", set(("user02",)))
resource = yield self._getResource()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150109/0583c87f/attachment-0001.html>
More information about the calendarserver-changes
mailing list