<!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>[14022] CalendarServer/trunk</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/14022">14022</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-09-30 01:39:00 -0700 (Tue, 30 Sep 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Several fixes for group sharing changes. More work still to do.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkconfauthaugmentstestxml">CalendarServer/trunk/conf/auth/augments-test.xml</a></li>
<li><a href="#CalendarServertrunkconfcaldavdtestplist">CalendarServer/trunk/conf/caldavd-test.plist</a></li>
<li><a href="#CalendarServertrunkrequirementsdevtxt">CalendarServer/trunk/requirements-dev.txt</a></li>
<li><a href="#CalendarServertrunkrequirementsstabletxt">CalendarServer/trunk/requirements-stable.txt</a></li>
<li><a href="#CalendarServertrunktwistedcaldavsharingpy">CalendarServer/trunk/twistedcaldav/sharing.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoresqlpy">CalendarServer/trunk/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresqlpy">CalendarServer/trunk/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_group_shareespy">CalendarServer/trunk/txdav/who/test/test_group_sharees.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkconfauthaugmentstestxml"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/conf/auth/augments-test.xml (14021 => 14022)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/conf/auth/augments-test.xml        2014-09-30 08:05:21 UTC (rev 14021)
+++ CalendarServer/trunk/conf/auth/augments-test.xml        2014-09-30 08:39:00 UTC (rev 14022)
</span><span class="lines">@@ -1,23 +1,3 @@
</span><del>-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-Copyright (c) 2006-2014 Apple Inc. All rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-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 "AS IS" 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.
- -->
-
-<!DOCTYPE augments SYSTEM "augments.dtd">
-
</del><span class="cx"> <augments>
</span><span class="cx"> <record>
</span><span class="cx"> <uid>Default</uid>
</span><span class="lines">@@ -79,4 +59,4 @@
</span><span class="cx"> <auto-schedule-mode>decline-always</auto-schedule-mode>
</span><span class="cx"> <auto-accept-group>20000000-0000-0000-0000-000000000001</auto-accept-group>
</span><span class="cx"> </record>
</span><del>-</augments>
</del><ins>+</augments>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="CalendarServertrunkconfcaldavdtestplist"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/conf/caldavd-test.plist (14021 => 14022)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/conf/caldavd-test.plist        2014-09-30 08:05:21 UTC (rev 14021)
+++ CalendarServer/trunk/conf/caldavd-test.plist        2014-09-30 08:39:00 UTC (rev 14022)
</span><span class="lines">@@ -793,6 +793,10 @@
</span><span class="cx">         <dict>
</span><span class="cx">                  <key>Enabled</key>
</span><span class="cx">                  <true/>
</span><ins>+
+                        <!-- Make these short for testing -->
+                 <key>ReconciliationDelaySeconds</key>
+                 <real>0.1</real>
</ins><span class="cx">         </dict>
</span><span class="cx"> </dict>
</span><span class="cx"> <key>AddressBooks</key>
</span></span></pre></div>
<a id="CalendarServertrunkrequirementsdevtxt"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/requirements-dev.txt (14021 => 14022)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/requirements-dev.txt        2014-09-30 08:05:21 UTC (rev 14021)
+++ CalendarServer/trunk/requirements-dev.txt        2014-09-30 08:39:00 UTC (rev 14022)
</span><span class="lines">@@ -7,4 +7,4 @@
</span><span class="cx"> mockldap
</span><span class="cx"> q
</span><span class="cx"> --editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVClientLibrary/trunk@13420#egg=CalDAVClientLibrary
</span><del>---editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@13957#egg=CalDAVTester
</del><ins>+--editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@14021#egg=CalDAVTester
</ins></span></pre></div>
<a id="CalendarServertrunkrequirementsstabletxt"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/requirements-stable.txt (14021 => 14022)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/requirements-stable.txt        2014-09-30 08:05:21 UTC (rev 14021)
+++ CalendarServer/trunk/requirements-stable.txt        2014-09-30 08:39:00 UTC (rev 14022)
</span><span class="lines">@@ -5,7 +5,7 @@
</span><span class="cx"> # For CalendarServer development, don't try to get these projects from PyPI; use svn.
</span><span class="cx">
</span><span class="cx"> -e .
</span><del>--e svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@13987#egg=twextpy
</del><ins>+-e svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@14020#egg=twextpy
</ins><span class="cx"> -e svn+http://svn.calendarserver.org/repository/calendarserver/PyKerberos/trunk@13420#egg=kerberos
</span><span class="cx"> -e svn+http://svn.calendarserver.org/repository/calendarserver/PyCalendar/trunk@13802#egg=pycalendar
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavsharingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/sharing.py (14021 => 14022)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/sharing.py        2014-09-30 08:05:21 UTC (rev 14021)
+++ CalendarServer/trunk/twistedcaldav/sharing.py        2014-09-30 08:39:00 UTC (rev 14022)
</span><span class="lines">@@ -416,8 +416,10 @@
</span><span class="cx"> userid is not allowed.
</span><span class="cx"> """
</span><span class="cx">
</span><del>- # First try to resolve as a principal
</del><ins>+ # First try to resolve as a calendar principal
</ins><span class="cx"> principal = yield self.principalForCalendarUserAddress(userid)
</span><ins>+ if principal is None:
+ principal = yield self.principalForCalendarGroupAddress(userid)
</ins><span class="cx"> if principal:
</span><span class="cx"> if request:
</span><span class="cx"> ownerPrincipal = (yield self.ownerPrincipal(request))
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py (14021 => 14022)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-09-30 08:05:21 UTC (rev 14021)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-09-30 08:39:00 UTC (rev 14022)
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx"> AttachmentSizeTooLarge, UnknownTimezone
</span><span class="cx"> from txdav.caldav.icalendarstore import QuotaExceeded
</span><span class="cx"> from txdav.common.datastore.sql import CommonHome, CommonHomeChild, \
</span><del>- CommonObjectResource, ECALENDARTYPE
</del><ins>+ CommonObjectResource, ECALENDARTYPE, SharingInvitation
</ins><span class="cx"> from txdav.common.datastore.sql_tables import _ATTACHMENTS_MODE_NONE, \
</span><span class="cx"> _ATTACHMENTS_MODE_READ, _ATTACHMENTS_MODE_WRITE, _BIND_MODE_DIRECT, \
</span><span class="cx"> _BIND_MODE_GROUP, _BIND_MODE_GROUP_READ, _BIND_MODE_GROUP_WRITE, \
</span><span class="lines">@@ -1752,17 +1752,47 @@
</span><span class="cx"> resourceID=child._resourceID
</span><span class="cx"> )
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> # ===============================================================================
</span><span class="cx"> # Group sharing
</span><span class="cx"> # ===============================================================================
</span><span class="cx">
</span><ins>+ # We need to handle the case where a sharee is added directly or as a member of one
+ # or more groups. In order to do that we distinguish those cases via the BIND_MODE:
+ #
+ # BIND_MODE_READ, BIND_MODE_WRITE - an individual sharee only (i.e., not a member of
+ # a group also being shared to).
+ #
+ # BIND_MODE_GROUP - a sharee added solely as a member of one or more groups (i.e., not
+ # an individual).
+ #
+ # BIND_MODE_GROUP_READ, BIND_MODE_GROUP_WRITE - a sharee added as both an individual
+ # and as a member of a group). The READ/WRITE state reflects the individual
+ # access granted).
+ #
+ # For the BIND_MODE_GROUP* variants the actual access level is determined by the
+ # max of all the group access levels and the individual access level. That
+ # that is determined by the L{effectiveShareMode} method.
+ #
+ # When adding/removing an individual or reconciling group membership changes, the
+ # actual BIND_MODE in the bind table is determined by one of the _groupModeAfter*
+ # methods.
</ins><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def reconcileGroupSharee(self, groupUID):
</span><span class="cx"> """
</span><del>- reconcile bind table with group members
</del><ins>+ Reconcile bind table with group members. Note that when this is called, changes have
+ already been made to the group being refreshed. So members that have been removed
+ won't appear as a member of the group but will still have an associated bind row.
+
+ What we need to do is get the list of all existing group binds and diff that with the
+ list of expected group binds from all groups shared to this calendar. This means we will
+ end up also reconciling other shared groups that changed. There is no way to prevent that
+ short of recording in the bind table, which groups caused a member to be bound.
</ins><span class="cx"> """
</span><span class="cx"> changed = False
</span><ins>+
+ # First check that the actual group membership has changed
</ins><span class="cx"> if (yield self.updateShareeGroupLink(groupUID)):
</span><span class="cx"> groupID = (yield self._txn.groupByUID(groupUID))[0]
</span><span class="cx"> memberUIDs = yield self._txn.groupMemberUIDs(groupID)
</span><span class="lines">@@ -1874,7 +1904,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=(
</del><ins>+ Where=(gs.CALENDAR_ID == self._resourceID).And(
</ins><span class="cx"> gs.GROUP_ID.In(
</span><span class="cx"> Select(
</span><span class="cx"> [gm.GROUP_ID],
</span><span class="lines">@@ -1886,7 +1916,7 @@
</span><span class="cx"> )
</span><span class="cx"> )
</span><span class="cx"> ).on(self._txn, uid=self.viewerHome().uid())
</span><del>- if rows[0][0] > 1:
</del><ins>+ if rows[0][0] > 0:
</ins><span class="cx"> # no mode change for group shares
</span><span class="cx"> result = {
</span><span class="cx"> _BIND_MODE_GROUP: _BIND_MODE_GROUP,
</span><span class="lines">@@ -1949,9 +1979,8 @@
</span><span class="cx"> returnValue(changed)
</span><span class="cx">
</span><span class="cx">
</span><del>- @classmethod
</del><span class="cx"> @inlineCallbacks
</span><del>- def _effectiveShareMode(cls, bindMode, viewerUID, txn):
</del><ins>+ def _effectiveShareMode(self, bindMode, viewerUID, txn):
</ins><span class="cx"> """
</span><span class="cx"> Get the effective share mode without a calendar object
</span><span class="cx"> """
</span><span class="lines">@@ -1963,7 +1992,7 @@
</span><span class="cx"> rows = yield Select(
</span><span class="cx"> [Max(gs.GROUP_BIND_MODE)], # _BIND_MODE_WRITE > _BIND_MODE_READ
</span><span class="cx"> From=gs,
</span><del>- Where=(
</del><ins>+ Where=(gs.CALENDAR_ID == self._resourceID).And(
</ins><span class="cx"> gs.GROUP_ID.In(
</span><span class="cx"> Select(
</span><span class="cx"> [gm.GROUP_ID],
</span><span class="lines">@@ -1975,7 +2004,11 @@
</span><span class="cx"> )
</span><span class="cx"> )
</span><span class="cx"> ).on(txn, uid=viewerUID)
</span><del>- returnValue(rows[0][0])
</del><ins>+
+ # The result might be empty if the sharee has been removed from the group, but reconciliation has not
+ # yet occurred, so cope with that by giving them the lowest mode since we don't know what the last valid
+ # mode was.
+ returnValue(rows[0][0] if rows[0][0] else _BIND_MODE_READ)
</ins><span class="cx"> else:
</span><span class="cx"> returnValue(bindMode)
</span><span class="cx">
</span><span class="lines">@@ -2004,6 +2037,7 @@
</span><span class="cx"> @type summary: C{str}
</span><span class="cx"> """
</span><span class="cx">
</span><ins>+ # Go direct to individual sharing API if groups are disabled
</ins><span class="cx"> if not (
</span><span class="cx"> config.Sharing.Enabled and
</span><span class="cx"> config.Sharing.Calendars.Enabled and
</span><span class="lines">@@ -2072,22 +2106,29 @@
</span><span class="cx"> @type shareeUID: C{str}
</span><span class="cx"> """
</span><span class="cx">
</span><del>- rows = None
- groupID = (yield self._txn.groupByUID(shareeUID, create=False))[0]
- if groupID is not None:
- gs = schema.GROUP_SHAREE
- rows = yield Select(
- [gs.GROUP_ID],
- From=gs,
- Where=(gs.CALENDAR_ID == self._resourceID).And(
- gs.GROUP_ID == groupID
- ),
- ).on(self._txn)
</del><ins>+ # Go direct to individual sharing API if groups are disabled
+ if 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>+ # Check if the sharee is a group
+ gr = schema.GROUPS
+ gs = schema.GROUP_SHAREE
+ rows = yield Select(
+ [gs.GROUP_ID],
+ From=gs.join(gr, gs.GROUP_ID == gr.GROUP_ID),
+ Where=gr.GROUP_UID == shareeUID
+ ).on(self._txn)
+
</ins><span class="cx"> if rows:
</span><ins>+ groupID = rows[0][0]
</ins><span class="cx"> reinvites = []
</span><del>- # uninvite each member of group
- memberUIDs = yield self._txn.groupMemberUIDs(rows[0][0])
</del><ins>+
+ # Uninvite each member of group
+ memberUIDs = yield self._txn.groupMemberUIDs(groupID)
</ins><span class="cx"> for memberUID in memberUIDs:
</span><span class="cx"> if memberUID != self._home.uid():
</span><span class="cx"> shareeView = yield self.shareeView(memberUID)
</span><span class="lines">@@ -2125,6 +2166,40 @@
</span><span class="cx"> yield super(Calendar, self).inviteUIDToShare(shareeUID, newMode)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @inlineCallbacks
+ def allInvitations(self):
+ """
+ Get list of all invitations (non-direct) to this object.
+ """
+ user_invitations = yield super(Calendar, self).allInvitations()
+
+ # Add groups (before the individuals)
+ gs = schema.GROUP_SHAREE
+ gr = schema.GROUPS
+ rows = yield Select(
+ [gr.GROUP_UID, gs.GROUP_BIND_MODE],
+ From=gs.join(gr, gs.GROUP_ID == gr.GROUP_ID),
+ Where=(gs.CALENDAR_ID == self._resourceID),
+ ).on(self._txn)
+
+ invitations = []
+ for guid, gmode in rows:
+ invite = SharingInvitation(
+ guid,
+ self.ownerHome().name(),
+ self.ownerHome().id(),
+ guid,
+ 0,
+ gmode,
+ _BIND_STATUS_ACCEPTED,
+ "",
+ )
+ invitations.append(invite)
+
+ invitations.extend(user_invitations)
+ returnValue(invitations)
+
+
</ins><span class="cx"> icalfbtype_to_indexfbtype = {
</span><span class="cx"> "UNKNOWN" : 0,
</span><span class="cx"> "FREE" : 1,
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql.py (14021 => 14022)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql.py        2014-09-30 08:05:21 UTC (rev 14021)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py        2014-09-30 08:39:00 UTC (rev 14022)
</span><span class="lines">@@ -5294,8 +5294,7 @@
</span><span class="cx"> return self._bindMode
</span><span class="cx">
</span><span class="cx">
</span><del>- @classmethod
- def _effectiveShareMode(cls, bindMode, viewerUID, txn):
</del><ins>+ def _effectiveShareMode(self, bindMode, viewerUID, txn):
</ins><span class="cx"> """
</span><span class="cx"> Get the effective share mode without a calendar object
</span><span class="cx"> """
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_group_shareespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_group_sharees.py (14021 => 14022)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/test_group_sharees.py        2014-09-30 08:05:21 UTC (rev 14021)
+++ CalendarServer/trunk/txdav/who/test/test_group_sharees.py        2014-09-30 08:39:00 UTC (rev 14022)
</span><span class="lines">@@ -21,12 +21,12 @@
</span><span class="cx"> from twext.enterprise.jobqueue import JobItem
</span><span class="cx"> from twext.python.filepath import CachingFilePath as FilePath
</span><span class="cx"> from twisted.internet import reactor
</span><del>-from twisted.internet.defer import inlineCallbacks, returnValue
</del><ins>+from twisted.internet.defer import inlineCallbacks, returnValue, succeed
</ins><span class="cx"> from twisted.trial import unittest
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="cx"> from txdav.caldav.datastore.test.util import populateCalendarsFrom, CommonCommonTests
</span><span class="cx"> from txdav.who.directory import CalendarDirectoryRecordMixin
</span><del>-from txdav.who.groups import GroupCacher
</del><ins>+from txdav.who.groups import GroupCacher, GroupShareeReconciliationWork
</ins><span class="cx"> import os
</span><span class="cx"> from txdav.common.datastore.sql_tables import _BIND_MODE_GROUP
</span><span class="cx"> from txdav.common.datastore.sql_tables import _BIND_MODE_READ
</span><span class="lines">@@ -262,3 +262,89 @@
</span><span class="cx"> yield calendar.uninviteUIDFromShare("group04")
</span><span class="cx"> noinvites = yield calendar.sharingInvites()
</span><span class="cx"> self.assertEqual(len(noinvites), 0)
</span><ins>+
+
+ @inlineCallbacks
+ def test_group_member_removal_refresh_slow(self):
+ """
+ Test that the sharee list is still valid when a member is removed from a group, but
+ sharee reconciliation has not yet occurred.
+ """
+
+ @inlineCallbacks
+ def expandedMembers(self, records=None, seen=None):
+
+ if self.uid == "group02":
+ returnValue(frozenset())
+ else:
+ returnValue((yield unpatchedExpandedMembers(self, records, seen)))
+
+ unpatchedExpandedMembers = CalendarDirectoryRecordMixin.expandedMembers
+
+ # Prevent sharee reconciliation
+ def _noop(self):
+ return succeed(None)
+ self.patch(GroupShareeReconciliationWork, "doWork", _noop)
+
+ # setup group cacher
+ groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
+ groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+ self.assertEqual(len(groupsToRefresh), 0)
+ wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "group02")
+ self.assertEqual(len(wps), 0)
+
+ yield self._check_notifications("user01", [])
+
+ # Invite
+ calendar = yield self.calendarUnderTest(home="user01", name="calendar")
+ invites = yield calendar.sharingInvites()
+ self.assertEqual(len(invites), 0)
+ self.assertFalse(calendar.isShared())
+
+ yield self._check_notifications("user01", [])
+ shareeViews = yield calendar.inviteUIDToShare("group02", _BIND_MODE_READ)
+ self.assertEqual(len(shareeViews), 3)
+ calendar = yield self.calendarUnderTest(home="user01", name="calendar")
+ invites = yield calendar.sharingInvites()
+ self.assertEqual(len(invites), 3)
+ for invite in invites:
+ shareeView = yield calendar.shareeView(invite.shareeUID)
+ self.assertEqual(invite.ownerUID, "user01")
+ self.assertEqual(invite.uid, shareeView.shareName())
+ self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+ self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+ self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+ self.assertEqual(invite.summary, None)
+ yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+ groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+ self.assertEqual(len(groupsToRefresh), 1)
+
+ # 0 group members
+ self.patch(CalendarDirectoryRecordMixin, "expandedMembers", expandedMembers)
+
+ wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), "group02")
+ self.assertEqual(len(wps), 1)
+ yield self.commit()
+ yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
+
+ calendar = yield self.calendarUnderTest(home="user01", name="calendar")
+ invites = yield calendar.sharingInvites()
+ self.assertEqual(len(invites), 3)
+ for invite in invites:
+ shareeView = yield calendar.shareeView(invite.shareeUID)
+ self.assertEqual(invite.ownerUID, "user01")
+ self.assertEqual(invite.uid, shareeView.shareName())
+ self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+ self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+ self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+ self.assertEqual(invite.summary, None)
+ yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+ yield self._check_notifications("user01", [])
+
+ # Uninvite
+ calendar = yield self.calendarUnderTest(home="user01", name="calendar")
+ yield calendar.uninviteUIDFromShare("group02")
+ noinvites = yield calendar.sharingInvites()
+ self.assertEqual(len(noinvites), 3)
</ins></span></pre>
</div>
</div>
</body>
</html>