<!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] > 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 > _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("utf-8"))
</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"> """
</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("utf-8"))
+ 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"> "UNKNOWN" : 0,
</span><span class="cx"> "FREE" : 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>+<?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 accounts SYSTEM "accounts.dtd">
+
+<directory realm="Test Realm">
+        <record type="user">
+         <short-name>user01</short-name>
+         <uid>user01</uid>
+         <guid>10000000-0000-0000-0000-000000000001</guid>
+         <password>user01</password>
+         <full-name>User 01</full-name>
+         <email>user01@example.com</email>
+        </record>
+        <record type="user">
+         <short-name>user02</short-name>
+         <uid>user02</uid>
+         <guid>10000000-0000-0000-0000-000000000002</guid>
+         <password>user02</password>
+         <full-name>User 02</full-name>
+         <email>user02@example.com</email>
+        </record>
+        <record type="user">
+         <short-name>user03</short-name>
+         <uid>user03</uid>
+         <guid>10000000-0000-0000-0000-000000000003</guid>
+         <password>user03</password>
+         <full-name>User 03</full-name>
+         <email>user03@example.com</email>
+        </record>
+        <record type="user">
+         <short-name>user04</short-name>
+         <uid>user04</uid>
+         <guid>10000000-0000-0000-0000-000000000004</guid>
+         <password>user04</password>
+         <full-name>User 04</full-name>
+         <email>user04@example.com</email>
+        </record>
+        <record type="user">
+         <short-name>user05</short-name>
+         <uid>user05</uid>
+         <guid>10000000-0000-0000-0000-000000000005</guid>
+         <password>user05</password>
+         <full-name>User 05</full-name>
+         <email>user05@example.com</email>
+        </record>
+        <record type="user">
+         <short-name>user06</short-name>
+         <uid>user06</uid>
+         <guid>10000000-0000-0000-0000-000000000006</guid>
+         <password>user06</password>
+         <full-name>User 06</full-name>
+         <email>user06@example.com</email>
+        </record>
+        <record type="user">
+         <short-name>user07</short-name>
+         <uid>user07</uid>
+         <guid>10000000-0000-0000-0000-000000000007</guid>
+         <password>user07</password>
+         <full-name>User 07</full-name>
+         <email>user07@example.com</email>
+        </record>
+        <record type="user">
+         <short-name>user08</short-name>
+         <uid>user08</uid>
+         <guid>10000000-0000-0000-0000-000000000008</guid>
+         <password>user08</password>
+         <full-name>User 08</full-name>
+         <email>user08@example.com</email>
+        </record>
+        <record type="user">
+         <short-name>user09</short-name>
+         <uid>user09</uid>
+         <guid>10000000-0000-0000-0000-000000000009</guid>
+         <password>user09</password>
+         <full-name>User 09</full-name>
+         <email>user09@example.com</email>
+        </record>
+        <record type="user">
+         <short-name>user10</short-name>
+         <uid>user10</uid>
+         <guid>10000000-0000-0000-0000-000000000010</guid>
+         <password>user10</password>
+         <full-name>User 10</full-name>
+         <email>user10@example.com</email>
+        </record>
+        <record type="group">
+         <short-name>group01</short-name>
+         <uid>group01</uid>
+         <guid>20000000-0000-0000-0000-000000000001</guid>
+         <full-name>Group 01</full-name>
+         <email>group01@example.com</email>
+         <member-uid>user01</member-uid>
+        </record>
+        <record type="group">
+         <short-name>group02</short-name>
+         <uid>group02</uid>
+         <guid>20000000-0000-0000-0000-000000000002</guid>
+         <full-name>Group 02</full-name>
+         <email>group02@example.com</email>
+         <member-uid>user06</member-uid>
+         <member-uid>user07</member-uid>
+         <member-uid>user08</member-uid>
+        </record>
+        <record type="group">
+         <short-name>group03</short-name>
+         <uid>group03</uid>
+         <guid>20000000-0000-0000-0000-000000000003</guid>
+         <full-name>Group 03</full-name>
+         <email>group03@example.com</email>
+         <member-uid>user07</member-uid>
+         <member-uid>user08</member-uid>
+         <member-uid>user09</member-uid>
+        </record>
+        <record type="group">
+         <short-name>group04</short-name>
+         <uid>group04</uid>
+         <guid>20000000-0000-0000-0000-000000000004</guid>
+         <full-name>Group 04</full-name>
+         <member-uid>group02</member-uid>
+         <member-uid>group03</member-uid>
+         <member-uid>user10</member-uid>
+        </record>
+</directory>
</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"> """
</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):
+ """
+ Test store-based group book sharing.
+ """
+
+ @inlineCallbacks
+ def setUp(self):
+ yield super(BaseSharingTests, self).setUp()
+
+ accountsFilePath = FilePath(
+ os.path.join(os.path.dirname(__file__), "accounts")
+ )
+ yield self.buildStoreAndDirectory(
+ accounts=accountsFilePath.child("groupShareeAccounts.xml"),
+ #resources=accountsFilePath.child("resources.xml"),
+ )
+ 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):
+ """
+ Test that initially there are no shares.
+ """
+
+ calendar = yield self.calendarUnderTest(home="user01", name="calendar")
+ invites = yield calendar.sharingInvites()
+ self.assertEqual(len(invites), 0)
+
+
+ @inlineCallbacks
+ def test_invite_sharee(self):
+ """
+ Test invite/uninvite creates/removes shares and notifications.
+ """
+
+ # Invite
+ calendar = yield self.calendarUnderTest(home="user01", name="calendar")
+ invites = yield calendar.sharingInvites()
+ self.assertEqual(len(invites), 0)
+ self.assertFalse(calendar.isShared())
+
+ shareeViews = yield calendar.inviteUIDToShare("group02", _BIND_MODE_READ, "summary")
+ 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, "user01")
+ 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, "summary")
+ #inviteUID = shareeView.shareUID()
+
+ self.assertTrue(calendar.isShared())
+
+ yield self.commit()
+
+ '''
+ sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
+ self.assertTrue(sharedParent is None)
+ #yield self._check_notifications("user02", [inviteUID, ])
+
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ self.assertTrue(group.isShared())
+
+ yield self.commit()
+ '''
+
+ # Uninvite
+ calendar = yield self.calendarUnderTest(home="user01", name="calendar")
+ invites = yield calendar.sharingInvites()
+ self.assertEqual(len(invites), 3)
+ self.assertTrue(calendar.isShared())
+
+ yield calendar.uninviteUIDFromShare("group02")
+ invites = yield calendar.sharingInvites()
+ self.assertEqual(len(invites), 0)
+ self.assertTrue(calendar.isShared())
+
+ yield self._check_notifications("user06", [])
+ yield self._check_notifications("user07", [])
+ yield self._check_notifications("user08", [])
+
+ yield self.commit()
+
+ calendar = yield self.calendarUnderTest(home="user01", name="calendar")
+ self.assertTrue(calendar.isShared())
+ yield calendar.setShared(False)
+ self.assertFalse(calendar.isShared())
+
+
+ @inlineCallbacks
+ def test_accept_share(self):
+ """
+ Test that invite+accept creates shares and notifications.
+ """
+
+ # Invite
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ invites = yield group.sharingInvites()
+ self.assertEqual(len(invites), 0)
+ self.assertFalse(group.isShared())
+
+ shareeView = yield group.inviteUIDToShare("user02", _BIND_MODE_READ, "summary")
+ invites = yield group.sharingInvites()
+ self.assertEqual(len(invites), 1)
+ inviteUID = shareeView.shareUID()
+
+ sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
+ self.assertTrue(sharedParent is None)
+
+ yield self._check_notifications("user02", [inviteUID, ])
+
+ self.assertTrue(group.isShared())
+
+ yield self.commit()
+
+ # Accept
+ shareeHome = yield self.calendarHomeUnderTest(name="user02")
+ yield shareeHome.acceptShare(inviteUID)
+
+ yield self._check_calendar("user02", "user01", self.group1_children)
+ yield self._check_notifications("user01", [inviteUID + "-reply", ])
+
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ self.assertTrue(group.isShared())
+
+ yield self.commit()
+
+ # Re-accept
+ shareeHome = yield self.calendarHomeUnderTest(name="user02")
+ yield shareeHome.acceptShare(inviteUID)
+
+ yield self._check_calendar("user02", "user01", self.group1_children)
+ yield self._check_notifications("user01", [inviteUID + "-reply", ])
+
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ self.assertTrue(group.isShared())
+
+
+ @inlineCallbacks
+ def test_decline_share(self):
+ """
+ Test that invite+decline does not create shares but does create notifications.
+ """
+
+ # Invite
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ invites = yield group.sharingInvites()
+ self.assertEqual(len(invites), 0)
+ self.assertFalse(group.isShared())
+
+ shareeView = yield group.inviteUIDToShare("user02", _BIND_MODE_READ, "summary")
+ invites = yield group.sharingInvites()
+ self.assertEqual(len(invites), 1)
+ inviteUID = shareeView.shareUID()
+
+ sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
+ self.assertTrue(sharedParent is None)
+
+ yield self._check_notifications("user02", [inviteUID, ])
+
+ self.assertTrue(group.isShared())
+
+ yield self.commit()
+
+ # Decline
+ shareeHome = yield self.calendarHomeUnderTest(name="user02")
+ yield shareeHome.declineShare(inviteUID)
+
+ sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
+ self.assertTrue(sharedParent is None)
+
+ yield self._check_notifications("user01", [inviteUID + "-reply", ])
+
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ self.assertTrue(group.isShared())
+
+ yield self.commit()
+
+ # Re-decline
+ shareeHome = yield self.calendarHomeUnderTest(name="user02")
+ yield shareeHome.declineShare(inviteUID)
+
+ sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
+ self.assertTrue(sharedParent is None)
+
+ yield self._check_notifications("user01", [inviteUID + "-reply", ])
+
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ self.assertTrue(group.isShared())
+
+
+ @inlineCallbacks
+ def test_accept_decline_share(self):
+ """
+ Test that invite+accept/decline creates/removes shares and notifications.
+ Decline via the home.
+ """
+
+ # Invite
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ invites = yield group.sharingInvites()
+ self.assertEqual(len(invites), 0)
+ self.assertFalse(group.isShared())
+
+ shareeView = yield group.inviteUIDToShare("user02", _BIND_MODE_READ, "summary")
+ invites = yield group.sharingInvites()
+ self.assertEqual(len(invites), 1)
+ inviteUID = shareeView.shareUID()
+
+ sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
+ self.assertTrue(sharedParent is None)
+
+ yield self._check_notifications("user02", [inviteUID, ])
+
+ self.assertTrue(group.isShared())
+
+ yield self.commit()
+
+ # Accept
+ shareeHome = yield self.calendarHomeUnderTest(name="user02")
+ yield shareeHome.acceptShare(inviteUID)
+
+ yield self._check_calendar("user02", "user01", self.group1_children)
+ yield self._check_notifications("user01", [inviteUID + "-reply", ])
+
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ self.assertTrue(group.isShared())
+
+ yield self.commit()
+
+ # Decline
+ shareeHome = yield self.calendarHomeUnderTest(name="user02")
+ yield shareeHome.declineShare(inviteUID)
+
+ sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
+ self.assertTrue(sharedParent is None)
+
+ yield self._check_notifications("user01", [inviteUID + "-reply", ])
+
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ self.assertTrue(group.isShared())
+
+
+ @inlineCallbacks
+ def test_accept_remove_share(self):
+ """
+ Test that invite+accept/decline creates/removes shares and notifications.
+ Decline via the shared collection (removal).
+ """
+
+ # Invite
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ invites = yield group.sharingInvites()
+ self.assertEqual(len(invites), 0)
+
+ shareeView = yield group.inviteUIDToShare("user02", _BIND_MODE_READ, "summary")
+ invites = yield group.sharingInvites()
+ self.assertEqual(len(invites), 1)
+ inviteUID = shareeView.shareUID()
+
+ sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
+ self.assertTrue(sharedParent is None)
+
+ yield self._check_notifications("user02", [inviteUID, ])
+
+ yield self.commit()
+
+ # Accept
+ shareeHome = yield self.calendarHomeUnderTest(name="user02")
+ yield shareeHome.acceptShare(inviteUID)
+
+ yield self._check_calendar("user02", "user01", self.group1_children)
+ yield self._check_notifications("user01", [inviteUID + "-reply", ])
+
+ yield self.commit()
+
+ # Delete
+ group = yield self.calendarObjectUnderTest(home="user02", calendar_name="user01", name="group1.vcf")
+ yield group.deleteShare()
+
+ sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
+ self.assertTrue(sharedParent is None)
+
+ yield self._check_notifications("user01", [inviteUID + "-reply", ])
+
+
+ @inlineCallbacks
+ def test_accept_two_groups(self):
+ """
+ Test that accept of two groups works.
+ """
+
+ # Two shares
+ inviteUID1 = yield self._createGroupShare(groupname="group1.vcf")
+ inviteUID2 = yield self._createGroupShare(groupname="group2.vcf")
+
+ yield self._check_calendar("user02", "user01", self.all_children)
+ yield self._check_notifications("user01", [inviteUID1 + "-reply", inviteUID2 + "-reply", ])
+
+
+ @inlineCallbacks
+ def test_accept_uninvite_two_groups(self):
+ """
+ Test that accept of two groups works, then uninvite each one.
+ """
+
+ # Two shares
+ inviteUID1 = yield self._createGroupShare(groupname="group1.vcf")
+ inviteUID2 = yield self._createGroupShare(groupname="group2.vcf")
+
+ yield self._check_calendar("user02", "user01", self.all_children)
+ yield self._check_notifications("user01", [inviteUID1 + "-reply", inviteUID2 + "-reply", ])
+
+ yield self.commit()
+
+ # Uninvite one
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ yield group.uninviteUIDFromShare("user02")
+ invites = yield group.sharingInvites()
+ self.assertEqual(len(invites), 0)
+
+ yield self._check_calendar("user02", "user01", self.group2_children)
+
+ shared = yield self.calendarObjectUnderTest(home="user02", calendar_name="user01", name="group1.vcf")
+ self.assertTrue(shared is None)
+ shared = yield self.calendarObjectUnderTest(home="user02", calendar_name="user01", name="card2.vcf")
+ self.assertTrue(shared is None)
+
+ yield self.commit()
+
+ # Uninvite other
+ group = yield self.calendarObjectUnderTest(home="user02", calendar_name="user01", name="group2.vcf")
+ yield group.uninviteUIDFromShare("user02")
+ invites = yield group.sharingInvites()
+ self.assertEqual(len(invites), 0)
+
+ sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
+ self.assertTrue(sharedParent is None)
+
+
+ @inlineCallbacks
+ def test_accept_decline_two_groups(self):
+ """
+ Test that accept of two groups works, then decline each one.
+ """
+
+ # Two shares
+ inviteUID1 = yield self._createGroupShare(groupname="group1.vcf")
+ inviteUID2 = yield self._createGroupShare(groupname="group2.vcf")
+
+ yield self._check_calendar("user02", "user01", self.all_children)
+ yield self._check_notifications("user01", [inviteUID1 + "-reply", inviteUID2 + "-reply", ])
+
+ yield self.commit()
+
+ # Decline one
+ shareeHome = yield self.calendarHomeUnderTest(name="user02")
+ yield shareeHome.declineShare(inviteUID1)
+
+ yield self._check_calendar("user02", "user01", self.group2_children)
+
+ shared = yield self.calendarObjectUnderTest(home="user02", calendar_name="user01", name="group1.vcf")
+ self.assertTrue(shared is None)
+ shared = yield self.calendarObjectUnderTest(home="user02", calendar_name="user01", name="card2.vcf")
+ self.assertTrue(shared is None)
+
+ yield self.commit()
+
+ # Decline other
+ shareeHome = yield self.calendarHomeUnderTest(name="user02")
+ yield shareeHome.declineShare(inviteUID2)
+
+ sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
+ self.assertTrue(sharedParent is None)
+
+
+ @inlineCallbacks
+ def test_accept_two_groups_different_access(self):
+ """
+ Test that accept of two groups works, then uninvite each one.
+ """
+
+ # Two shares
+ inviteUID1 = yield self._createGroupShare(groupname="group1.vcf")
+ inviteUID2 = yield self._createGroupShare(groupname="group2.vcf", mode=_BIND_MODE_WRITE)
+
+ yield self._check_calendar("user02", "user01", self.all_children)
+ yield self._check_notifications("user01", [inviteUID1 + "-reply", inviteUID2 + "-reply", ])
+
+ # Read only for all, write for group2's items
+ yield self._check_read_only("user02", "user01", ["group1.vcf", "card2.vcf", ])
+ yield self._check_read_write("user02", "user01", ["group2.vcf", "card1.vcf", "card3.vcf", ])
+
+ yield self.commit()
+
+ # Decline one
+ shareeHome = yield self.calendarHomeUnderTest(name="user02")
+ yield shareeHome.declineShare(inviteUID2)
+
+ yield self._check_calendar("user02", "user01", self.group1_children)
+
+ yield self._check_read_only("user02", "user01", ["group1.vcf", "card1.vcf", "card2.vcf", ])
+
+ shared = yield self.calendarObjectUnderTest(home="user02", calendar_name="user01", name="group2.vcf")
+ self.assertTrue(shared is None)
+ shared = yield self.calendarObjectUnderTest(home="user02", calendar_name="user01", name="card3.vcf")
+ self.assertTrue(shared is None)
+
+ yield self.commit()
+
+ # Decline other
+ shareeHome = yield self.calendarHomeUnderTest(name="user02")
+ yield shareeHome.declineShare(inviteUID1)
+
+ sharedParent = yield self.calendarUnderTest(home="user02", name="user01")
+ self.assertTrue(sharedParent is None)
+
+
+
+class MixedSharing(BaseSharingTests):
+ """
+ Test store-based combined address book and group book sharing.
+ """
+
+ @inlineCallbacks
+ def test_calendar_ro_then_groups(self):
+
+ # Share address book read-only
+ shareeName = yield self._createShare()
+ yield self._check_calendar("user02", "user01", self.fully_shared_children)
+ yield self._check_read_only("user02", "user01", self.all_children)
+ yield self._check_read_write("user02", "user01", [])
+ yield self._check_notifications("user02", [shareeName, ])
+
+ # Add group1 read-write
+ inviteUID1 = yield self._createGroupShare(groupname="group1.vcf", mode=_BIND_MODE_WRITE)
+
+ yield self._check_calendar("user02", "user01", self.fully_shared_children)
+ yield self._check_read_only("user02", "user01", ["group2.vcf", "card3.vcf", ])
+ yield self._check_read_write("user02", "user01", ["group1.vcf", "card1.vcf", "card2.vcf", ])
+ yield self._check_notifications("user02", [shareeName, inviteUID1, ])
+
+ # Add group2 read-write
+ inviteUID2 = yield self._createGroupShare(groupname="group2.vcf", mode=_BIND_MODE_WRITE)
+
+ yield self._check_calendar("user02", "user01", self.fully_shared_children)
+ yield self._check_read_only("user02", "user01", [])
+ yield self._check_read_write("user02", "user01", self.all_children)
+ yield self._check_notifications("user02", [shareeName, inviteUID1, inviteUID2])
+
+ # Uninvite group1
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ yield group.uninviteUIDFromShare("user02")
+
+ yield self._check_calendar("user02", "user01", self.fully_shared_children)
+ yield self._check_read_only("user02", "user01", ["group1.vcf", "card2.vcf", ])
+ yield self._check_read_write("user02", "user01", ["group2.vcf", "card1.vcf", "card3.vcf", ])
+
+ # Uninvite group2
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group2.vcf")
+ yield group.uninviteUIDFromShare("user02")
+
+ yield self._check_calendar("user02", "user01", self.fully_shared_children)
+ yield self._check_read_only("user02", "user01", self.all_children)
+ yield self._check_read_write("user02", "user01", [])
+
+
+ @inlineCallbacks
+ def test_calendar_ro_then_group_no_accept(self):
+
+ # Share address book read-only
+ shareeName = yield self._createShare()
+ yield self._check_calendar("user02", "user01", self.fully_shared_children)
+ yield self._check_read_only("user02", "user01", self.all_children)
+ yield self._check_read_write("user02", "user01", [])
+ yield self._check_notifications("user02", [shareeName, ])
+
+ # Add group1 read-write - but do not accept
+ group = yield self.calendarObjectUnderTest(home="user01", calendar_name="calendar", name="group1.vcf")
+ invited = yield group.inviteUIDToShare("user02", _BIND_MODE_WRITE, "summary")
+ yield self._check_notifications("user02", [shareeName, invited.shareUID(), ])
+
+ yield self._check_calendar("user02", "user01", self.fully_shared_children)
+ yield self._check_read_only("user02", "user01", self.all_children)
+ yield self._check_read_write("user02", "user01", [])
+
+
+
</ins><span class="cx"> class SharingRevisions(BaseSharingTests):
</span><span class="cx"> """
</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>