<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14975] CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14975">14975</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2015-07-16 12:02:35 -0700 (Thu, 16 Jul 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fix exception with missing sharee when examining an attachment path.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesreleaseCalendarServer54devtwistedcaldavstorebridgepy">CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/storebridge.py</a></li>
<li><a href="#CalendarServerbranchesreleaseCalendarServer54devtwistedcaldavtesttest_sharingpy">CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/test/test_sharing.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesreleaseCalendarServer54devtwistedcaldavstorebridgepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/storebridge.py (14974 => 14975)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/storebridge.py        2015-07-16 19:02:11 UTC (rev 14974)
+++ CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/storebridge.py        2015-07-16 19:02:35 UTC (rev 14975)
</span><span class="lines">@@ -2006,34 +2006,35 @@
</span><span class="cx"> userprivs.extend(privileges)
</span><span class="cx">
</span><span class="cx"> principal = self.principalForUID(invite.shareeUID())
</span><del>- aces += (
- # Inheritable specific access for the resource's associated principal.
- davxml.ACE(
- davxml.Principal(davxml.HRef(principal.principalURL())),
- davxml.Grant(*userprivs),
- davxml.Protected(),
- TwistedACLInheritable(),
- ),
- )
-
- if config.EnableProxyPrincipals:
</del><ins>+ if principal is not None:
</ins><span class="cx"> aces += (
</span><del>- # DAV:read/DAV:read-current-user-privilege-set access for this principal's calendar-proxy-read users.
</del><ins>+ # Inheritable specific access for the resource's associated principal.
</ins><span class="cx"> davxml.ACE(
</span><del>- davxml.Principal(davxml.HRef(joinURL(principal.principalURL(), "calendar-proxy-read/"))),
</del><ins>+ davxml.Principal(davxml.HRef(principal.principalURL())),
</ins><span class="cx"> davxml.Grant(*userprivs),
</span><span class="cx"> davxml.Protected(),
</span><span class="cx"> TwistedACLInheritable(),
</span><span class="cx"> ),
</span><del>- # DAV:read/DAV:read-current-user-privilege-set/DAV:write access for this principal's calendar-proxy-write users.
- davxml.ACE(
- davxml.Principal(davxml.HRef(joinURL(principal.principalURL(), "calendar-proxy-write/"))),
- davxml.Grant(*userprivs),
- davxml.Protected(),
- TwistedACLInheritable(),
- ),
</del><span class="cx"> )
</span><span class="cx">
</span><ins>+ if config.EnableProxyPrincipals:
+ aces += (
+ # DAV:read/DAV:read-current-user-privilege-set access for this principal's calendar-proxy-read users.
+ davxml.ACE(
+ davxml.Principal(davxml.HRef(joinURL(principal.principalURL(), "calendar-proxy-read/"))),
+ davxml.Grant(*userprivs),
+ davxml.Protected(),
+ TwistedACLInheritable(),
+ ),
+ # DAV:read/DAV:read-current-user-privilege-set/DAV:write access for this principal's calendar-proxy-write users.
+ davxml.ACE(
+ davxml.Principal(davxml.HRef(joinURL(principal.principalURL(), "calendar-proxy-write/"))),
+ davxml.Grant(*userprivs),
+ davxml.Protected(),
+ TwistedACLInheritable(),
+ ),
+ )
+
</ins><span class="cx"> returnValue(aces)
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesreleaseCalendarServer54devtwistedcaldavtesttest_sharingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/test/test_sharing.py (14974 => 14975)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/test/test_sharing.py        2015-07-16 19:02:11 UTC (rev 14974)
+++ CalendarServer/branches/release/CalendarServer-5.4-dev/twistedcaldav/test/test_sharing.py        2015-07-16 19:02:35 UTC (rev 14975)
</span><span class="lines">@@ -18,6 +18,7 @@
</span><span class="cx"> from twext.web2.dav.util import allDataFromStream
</span><span class="cx"> from twext.web2.http_headers import MimeType
</span><span class="cx"> from twext.web2.iweb import IResponse
</span><ins>+from twext.web2.stream import MemoryStream
</ins><span class="cx">
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue, succeed
</span><span class="cx">
</span><span class="lines">@@ -25,6 +26,7 @@
</span><span class="cx"> from twistedcaldav import sharing
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="cx"> from twistedcaldav.directory.principal import DirectoryCalendarPrincipalResource
</span><ins>+from twistedcaldav.ical import Component
</ins><span class="cx"> from twistedcaldav.resource import CalDAVResource
</span><span class="cx"> from twistedcaldav.sharing import WikiDirectoryService
</span><span class="cx"> from twistedcaldav.test.test_cache import StubResponseCacheResource
</span><span class="lines">@@ -35,6 +37,7 @@
</span><span class="cx"> from txdav.xml.parser import WebDAVDocument
</span><span class="cx">
</span><span class="cx"> from xml.etree.cElementTree import XML
</span><ins>+import urlparse
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> sharedOwnerType = davxml.ResourceType.sharedownercalendar #@UndefinedVariable
</span><span class="lines">@@ -81,6 +84,7 @@
</span><span class="cx"> class FakePrincipal(DirectoryCalendarPrincipalResource):
</span><span class="cx">
</span><span class="cx"> invalid_names = set()
</span><ins>+ missing_names = set()
</ins><span class="cx">
</span><span class="cx"> def __init__(self, cuaddr, test):
</span><span class="cx"> if cuaddr.startswith("mailto:"):
</span><span class="lines">@@ -124,20 +128,20 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-class SharingTests(StoreTestCase):
</del><ins>+class BaseSharingTests(StoreTestCase):
</ins><span class="cx">
</span><span class="cx"> def configure(self):
</span><span class="cx"> """
</span><span class="cx"> Override configuration hook to turn on sharing.
</span><span class="cx"> """
</span><del>- super(SharingTests, self).configure()
</del><ins>+ super(BaseSharingTests, self).configure()
</ins><span class="cx"> self.patch(config.Sharing, "Enabled", True)
</span><span class="cx"> self.patch(config.Sharing.Calendars, "Enabled", True)
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def setUp(self):
</span><del>- yield super(SharingTests, self).setUp()
</del><ins>+ yield super(BaseSharingTests, self).setUp()
</ins><span class="cx">
</span><span class="cx"> def patched(c):
</span><span class="cx"> """
</span><span class="lines">@@ -183,7 +187,7 @@
</span><span class="cx">
</span><span class="cx"> @patched
</span><span class="cx"> def principalForUID(resourceSelf, principalUID):
</span><del>- return FakePrincipal("urn:uuid:" + principalUID, self)
</del><ins>+ return FakePrincipal("urn:uuid:" + principalUID, self) if principalUID not in FakePrincipal.missing_names else None
</ins><span class="cx">
</span><span class="cx"> self.resource = yield self._getResource()
</span><span class="cx">
</span><span class="lines">@@ -192,7 +196,7 @@
</span><span class="cx"> def _refreshRoot(self, request=None):
</span><span class="cx"> if request is None:
</span><span class="cx"> request = norequest()
</span><del>- result = yield super(SharingTests, self)._refreshRoot(request)
</del><ins>+ result = yield super(BaseSharingTests, self)._refreshRoot(request)
</ins><span class="cx"> self.resource = (
</span><span class="cx"> yield self.site.resource.locateChild(request, ["calendar"])
</span><span class="cx"> )[0]
</span><span class="lines">@@ -344,6 +348,9 @@
</span><span class="cx"> return None
</span><span class="cx">
</span><span class="cx">
</span><ins>+
+class SharingTests(BaseSharingTests):
+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_upgradeToShare(self):
</span><span class="cx">
</span><span class="lines">@@ -928,7 +935,7 @@
</span><span class="cx"> ))
</span><span class="cx">
</span><span class="cx"> self.directory.destroyRecord("users", "user02")
</span><del>- self.patch(FakePrincipal, "invalid_names", set(("user02",)))
</del><ins>+ self.patch(FakePrincipal, "missing_names", set(("user02",)))
</ins><span class="cx"> yield self.resource.downgradeFromShare(norequest())
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -959,7 +966,7 @@
</span><span class="cx"> ))
</span><span class="cx">
</span><span class="cx"> self.directory.destroyRecord("users", "user02")
</span><del>- self.patch(FakePrincipal, "invalid_names", set(("user02",)))
</del><ins>+ self.patch(FakePrincipal, "missing_names", set(("user02",)))
</ins><span class="cx">
</span><span class="cx"> yield self._doPOST("""<?xml version="1.0" encoding="utf-8" ?>
</span><span class="cx"> <CS:share xmlns:D="DAV:" xmlns:CS="http://calendarserver.org/ns/">
</span><span class="lines">@@ -1075,7 +1082,7 @@
</span><span class="cx"> href = self._getHRefElementValue(result) + "/"
</span><span class="cx">
</span><span class="cx"> self.directory.destroyRecord("users", "user01")
</span><del>- self.patch(FakePrincipal, "invalid_names", set(("user01",)))
</del><ins>+ self.patch(FakePrincipal, "missing_names", set(("user01",)))
</ins><span class="cx">
</span><span class="cx"> resource = (yield self._getResourceSharer(href))
</span><span class="cx"> yield resource.removeShareeResource(SimpleStoreRequest(self, "DELETE", href))
</span><span class="lines">@@ -1112,7 +1119,7 @@
</span><span class="cx"> ))
</span><span class="cx">
</span><span class="cx"> self.directory.destroyRecord("users", "user01")
</span><del>- self.patch(FakePrincipal, "invalid_names", set(("user01",)))
</del><ins>+ self.patch(FakePrincipal, "missing_names", set(("user01",)))
</ins><span class="cx">
</span><span class="cx"> yield self._doPOSTSharerAccept("""<?xml version='1.0' encoding='UTF-8'?>
</span><span class="cx"> <invite-reply xmlns='http://calendarserver.org/ns/'>
</span><span class="lines">@@ -1199,7 +1206,7 @@
</span><span class="cx"> ))
</span><span class="cx">
</span><span class="cx"> self.directory.destroyRecord("users", "user01")
</span><del>- self.patch(FakePrincipal, "invalid_names", set(("user01",)))
</del><ins>+ self.patch(FakePrincipal, "missing_names", set(("user01",)))
</ins><span class="cx">
</span><span class="cx"> yield self._doPOSTSharerAccept("""<?xml version='1.0' encoding='UTF-8'?>
</span><span class="cx"> <invite-reply xmlns='http://calendarserver.org/ns/'>
</span><span class="lines">@@ -1247,7 +1254,7 @@
</span><span class="cx"> ))
</span><span class="cx">
</span><span class="cx"> self.directory.destroyRecord("users", "user01")
</span><del>- self.patch(FakePrincipal, "invalid_names", set(("user01",)))
</del><ins>+ self.patch(FakePrincipal, "missing_names", set(("user01",)))
</ins><span class="cx">
</span><span class="cx"> yield self._doPOSTSharerAccept("""<?xml version='1.0' encoding='UTF-8'?>
</span><span class="cx"> <invite-reply xmlns='http://calendarserver.org/ns/'>
</span><span class="lines">@@ -1334,7 +1341,7 @@
</span><span class="cx"> ))
</span><span class="cx">
</span><span class="cx"> self.directory.destroyRecord("users", "user01")
</span><del>- self.patch(FakePrincipal, "invalid_names", set(("user01",)))
</del><ins>+ self.patch(FakePrincipal, "missing_names", set(("user01",)))
</ins><span class="cx">
</span><span class="cx"> yield self._doPOSTSharerAccept("""<?xml version='1.0' encoding='UTF-8'?>
</span><span class="cx"> <invite-reply xmlns='http://calendarserver.org/ns/'>
</span><span class="lines">@@ -1454,7 +1461,7 @@
</span><span class="cx"> href = self._getHRefElementValue(result) + "/"
</span><span class="cx">
</span><span class="cx"> self.directory.destroyRecord("users", "user01")
</span><del>- self.patch(FakePrincipal, "invalid_names", set(("user01",)))
</del><ins>+ self.patch(FakePrincipal, "missing_names", set(("user01",)))
</ins><span class="cx">
</span><span class="cx"> data = yield self._doPROPFINDHome()
</span><span class="cx"> self.assertTrue(data is not None)
</span><span class="lines">@@ -1557,3 +1564,156 @@
</span><span class="cx"> customxml.InviteStatusAccepted(),
</span><span class="cx"> ),
</span><span class="cx"> ))
</span><ins>+
+
+
+class DropboxSharingTests(BaseSharingTests):
+
+ def configure(self):
+ """
+ Override configuration hook to turn on dropbox.
+ """
+ super(DropboxSharingTests, self).configure()
+ self.patch(config, "EnableDropBox", True)
+ self.patch(config, "EnableManagedAttachments", False)
+
+
+ @inlineCallbacks
+ def test_dropboxWithMissingInvitee(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))
+ uid = self._getUIDElementValue(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>
+ """ % (uid,)
+ )
+
+ calendar = yield self.calendarUnderTest(name="calendar", home="user01")
+ component = Component.fromString("""BEGIN:VCALENDAR
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+VERSION:2.0
+BEGIN:VEVENT
+DTSTAMP:20051222T205953Z
+CREATED:20060101T150000Z
+DTSTART:20060101T100000Z
+DURATION:PT1H
+SUMMARY:event 1
+UID:event1@ninevah.local
+ATTACH;VALUE=URI:/calendars/users/home1/some-dropbox-id/some-dropbox-id/caldavd.plist
+X-APPLE-DROPBOX:/calendars/users/home1/dropbox/some-dropbox-id
+END:VEVENT
+END:VCALENDAR
+""")
+ yield calendar.createCalendarObjectWithName("dropbox.ics", component)
+ yield self.commit()
+
+ self.directory.destroyRecord("users", "user02")
+ self.patch(FakePrincipal, "missing_names", set(("user02",)))
+
+ # Get dropbox and test ACLs
+ request = SimpleStoreRequest(self, "GET", "/calendars/__uids__/user01/dropbox/some-dropbox-id/")
+ resource = yield request.locateResource("/calendars/__uids__/user01/dropbox/some-dropbox-id/")
+ acl = yield resource.accessControlList(request)
+ self.assertTrue(acl is not None)
+
+
+
+class MamnagedAttachmentSharingTests(BaseSharingTests):
+
+ def configure(self):
+ """
+ Override configuration hook to turn on managed attachments.
+ """
+ super(MamnagedAttachmentSharingTests, self).configure()
+ self.patch(config, "EnableDropBox", False)
+ self.patch(config, "EnableManagedAttachments", True)
+
+
+ @inlineCallbacks
+ def test_attachmentWithMissingInvitee(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))
+ uid = self._getUIDElementValue(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>
+ """ % (uid,)
+ )
+
+ calendar = yield self.calendarUnderTest(name="calendar", home="user01")
+ component = Component.fromString("""BEGIN:VCALENDAR
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+VERSION:2.0
+BEGIN:VEVENT
+DTSTAMP:20051222T205953Z
+CREATED:20060101T150000Z
+DTSTART:20060101T100000Z
+DURATION:PT1H
+SUMMARY:event 1
+UID:event1@ninevah.local
+END:VEVENT
+END:VCALENDAR
+""")
+ obj = yield calendar.createCalendarObjectWithName("dropbox.ics", component)
+ _ignore_attachment, location = yield obj.addAttachment(None, MimeType("text", "plain"), "new.txt", MemoryStream("new attachment text"))
+ yield self.commit()
+
+ self.directory.destroyRecord("users", "user02")
+ self.patch(FakePrincipal, "missing_names", set(("user02",)))
+
+ # Get dropbox and test ACLs
+ location = urlparse.urlparse(location)[2]
+ location = "/".join(location.split("/")[:-1])
+ request = SimpleStoreRequest(self, "GET", location)
+ resource = yield request.locateResource(location)
+ acl = yield resource.accessControlList(request)
+ self.assertTrue(acl is not None)
</ins></span></pre>
</div>
</div>
</body>
</html>