<!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>[13753] CalendarServer/branches/users/gaya/groupsharee2/txdav</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/13753">13753</a></dd>
<dt>Author</dt> <dd>gaya@apple.com</dd>
<dt>Date</dt> <dd>2014-07-11 13:46:58 -0700 (Fri, 11 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>first group sharee tests</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcaldavdatastoresqlpy">CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcaldavdatastoretesttest_sql_sharingpy">CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/test_sql_sharing.py</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavwhogroupspy">CalendarServer/branches/users/gaya/groupsharee2/txdav/who/groups.py</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/accounts/</li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcaldavdatastoretestaccountsgroupShareeAccountsxml">CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/accounts/groupShareeAccounts.xml</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/sql.py (13752 => 13753)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/sql.py        2014-07-11 20:03:42 UTC (rev 13752)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/sql.py        2014-07-11 20:46:58 UTC (rev 13753)
</span><span class="lines">@@ -1820,7 +1820,7 @@
</span><span class="cx">         rows = yield Select(
</span><span class="cx">             [Count(gs.GROUP_ID)],
</span><span class="cx">             From=gs,
</span><del>-            Where=(gs.CALENDAR_HOME_ID == self.ownerHome()._resourceID).And(
</del><ins>+            Where=(gs.CALENDAR_HOME_ID == self.viewerHome()._resourceID).And(
</ins><span class="cx">                 gs.CALENDAR_ID == self._resourceID)
</span><span class="cx">         ).on(self._txn)
</span><span class="cx">         if rows[0][0] &gt; 1:
</span><span class="lines">@@ -1855,9 +1855,9 @@
</span><span class="cx"> 
</span><span class="cx">         gs = schema.GROUP_SHAREE
</span><span class="cx">         rows = yield Select(
</span><del>-            [gs.MEMBERSHIP_HASH, gs.MODE],
</del><ins>+            [gs.MEMBERSHIP_HASH, gs.GROUP_BIND_MODE],
</ins><span class="cx">             From=gs,
</span><del>-            Where=(gs.CALENDAR_HOME_ID == self.ownerHome()._resourceID).And(
</del><ins>+            Where=(gs.CALENDAR_HOME_ID == self.viewerHome()._resourceID).And(
</ins><span class="cx">                 gs.CALENDAR_ID == self._resourceID).And(
</span><span class="cx">                 gs.GROUP_ID == groupID)
</span><span class="cx">         ).on(self._txn)
</span><span class="lines">@@ -1871,7 +1871,7 @@
</span><span class="cx">             if updateMap:
</span><span class="cx">                 yield Update(
</span><span class="cx">                     updateMap,
</span><del>-                    Where=(gs.CALENDAR_HOME_ID == self.ownerHome()._resourceID).And(
</del><ins>+                    Where=(gs.CALENDAR_HOME_ID == self.viewerHome()._resourceID).And(
</ins><span class="cx">                         gs.CALENDAR_ID == self._resourceID).And(
</span><span class="cx">                         gs.GROUP_ID == groupID
</span><span class="cx">                     )
</span><span class="lines">@@ -1881,7 +1881,7 @@
</span><span class="cx">             yield Insert({
</span><span class="cx">                 gs.MEMBERSHIP_HASH: membershipHash,
</span><span class="cx">                 gs.GROUP_BIND_MODE: mode,
</span><del>-                gs.CALENDAR_HOME_ID: self.ownerHome()._resourceID,
</del><ins>+                gs.CALENDAR_HOME_ID: self.viewerHome()._resourceID,
</ins><span class="cx">                 gs.CALENDAR_ID: self._resourceID,
</span><span class="cx">                 gs.GROUP_ID: groupID,
</span><span class="cx">             }).on(self._txn)
</span><span class="lines">@@ -1899,7 +1899,7 @@
</span><span class="cx">             rows = yield Select(
</span><span class="cx">                 [Max(gs.GROUP_BIND_MODE)], # _BIND_MODE_WRITE &gt; _BIND_MODE_READ
</span><span class="cx">                 From=gs,
</span><del>-                Where=(gs.CALENDAR_HOME_ID == self.ownerHome()._resourceID).And(
</del><ins>+                Where=(gs.CALENDAR_HOME_ID == self.viewerHome()._resourceID).And(
</ins><span class="cx">                     gs.CALENDAR_ID == self._resourceID
</span><span class="cx">                 )
</span><span class="cx">             ).on(self._txn)
</span><span class="lines">@@ -1929,7 +1929,7 @@
</span><span class="cx">         record = yield self._txn.directoryService().recordWithUID(shareeUID.decode(&quot;utf-8&quot;))
</span><span class="cx">         if (
</span><span class="cx">             record is None or
</span><del>-            record.recordType != RecordType.group or not (False and
</del><ins>+            record.recordType != RecordType.group or not (
</ins><span class="cx">                 config.Sharing.Enabled and
</span><span class="cx">                 config.Sharing.Calendars.Enabled and
</span><span class="cx">                 config.Sharing.Calendars.Groups.Enabled
</span><span class="lines">@@ -1940,15 +1940,19 @@
</span><span class="cx">             )
</span><span class="cx"> 
</span><span class="cx">         # invite every member of group
</span><del>-        groupID = (yield self._txn.groupByUID(record.uid))[0]
</del><ins>+        shareeViews = set()
+        groupID = (yield self._txn.groupByUID(shareeUID))[0]
</ins><span class="cx">         memberUIDs = yield self._txn.groupMemberUIDs(groupID)
</span><span class="cx">         for memberUID in memberUIDs:
</span><del>-            shareeView = yield self.shareeView(shareeUID)
</del><ins>+            shareeView = yield self.shareeView(memberUID)
</ins><span class="cx">             newMode = _BIND_MODE_GROUP if shareeView is None else shareeView.groupModeAfterAddingOneGroupSharee()
</span><span class="cx">             if newMode is not None:
</span><del>-                yield super(Calendar, self).inviteUIDToShare(memberUID, newMode)
</del><ins>+                # everything but direct share
+                shareeView = yield super(Calendar, self).inviteUIDToShare(memberUID, newMode, summary)
+                yield shareeView.updateShareeGroupLink(shareeUID, mode=mode)
+                shareeViews.add(shareeView)
</ins><span class="cx"> 
</span><del>-        returnValue(None)
</del><ins>+        returnValue(shareeViews)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -1987,16 +1991,45 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         # Cancel invites - we'll just use whatever userid we are given
</span><span class="cx"> 
</span><del>-        shareeView = yield self.shareeView(shareeUID)
-        if shareeView is not None:
-            newMode = yield shareeView.groupModeAfterRemovingOneGroupSharee()
-            if newMode is None:
-                yield super(Calendar, self).uninviteUIDFromShare(shareeUID)
-            else:
-                yield super(Calendar, self).inviteUIDToShare(shareeUID, newMode)
</del><ins>+        record = yield self._txn.directoryService().recordWithUID(shareeUID.decode(&quot;utf-8&quot;))
+        if (
+            record is None or
+            record.recordType != RecordType.group or not (
+                config.Sharing.Enabled and
+                config.Sharing.Calendars.Enabled and
+                config.Sharing.Calendars.Groups.Enabled
+            )
+        ):
+            returnValue(
+                (yield super(Calendar, self).uninviteUIDFromShare(shareeUID))
+            )
</ins><span class="cx"> 
</span><ins>+        # uninvite every member of group
+        groupID = (yield self._txn.groupByUID(shareeUID))[0]
+        memberUIDs = yield self._txn.groupMemberUIDs(groupID)
+        for memberUID in memberUIDs:
+            shareeView = yield self.shareeView(memberUID)
+            if shareeView is not None:
</ins><span class="cx"> 
</span><ins>+                newMode = yield shareeView.groupModeAfterRemovingOneGroupSharee()
+                gs = schema.GROUP_SHAREE
+                yield Delete(
+                    From=gs,
+                    Where=(gs.CALENDAR_HOME_ID == shareeView.viewerHome()._resourceID).And(
+                        gs.CALENDAR_ID == self._resourceID).And(
+                        gs.GROUP_ID == groupID
+                    )
+                )
</ins><span class="cx"> 
</span><ins>+                if newMode is None:
+                    # only group was shared, do delete share
+                    yield super(Calendar, self).uninviteUIDFromShare(memberUID)
+                else:
+                    # multiple groups or group and individual was shared, update to new mode
+                    yield super(Calendar, self).inviteUIDToShare(memberUID, newMode)
+
+
+
</ins><span class="cx"> icalfbtype_to_indexfbtype = {
</span><span class="cx">     &quot;UNKNOWN&quot;         : 0,
</span><span class="cx">     &quot;FREE&quot;            : 1,
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcaldavdatastoretestaccountsgroupShareeAccountsxml"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/accounts/groupShareeAccounts.xml (0 => 13753)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/accounts/groupShareeAccounts.xml                                (rev 0)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/accounts/groupShareeAccounts.xml        2014-07-11 20:46:58 UTC (rev 13753)
</span><span class="lines">@@ -0,0 +1,139 @@
</span><ins>+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+
+&lt;!--
+Copyright (c) 2006-2014 Apple Inc. All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+ --&gt;
+
+&lt;!DOCTYPE accounts SYSTEM &quot;accounts.dtd&quot;&gt;
+
+&lt;directory realm=&quot;Test Realm&quot;&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user01&lt;/short-name&gt;
+            &lt;uid&gt;user01&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000001&lt;/guid&gt;
+            &lt;password&gt;user01&lt;/password&gt;
+            &lt;full-name&gt;User 01&lt;/full-name&gt;
+            &lt;email&gt;user01@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user02&lt;/short-name&gt;
+            &lt;uid&gt;user02&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000002&lt;/guid&gt;
+            &lt;password&gt;user02&lt;/password&gt;
+            &lt;full-name&gt;User 02&lt;/full-name&gt;
+            &lt;email&gt;user02@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user03&lt;/short-name&gt;
+            &lt;uid&gt;user03&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000003&lt;/guid&gt;
+            &lt;password&gt;user03&lt;/password&gt;
+            &lt;full-name&gt;User 03&lt;/full-name&gt;
+            &lt;email&gt;user03@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user04&lt;/short-name&gt;
+            &lt;uid&gt;user04&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000004&lt;/guid&gt;
+            &lt;password&gt;user04&lt;/password&gt;
+            &lt;full-name&gt;User 04&lt;/full-name&gt;
+            &lt;email&gt;user04@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user05&lt;/short-name&gt;
+            &lt;uid&gt;user05&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000005&lt;/guid&gt;
+            &lt;password&gt;user05&lt;/password&gt;
+            &lt;full-name&gt;User 05&lt;/full-name&gt;
+            &lt;email&gt;user05@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user06&lt;/short-name&gt;
+            &lt;uid&gt;user06&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000006&lt;/guid&gt;
+            &lt;password&gt;user06&lt;/password&gt;
+            &lt;full-name&gt;User 06&lt;/full-name&gt;
+            &lt;email&gt;user06@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user07&lt;/short-name&gt;
+            &lt;uid&gt;user07&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000007&lt;/guid&gt;
+            &lt;password&gt;user07&lt;/password&gt;
+            &lt;full-name&gt;User 07&lt;/full-name&gt;
+            &lt;email&gt;user07@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user08&lt;/short-name&gt;
+            &lt;uid&gt;user08&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000008&lt;/guid&gt;
+            &lt;password&gt;user08&lt;/password&gt;
+            &lt;full-name&gt;User 08&lt;/full-name&gt;
+            &lt;email&gt;user08@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user09&lt;/short-name&gt;
+            &lt;uid&gt;user09&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000009&lt;/guid&gt;
+            &lt;password&gt;user09&lt;/password&gt;
+            &lt;full-name&gt;User 09&lt;/full-name&gt;
+            &lt;email&gt;user09@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user10&lt;/short-name&gt;
+            &lt;uid&gt;user10&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000010&lt;/guid&gt;
+            &lt;password&gt;user10&lt;/password&gt;
+            &lt;full-name&gt;User 10&lt;/full-name&gt;
+            &lt;email&gt;user10@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;group&quot;&gt;
+            &lt;short-name&gt;group01&lt;/short-name&gt;
+            &lt;uid&gt;group01&lt;/uid&gt;
+            &lt;guid&gt;20000000-0000-0000-0000-000000000001&lt;/guid&gt;
+            &lt;full-name&gt;Group 01&lt;/full-name&gt;
+            &lt;email&gt;group01@example.com&lt;/email&gt;
+            &lt;member-uid&gt;user01&lt;/member-uid&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;group&quot;&gt;
+            &lt;short-name&gt;group02&lt;/short-name&gt;
+            &lt;uid&gt;group02&lt;/uid&gt;
+            &lt;guid&gt;20000000-0000-0000-0000-000000000002&lt;/guid&gt;
+            &lt;full-name&gt;Group 02&lt;/full-name&gt;
+            &lt;email&gt;group02@example.com&lt;/email&gt;
+            &lt;member-uid&gt;user06&lt;/member-uid&gt;
+            &lt;member-uid&gt;user07&lt;/member-uid&gt;
+            &lt;member-uid&gt;user08&lt;/member-uid&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;group&quot;&gt;
+            &lt;short-name&gt;group03&lt;/short-name&gt;
+            &lt;uid&gt;group03&lt;/uid&gt;
+            &lt;guid&gt;20000000-0000-0000-0000-000000000003&lt;/guid&gt;
+            &lt;full-name&gt;Group 03&lt;/full-name&gt;
+            &lt;email&gt;group03@example.com&lt;/email&gt;
+            &lt;member-uid&gt;user07&lt;/member-uid&gt;
+            &lt;member-uid&gt;user08&lt;/member-uid&gt;
+            &lt;member-uid&gt;user09&lt;/member-uid&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;group&quot;&gt;
+            &lt;short-name&gt;group04&lt;/short-name&gt;
+            &lt;uid&gt;group04&lt;/uid&gt;
+            &lt;guid&gt;20000000-0000-0000-0000-000000000004&lt;/guid&gt;
+            &lt;full-name&gt;Group 04&lt;/full-name&gt;
+            &lt;member-uid&gt;group02&lt;/member-uid&gt;
+            &lt;member-uid&gt;group03&lt;/member-uid&gt;
+            &lt;member-uid&gt;user10&lt;/member-uid&gt;
+        &lt;/record&gt;
+&lt;/directory&gt;
</ins></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcaldavdatastoretesttest_sql_sharingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/test_sql_sharing.py (13752 => 13753)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/test_sql_sharing.py        2014-07-11 20:03:42 UTC (rev 13752)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/test/test_sql_sharing.py        2014-07-11 20:46:58 UTC (rev 13753)
</span><span class="lines">@@ -15,20 +15,25 @@
</span><span class="cx"> ##
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+from twext.python.clsprop import classproperty
+from twext.python.filepath import CachingFilePath as FilePath
</ins><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="cx"> from twisted.trial.unittest import TestCase
</span><del>-
-from twext.python.clsprop import classproperty
-from txdav.common.datastore.test.util import CommonCommonTests, \
-    populateCalendarsFrom
-from txdav.common.datastore.sql_tables import _BIND_MODE_READ, \
-    _BIND_STATUS_INVITED, _BIND_MODE_DIRECT, _BIND_STATUS_ACCEPTED
</del><ins>+from twistedcaldav import customxml
+from twistedcaldav.stdconfig import config
</ins><span class="cx"> from txdav.base.propertystore.base import PropertyName
</span><ins>+from txdav.common.datastore.sql_tables import _BIND_MODE_DIRECT
+from txdav.common.datastore.sql_tables import _BIND_MODE_GROUP
+from txdav.common.datastore.sql_tables import _BIND_MODE_READ
+from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE
+from txdav.common.datastore.sql_tables import _BIND_STATUS_ACCEPTED
+from txdav.common.datastore.sql_tables import _BIND_STATUS_INVITED
+from txdav.common.datastore.test.util import CommonCommonTests
+from txdav.common.datastore.test.util import populateCalendarsFrom
</ins><span class="cx"> from txdav.xml.base import WebDAVTextElement
</span><del>-from twistedcaldav import customxml
</del><span class="cx"> from txdav.xml.element import registerElement, registerElementClass
</span><ins>+import os
</ins><span class="cx"> 
</span><del>-
</del><span class="cx"> class BaseSharingTests(CommonCommonTests, TestCase):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Test store-based calendar sharing.
</span><span class="lines">@@ -581,6 +586,518 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+class GroupSharing(BaseSharingTests):
+    &quot;&quot;&quot;
+    Test store-based group book sharing.
+    &quot;&quot;&quot;
+
+    @inlineCallbacks
+    def setUp(self):
+        yield super(BaseSharingTests, self).setUp()
+
+        accountsFilePath = FilePath(
+            os.path.join(os.path.dirname(__file__), &quot;accounts&quot;)
+        )
+        yield self.buildStoreAndDirectory(
+            accounts=accountsFilePath.child(&quot;groupShareeAccounts.xml&quot;),
+            #resources=accountsFilePath.child(&quot;resources.xml&quot;),
+        )
+        yield self.populate()
+
+        self.paths = {}
+
+
+    def configure(self):
+        super(GroupSharing, self).configure()
+        config.Sharing.Enabled = True
+        config.Sharing.Calendars.Enabled = True
+        config.Sharing.Calendars.Groups.Enabled = True
+        config.Sharing.Calendars.Groups.ReconciliationDelaySeconds = 0
+
+
+    @inlineCallbacks
+    def _check_notifications(self, home, items):
+        notifyHome = yield self.transactionUnderTest().notificationsWithUID(home)
+        notifications = yield notifyHome.listNotificationObjects()
+        self.assertEqual(set(notifications), set(items))
+
+
+    @inlineCallbacks
+    def test_no_shares(self):
+        &quot;&quot;&quot;
+        Test that initially there are no shares.
+        &quot;&quot;&quot;
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+
+
+    @inlineCallbacks
+    def test_invite_sharee(self):
+        &quot;&quot;&quot;
+        Test invite/uninvite creates/removes shares and notifications.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViews = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViews), 3)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        shareeViews = sorted(shareeViews, key=lambda shareeView: shareeView.viewerHome().uid())
+        invites = sorted(invites, key=lambda invitee: invitee.shareeUID)
+        for i in range(3):
+            self.assertEqual(invites[i].uid, shareeViews[i].shareUID())
+            self.assertEqual(invites[i].ownerUID, &quot;user01&quot;)
+            self.assertEqual(invites[i].shareeUID, shareeViews[i].viewerHome().uid())
+            self.assertEqual(invites[i].mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeViews[i].effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invites[i].status, _BIND_STATUS_INVITED)
+            self.assertEqual(invites[i].summary, &quot;summary&quot;)
+        #inviteUID = shareeView.shareUID()
+
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        '''
+        sharedParent = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;user01&quot;)
+        self.assertTrue(sharedParent is None)
+        #yield self._check_notifications(&quot;user02&quot;, [inviteUID, ])
+
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        self.assertTrue(group.isShared())
+
+        yield self.commit()
+        '''
+
+        # Uninvite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        self.assertTrue(calendar.isShared())
+
+        yield calendar.uninviteUIDFromShare(&quot;group02&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertTrue(calendar.isShared())
+
+        yield self._check_notifications(&quot;user06&quot;, [])
+        yield self._check_notifications(&quot;user07&quot;, [])
+        yield self._check_notifications(&quot;user08&quot;, [])
+
+        yield self.commit()
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+        yield calendar.setShared(False)
+        self.assertFalse(calendar.isShared())
+
+
+    @inlineCallbacks
+    def test_accept_share(self):
+        &quot;&quot;&quot;
+        Test that invite+accept creates shares and notifications.
+        &quot;&quot;&quot;
+
+        # Invite
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        invites = yield group.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(group.isShared())
+
+        shareeView = yield group.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        invites = yield group.sharingInvites()
+        self.assertEqual(len(invites), 1)
+        inviteUID = shareeView.shareUID()
+
+        sharedParent = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;user01&quot;)
+        self.assertTrue(sharedParent is None)
+
+        yield self._check_notifications(&quot;user02&quot;, [inviteUID, ])
+
+        self.assertTrue(group.isShared())
+
+        yield self.commit()
+
+        # Accept
+        shareeHome = yield self.calendarHomeUnderTest(name=&quot;user02&quot;)
+        yield shareeHome.acceptShare(inviteUID)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.group1_children)
+        yield self._check_notifications(&quot;user01&quot;, [inviteUID + &quot;-reply&quot;, ])
+
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        self.assertTrue(group.isShared())
+
+        yield self.commit()
+
+        # Re-accept
+        shareeHome = yield self.calendarHomeUnderTest(name=&quot;user02&quot;)
+        yield shareeHome.acceptShare(inviteUID)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.group1_children)
+        yield self._check_notifications(&quot;user01&quot;, [inviteUID + &quot;-reply&quot;, ])
+
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        self.assertTrue(group.isShared())
+
+
+    @inlineCallbacks
+    def test_decline_share(self):
+        &quot;&quot;&quot;
+        Test that invite+decline does not create shares but does create notifications.
+        &quot;&quot;&quot;
+
+        # Invite
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        invites = yield group.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(group.isShared())
+
+        shareeView = yield group.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        invites = yield group.sharingInvites()
+        self.assertEqual(len(invites), 1)
+        inviteUID = shareeView.shareUID()
+
+        sharedParent = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;user01&quot;)
+        self.assertTrue(sharedParent is None)
+
+        yield self._check_notifications(&quot;user02&quot;, [inviteUID, ])
+
+        self.assertTrue(group.isShared())
+
+        yield self.commit()
+
+        # Decline
+        shareeHome = yield self.calendarHomeUnderTest(name=&quot;user02&quot;)
+        yield shareeHome.declineShare(inviteUID)
+
+        sharedParent = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;user01&quot;)
+        self.assertTrue(sharedParent is None)
+
+        yield self._check_notifications(&quot;user01&quot;, [inviteUID + &quot;-reply&quot;, ])
+
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        self.assertTrue(group.isShared())
+
+        yield self.commit()
+
+        # Re-decline
+        shareeHome = yield self.calendarHomeUnderTest(name=&quot;user02&quot;)
+        yield shareeHome.declineShare(inviteUID)
+
+        sharedParent = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;user01&quot;)
+        self.assertTrue(sharedParent is None)
+
+        yield self._check_notifications(&quot;user01&quot;, [inviteUID + &quot;-reply&quot;, ])
+
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        self.assertTrue(group.isShared())
+
+
+    @inlineCallbacks
+    def test_accept_decline_share(self):
+        &quot;&quot;&quot;
+        Test that invite+accept/decline creates/removes shares and notifications.
+        Decline via the home.
+        &quot;&quot;&quot;
+
+        # Invite
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        invites = yield group.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(group.isShared())
+
+        shareeView = yield group.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        invites = yield group.sharingInvites()
+        self.assertEqual(len(invites), 1)
+        inviteUID = shareeView.shareUID()
+
+        sharedParent = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;user01&quot;)
+        self.assertTrue(sharedParent is None)
+
+        yield self._check_notifications(&quot;user02&quot;, [inviteUID, ])
+
+        self.assertTrue(group.isShared())
+
+        yield self.commit()
+
+        # Accept
+        shareeHome = yield self.calendarHomeUnderTest(name=&quot;user02&quot;)
+        yield shareeHome.acceptShare(inviteUID)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.group1_children)
+        yield self._check_notifications(&quot;user01&quot;, [inviteUID + &quot;-reply&quot;, ])
+
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        self.assertTrue(group.isShared())
+
+        yield self.commit()
+
+        # Decline
+        shareeHome = yield self.calendarHomeUnderTest(name=&quot;user02&quot;)
+        yield shareeHome.declineShare(inviteUID)
+
+        sharedParent = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;user01&quot;)
+        self.assertTrue(sharedParent is None)
+
+        yield self._check_notifications(&quot;user01&quot;, [inviteUID + &quot;-reply&quot;, ])
+
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        self.assertTrue(group.isShared())
+
+
+    @inlineCallbacks
+    def test_accept_remove_share(self):
+        &quot;&quot;&quot;
+        Test that invite+accept/decline creates/removes shares and notifications.
+        Decline via the shared collection (removal).
+        &quot;&quot;&quot;
+
+        # Invite
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        invites = yield group.sharingInvites()
+        self.assertEqual(len(invites), 0)
+
+        shareeView = yield group.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        invites = yield group.sharingInvites()
+        self.assertEqual(len(invites), 1)
+        inviteUID = shareeView.shareUID()
+
+        sharedParent = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;user01&quot;)
+        self.assertTrue(sharedParent is None)
+
+        yield self._check_notifications(&quot;user02&quot;, [inviteUID, ])
+
+        yield self.commit()
+
+        # Accept
+        shareeHome = yield self.calendarHomeUnderTest(name=&quot;user02&quot;)
+        yield shareeHome.acceptShare(inviteUID)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.group1_children)
+        yield self._check_notifications(&quot;user01&quot;, [inviteUID + &quot;-reply&quot;, ])
+
+        yield self.commit()
+
+        # Delete
+        group = yield self.calendarObjectUnderTest(home=&quot;user02&quot;, calendar_name=&quot;user01&quot;, name=&quot;group1.vcf&quot;)
+        yield group.deleteShare()
+
+        sharedParent = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;user01&quot;)
+        self.assertTrue(sharedParent is None)
+
+        yield self._check_notifications(&quot;user01&quot;, [inviteUID + &quot;-reply&quot;, ])
+
+
+    @inlineCallbacks
+    def test_accept_two_groups(self):
+        &quot;&quot;&quot;
+        Test that accept of two groups works.
+        &quot;&quot;&quot;
+
+        # Two shares
+        inviteUID1 = yield self._createGroupShare(groupname=&quot;group1.vcf&quot;)
+        inviteUID2 = yield self._createGroupShare(groupname=&quot;group2.vcf&quot;)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.all_children)
+        yield self._check_notifications(&quot;user01&quot;, [inviteUID1 + &quot;-reply&quot;, inviteUID2 + &quot;-reply&quot;, ])
+
+
+    @inlineCallbacks
+    def test_accept_uninvite_two_groups(self):
+        &quot;&quot;&quot;
+        Test that accept of two groups works, then uninvite each one.
+        &quot;&quot;&quot;
+
+        # Two shares
+        inviteUID1 = yield self._createGroupShare(groupname=&quot;group1.vcf&quot;)
+        inviteUID2 = yield self._createGroupShare(groupname=&quot;group2.vcf&quot;)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.all_children)
+        yield self._check_notifications(&quot;user01&quot;, [inviteUID1 + &quot;-reply&quot;, inviteUID2 + &quot;-reply&quot;, ])
+
+        yield self.commit()
+
+        # Uninvite one
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        yield group.uninviteUIDFromShare(&quot;user02&quot;)
+        invites = yield group.sharingInvites()
+        self.assertEqual(len(invites), 0)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.group2_children)
+
+        shared = yield self.calendarObjectUnderTest(home=&quot;user02&quot;, calendar_name=&quot;user01&quot;, name=&quot;group1.vcf&quot;)
+        self.assertTrue(shared is None)
+        shared = yield self.calendarObjectUnderTest(home=&quot;user02&quot;, calendar_name=&quot;user01&quot;, name=&quot;card2.vcf&quot;)
+        self.assertTrue(shared is None)
+
+        yield self.commit()
+
+        # Uninvite other
+        group = yield self.calendarObjectUnderTest(home=&quot;user02&quot;, calendar_name=&quot;user01&quot;, name=&quot;group2.vcf&quot;)
+        yield group.uninviteUIDFromShare(&quot;user02&quot;)
+        invites = yield group.sharingInvites()
+        self.assertEqual(len(invites), 0)
+
+        sharedParent = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;user01&quot;)
+        self.assertTrue(sharedParent is None)
+
+
+    @inlineCallbacks
+    def test_accept_decline_two_groups(self):
+        &quot;&quot;&quot;
+        Test that accept of two groups works, then decline each one.
+        &quot;&quot;&quot;
+
+        # Two shares
+        inviteUID1 = yield self._createGroupShare(groupname=&quot;group1.vcf&quot;)
+        inviteUID2 = yield self._createGroupShare(groupname=&quot;group2.vcf&quot;)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.all_children)
+        yield self._check_notifications(&quot;user01&quot;, [inviteUID1 + &quot;-reply&quot;, inviteUID2 + &quot;-reply&quot;, ])
+
+        yield self.commit()
+
+        # Decline one
+        shareeHome = yield self.calendarHomeUnderTest(name=&quot;user02&quot;)
+        yield shareeHome.declineShare(inviteUID1)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.group2_children)
+
+        shared = yield self.calendarObjectUnderTest(home=&quot;user02&quot;, calendar_name=&quot;user01&quot;, name=&quot;group1.vcf&quot;)
+        self.assertTrue(shared is None)
+        shared = yield self.calendarObjectUnderTest(home=&quot;user02&quot;, calendar_name=&quot;user01&quot;, name=&quot;card2.vcf&quot;)
+        self.assertTrue(shared is None)
+
+        yield self.commit()
+
+        # Decline other
+        shareeHome = yield self.calendarHomeUnderTest(name=&quot;user02&quot;)
+        yield shareeHome.declineShare(inviteUID2)
+
+        sharedParent = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;user01&quot;)
+        self.assertTrue(sharedParent is None)
+
+
+    @inlineCallbacks
+    def test_accept_two_groups_different_access(self):
+        &quot;&quot;&quot;
+        Test that accept of two groups works, then uninvite each one.
+        &quot;&quot;&quot;
+
+        # Two shares
+        inviteUID1 = yield self._createGroupShare(groupname=&quot;group1.vcf&quot;)
+        inviteUID2 = yield self._createGroupShare(groupname=&quot;group2.vcf&quot;, mode=_BIND_MODE_WRITE)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.all_children)
+        yield self._check_notifications(&quot;user01&quot;, [inviteUID1 + &quot;-reply&quot;, inviteUID2 + &quot;-reply&quot;, ])
+
+        # Read only for all, write for group2's items
+        yield self._check_read_only(&quot;user02&quot;, &quot;user01&quot;, [&quot;group1.vcf&quot;, &quot;card2.vcf&quot;, ])
+        yield self._check_read_write(&quot;user02&quot;, &quot;user01&quot;, [&quot;group2.vcf&quot;, &quot;card1.vcf&quot;, &quot;card3.vcf&quot;, ])
+
+        yield self.commit()
+
+        # Decline one
+        shareeHome = yield self.calendarHomeUnderTest(name=&quot;user02&quot;)
+        yield shareeHome.declineShare(inviteUID2)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.group1_children)
+
+        yield self._check_read_only(&quot;user02&quot;, &quot;user01&quot;, [&quot;group1.vcf&quot;, &quot;card1.vcf&quot;, &quot;card2.vcf&quot;, ])
+
+        shared = yield self.calendarObjectUnderTest(home=&quot;user02&quot;, calendar_name=&quot;user01&quot;, name=&quot;group2.vcf&quot;)
+        self.assertTrue(shared is None)
+        shared = yield self.calendarObjectUnderTest(home=&quot;user02&quot;, calendar_name=&quot;user01&quot;, name=&quot;card3.vcf&quot;)
+        self.assertTrue(shared is None)
+
+        yield self.commit()
+
+        # Decline other
+        shareeHome = yield self.calendarHomeUnderTest(name=&quot;user02&quot;)
+        yield shareeHome.declineShare(inviteUID1)
+
+        sharedParent = yield self.calendarUnderTest(home=&quot;user02&quot;, name=&quot;user01&quot;)
+        self.assertTrue(sharedParent is None)
+
+
+
+class MixedSharing(BaseSharingTests):
+    &quot;&quot;&quot;
+    Test store-based combined address book and group book sharing.
+    &quot;&quot;&quot;
+
+    @inlineCallbacks
+    def test_calendar_ro_then_groups(self):
+
+        # Share address book read-only
+        shareeName = yield self._createShare()
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.fully_shared_children)
+        yield self._check_read_only(&quot;user02&quot;, &quot;user01&quot;, self.all_children)
+        yield self._check_read_write(&quot;user02&quot;, &quot;user01&quot;, [])
+        yield self._check_notifications(&quot;user02&quot;, [shareeName, ])
+
+        # Add group1 read-write
+        inviteUID1 = yield self._createGroupShare(groupname=&quot;group1.vcf&quot;, mode=_BIND_MODE_WRITE)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.fully_shared_children)
+        yield self._check_read_only(&quot;user02&quot;, &quot;user01&quot;, [&quot;group2.vcf&quot;, &quot;card3.vcf&quot;, ])
+        yield self._check_read_write(&quot;user02&quot;, &quot;user01&quot;, [&quot;group1.vcf&quot;, &quot;card1.vcf&quot;, &quot;card2.vcf&quot;, ])
+        yield self._check_notifications(&quot;user02&quot;, [shareeName, inviteUID1, ])
+
+        # Add group2 read-write
+        inviteUID2 = yield self._createGroupShare(groupname=&quot;group2.vcf&quot;, mode=_BIND_MODE_WRITE)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.fully_shared_children)
+        yield self._check_read_only(&quot;user02&quot;, &quot;user01&quot;, [])
+        yield self._check_read_write(&quot;user02&quot;, &quot;user01&quot;, self.all_children)
+        yield self._check_notifications(&quot;user02&quot;, [shareeName, inviteUID1, inviteUID2])
+
+        # Uninvite group1
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        yield group.uninviteUIDFromShare(&quot;user02&quot;)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.fully_shared_children)
+        yield self._check_read_only(&quot;user02&quot;, &quot;user01&quot;, [&quot;group1.vcf&quot;, &quot;card2.vcf&quot;, ])
+        yield self._check_read_write(&quot;user02&quot;, &quot;user01&quot;, [&quot;group2.vcf&quot;, &quot;card1.vcf&quot;, &quot;card3.vcf&quot;, ])
+
+        # Uninvite group2
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group2.vcf&quot;)
+        yield group.uninviteUIDFromShare(&quot;user02&quot;)
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.fully_shared_children)
+        yield self._check_read_only(&quot;user02&quot;, &quot;user01&quot;, self.all_children)
+        yield self._check_read_write(&quot;user02&quot;, &quot;user01&quot;, [])
+
+
+    @inlineCallbacks
+    def test_calendar_ro_then_group_no_accept(self):
+
+        # Share address book read-only
+        shareeName = yield self._createShare()
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.fully_shared_children)
+        yield self._check_read_only(&quot;user02&quot;, &quot;user01&quot;, self.all_children)
+        yield self._check_read_write(&quot;user02&quot;, &quot;user01&quot;, [])
+        yield self._check_notifications(&quot;user02&quot;, [shareeName, ])
+
+        # Add group1 read-write - but do not accept
+        group = yield self.calendarObjectUnderTest(home=&quot;user01&quot;, calendar_name=&quot;calendar&quot;, name=&quot;group1.vcf&quot;)
+        invited = yield group.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_WRITE, &quot;summary&quot;)
+        yield self._check_notifications(&quot;user02&quot;, [shareeName, invited.shareUID(), ])
+
+        yield self._check_calendar(&quot;user02&quot;, &quot;user01&quot;, self.fully_shared_children)
+        yield self._check_read_only(&quot;user02&quot;, &quot;user01&quot;, self.all_children)
+        yield self._check_read_write(&quot;user02&quot;, &quot;user01&quot;, [])
+
+
+
</ins><span class="cx"> class SharingRevisions(BaseSharingTests):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Test store-based sharing and interaction with revision table.
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavwhogroupspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/who/groups.py (13752 => 13753)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/who/groups.py        2014-07-11 20:03:42 UTC (rev 13752)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/who/groups.py        2014-07-11 20:46:58 UTC (rev 13753)
</span><span class="lines">@@ -453,7 +453,7 @@
</span><span class="cx">         for [calendarID] in rows:
</span><span class="cx">             wp = yield GroupShareeReconciliationWork.reschedule(
</span><span class="cx">                 txn,
</span><del>-                seconds=float(config.Sharing.Calendar.Groups.ReconciliationDelaySeconds),
</del><ins>+                seconds=float(config.Sharing.Calendars.Groups.ReconciliationDelaySeconds),
</ins><span class="cx">                 calendarID=calendarID,
</span><span class="cx">                 groupID=groupID,
</span><span class="cx">             )
</span></span></pre>
</div>
</div>

</body>
</html>