<!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(), &quot;calendar-proxy-read/&quot;))),
</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(), &quot;calendar-proxy-write/&quot;))),
-                        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(), &quot;calendar-proxy-read/&quot;))),
+                            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(), &quot;calendar-proxy-write/&quot;))),
+                            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(&quot;mailto:&quot;):
</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">         &quot;&quot;&quot;
</span><span class="cx">         Override configuration hook to turn on sharing.
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        super(SharingTests, self).configure()
</del><ins>+        super(BaseSharingTests, self).configure()
</ins><span class="cx">         self.patch(config.Sharing, &quot;Enabled&quot;, True)
</span><span class="cx">         self.patch(config.Sharing.Calendars, &quot;Enabled&quot;, 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">             &quot;&quot;&quot;
</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(&quot;urn:uuid:&quot; + principalUID, self)
</del><ins>+            return FakePrincipal(&quot;urn:uuid:&quot; + 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, [&quot;calendar&quot;])
</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(&quot;users&quot;, &quot;user02&quot;)
</span><del>-        self.patch(FakePrincipal, &quot;invalid_names&quot;, set((&quot;user02&quot;,)))
</del><ins>+        self.patch(FakePrincipal, &quot;missing_names&quot;, set((&quot;user02&quot;,)))
</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(&quot;users&quot;, &quot;user02&quot;)
</span><del>-        self.patch(FakePrincipal, &quot;invalid_names&quot;, set((&quot;user02&quot;,)))
</del><ins>+        self.patch(FakePrincipal, &quot;missing_names&quot;, set((&quot;user02&quot;,)))
</ins><span class="cx"> 
</span><span class="cx">         yield self._doPOST(&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
</span><span class="cx">             &lt;CS:share xmlns:D=&quot;DAV:&quot; xmlns:CS=&quot;http://calendarserver.org/ns/&quot;&gt;
</span><span class="lines">@@ -1075,7 +1082,7 @@
</span><span class="cx">         href = self._getHRefElementValue(result) + &quot;/&quot;
</span><span class="cx"> 
</span><span class="cx">         self.directory.destroyRecord(&quot;users&quot;, &quot;user01&quot;)
</span><del>-        self.patch(FakePrincipal, &quot;invalid_names&quot;, set((&quot;user01&quot;,)))
</del><ins>+        self.patch(FakePrincipal, &quot;missing_names&quot;, set((&quot;user01&quot;,)))
</ins><span class="cx"> 
</span><span class="cx">         resource = (yield self._getResourceSharer(href))
</span><span class="cx">         yield resource.removeShareeResource(SimpleStoreRequest(self, &quot;DELETE&quot;, href))
</span><span class="lines">@@ -1112,7 +1119,7 @@
</span><span class="cx">         ))
</span><span class="cx"> 
</span><span class="cx">         self.directory.destroyRecord(&quot;users&quot;, &quot;user01&quot;)
</span><del>-        self.patch(FakePrincipal, &quot;invalid_names&quot;, set((&quot;user01&quot;,)))
</del><ins>+        self.patch(FakePrincipal, &quot;missing_names&quot;, set((&quot;user01&quot;,)))
</ins><span class="cx"> 
</span><span class="cx">         yield self._doPOSTSharerAccept(&quot;&quot;&quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;
</span><span class="cx">             &lt;invite-reply xmlns='http://calendarserver.org/ns/'&gt;
</span><span class="lines">@@ -1199,7 +1206,7 @@
</span><span class="cx">         ))
</span><span class="cx"> 
</span><span class="cx">         self.directory.destroyRecord(&quot;users&quot;, &quot;user01&quot;)
</span><del>-        self.patch(FakePrincipal, &quot;invalid_names&quot;, set((&quot;user01&quot;,)))
</del><ins>+        self.patch(FakePrincipal, &quot;missing_names&quot;, set((&quot;user01&quot;,)))
</ins><span class="cx"> 
</span><span class="cx">         yield self._doPOSTSharerAccept(&quot;&quot;&quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;
</span><span class="cx">             &lt;invite-reply xmlns='http://calendarserver.org/ns/'&gt;
</span><span class="lines">@@ -1247,7 +1254,7 @@
</span><span class="cx">         ))
</span><span class="cx"> 
</span><span class="cx">         self.directory.destroyRecord(&quot;users&quot;, &quot;user01&quot;)
</span><del>-        self.patch(FakePrincipal, &quot;invalid_names&quot;, set((&quot;user01&quot;,)))
</del><ins>+        self.patch(FakePrincipal, &quot;missing_names&quot;, set((&quot;user01&quot;,)))
</ins><span class="cx"> 
</span><span class="cx">         yield self._doPOSTSharerAccept(&quot;&quot;&quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;
</span><span class="cx">             &lt;invite-reply xmlns='http://calendarserver.org/ns/'&gt;
</span><span class="lines">@@ -1334,7 +1341,7 @@
</span><span class="cx">         ))
</span><span class="cx"> 
</span><span class="cx">         self.directory.destroyRecord(&quot;users&quot;, &quot;user01&quot;)
</span><del>-        self.patch(FakePrincipal, &quot;invalid_names&quot;, set((&quot;user01&quot;,)))
</del><ins>+        self.patch(FakePrincipal, &quot;missing_names&quot;, set((&quot;user01&quot;,)))
</ins><span class="cx"> 
</span><span class="cx">         yield self._doPOSTSharerAccept(&quot;&quot;&quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;
</span><span class="cx">             &lt;invite-reply xmlns='http://calendarserver.org/ns/'&gt;
</span><span class="lines">@@ -1454,7 +1461,7 @@
</span><span class="cx">         href = self._getHRefElementValue(result) + &quot;/&quot;
</span><span class="cx"> 
</span><span class="cx">         self.directory.destroyRecord(&quot;users&quot;, &quot;user01&quot;)
</span><del>-        self.patch(FakePrincipal, &quot;invalid_names&quot;, set((&quot;user01&quot;,)))
</del><ins>+        self.patch(FakePrincipal, &quot;missing_names&quot;, set((&quot;user01&quot;,)))
</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):
+        &quot;&quot;&quot;
+        Override configuration hook to turn on dropbox.
+        &quot;&quot;&quot;
+        super(DropboxSharingTests, self).configure()
+        self.patch(config, &quot;EnableDropBox&quot;, True)
+        self.patch(config, &quot;EnableManagedAttachments&quot;, False)
+
+
+    @inlineCallbacks
+    def test_dropboxWithMissingInvitee(self):
+
+        yield self.resource.upgradeToShare()
+
+        yield self._doPOST(&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
+            &lt;CS:share xmlns:D=&quot;DAV:&quot; xmlns:CS=&quot;http://calendarserver.org/ns/&quot;&gt;
+                &lt;CS:set&gt;
+                    &lt;D:href&gt;mailto:user02@example.com&lt;/D:href&gt;
+                    &lt;CS:summary&gt;My Shared Calendar&lt;/CS:summary&gt;
+                    &lt;CS:read-write/&gt;
+                &lt;/CS:set&gt;
+            &lt;/CS:share&gt;
+            &quot;&quot;&quot;)
+
+        propInvite = (yield self.resource.readProperty(customxml.Invite, None))
+        uid = self._getUIDElementValue(propInvite)
+
+        yield self._doPOSTSharerAccept(&quot;&quot;&quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;
+            &lt;invite-reply xmlns='http://calendarserver.org/ns/'&gt;
+              &lt;href xmlns='DAV:'&gt;mailto:user01@example.com&lt;/href&gt;
+              &lt;invite-accepted/&gt;
+              &lt;hosturl&gt;
+                &lt;href xmlns='DAV:'&gt;/calendars/__uids__/user01/calendar/&lt;/href&gt;
+              &lt;/hosturl&gt;
+              &lt;in-reply-to&gt;%s&lt;/in-reply-to&gt;
+              &lt;summary&gt;The Shared Calendar&lt;/summary&gt;
+              &lt;common-name&gt;User 02&lt;/common-name&gt;
+              &lt;first-name&gt;user&lt;/first-name&gt;
+              &lt;last-name&gt;02&lt;/last-name&gt;
+            &lt;/invite-reply&gt;
+            &quot;&quot;&quot; % (uid,)
+        )
+
+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
+        component = Component.fromString(&quot;&quot;&quot;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
+&quot;&quot;&quot;)
+        yield calendar.createCalendarObjectWithName(&quot;dropbox.ics&quot;, component)
+        yield self.commit()
+
+        self.directory.destroyRecord(&quot;users&quot;, &quot;user02&quot;)
+        self.patch(FakePrincipal, &quot;missing_names&quot;, set((&quot;user02&quot;,)))
+
+        # Get dropbox and test ACLs
+        request = SimpleStoreRequest(self, &quot;GET&quot;, &quot;/calendars/__uids__/user01/dropbox/some-dropbox-id/&quot;)
+        resource = yield request.locateResource(&quot;/calendars/__uids__/user01/dropbox/some-dropbox-id/&quot;)
+        acl = yield resource.accessControlList(request)
+        self.assertTrue(acl is not None)
+
+
+
+class MamnagedAttachmentSharingTests(BaseSharingTests):
+
+    def configure(self):
+        &quot;&quot;&quot;
+        Override configuration hook to turn on managed attachments.
+        &quot;&quot;&quot;
+        super(MamnagedAttachmentSharingTests, self).configure()
+        self.patch(config, &quot;EnableDropBox&quot;, False)
+        self.patch(config, &quot;EnableManagedAttachments&quot;, True)
+
+
+    @inlineCallbacks
+    def test_attachmentWithMissingInvitee(self):
+
+        yield self.resource.upgradeToShare()
+
+        yield self._doPOST(&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
+            &lt;CS:share xmlns:D=&quot;DAV:&quot; xmlns:CS=&quot;http://calendarserver.org/ns/&quot;&gt;
+                &lt;CS:set&gt;
+                    &lt;D:href&gt;mailto:user02@example.com&lt;/D:href&gt;
+                    &lt;CS:summary&gt;My Shared Calendar&lt;/CS:summary&gt;
+                    &lt;CS:read-write/&gt;
+                &lt;/CS:set&gt;
+            &lt;/CS:share&gt;
+            &quot;&quot;&quot;)
+
+        propInvite = (yield self.resource.readProperty(customxml.Invite, None))
+        uid = self._getUIDElementValue(propInvite)
+
+        yield self._doPOSTSharerAccept(&quot;&quot;&quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;
+            &lt;invite-reply xmlns='http://calendarserver.org/ns/'&gt;
+              &lt;href xmlns='DAV:'&gt;mailto:user01@example.com&lt;/href&gt;
+              &lt;invite-accepted/&gt;
+              &lt;hosturl&gt;
+                &lt;href xmlns='DAV:'&gt;/calendars/__uids__/user01/calendar/&lt;/href&gt;
+              &lt;/hosturl&gt;
+              &lt;in-reply-to&gt;%s&lt;/in-reply-to&gt;
+              &lt;summary&gt;The Shared Calendar&lt;/summary&gt;
+              &lt;common-name&gt;User 02&lt;/common-name&gt;
+              &lt;first-name&gt;user&lt;/first-name&gt;
+              &lt;last-name&gt;02&lt;/last-name&gt;
+            &lt;/invite-reply&gt;
+            &quot;&quot;&quot; % (uid,)
+        )
+
+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
+        component = Component.fromString(&quot;&quot;&quot;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
+&quot;&quot;&quot;)
+        obj = yield calendar.createCalendarObjectWithName(&quot;dropbox.ics&quot;, component)
+        _ignore_attachment, location = yield obj.addAttachment(None, MimeType(&quot;text&quot;, &quot;plain&quot;), &quot;new.txt&quot;, MemoryStream(&quot;new attachment text&quot;))
+        yield self.commit()
+
+        self.directory.destroyRecord(&quot;users&quot;, &quot;user02&quot;)
+        self.patch(FakePrincipal, &quot;missing_names&quot;, set((&quot;user02&quot;,)))
+
+        # Get dropbox and test ACLs
+        location = urlparse.urlparse(location)[2]
+        location = &quot;/&quot;.join(location.split(&quot;/&quot;)[:-1])
+        request = SimpleStoreRequest(self, &quot;GET&quot;, location)
+        resource = yield request.locateResource(location)
+        acl = yield resource.accessControlList(request)
+        self.assertTrue(acl is not None)
</ins></span></pre>
</div>
</div>

</body>
</html>