<!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>[13777] 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/13777">13777</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-07-18 11:54:57 -0700 (Fri, 18 Jul 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fix tests after group sharing changes.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktwistedcaldavresourcepy">CalendarServer/trunk/twistedcaldav/resource.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtestutilpy">CalendarServer/trunk/twistedcaldav/test/util.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoresqlpy">CalendarServer/trunk/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavwhodirectorypy">CalendarServer/trunk/txdav/who/directory.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_delegatespy">CalendarServer/trunk/txdav/who/test/test_delegates.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_group_attendeespy">CalendarServer/trunk/txdav/who/test/test_group_attendees.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_group_shareespy">CalendarServer/trunk/txdav/who/test/test_group_sharees.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_groupspy">CalendarServer/trunk/txdav/who/test/test_groups.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktwistedcaldavresourcepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/resource.py (13776 => 13777)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/resource.py        2014-07-18 18:23:07 UTC (rev 13776)
+++ CalendarServer/trunk/twistedcaldav/resource.py        2014-07-18 18:54:57 UTC (rev 13777)
</span><span class="lines">@@ -470,10 +470,13 @@
</span><span class="cx"> if config.Sharing.Enabled:
</span><span class="cx"> if config.Sharing.Calendars.Enabled and self.isCalendarCollection():
</span><span class="cx"> baseProperties += (
</span><del>- customxml.Invite.qname(),
</del><span class="cx"> customxml.AllowedSharingModes.qname(),
</span><span class="cx"> customxml.SharedURL.qname(),
</span><span class="cx"> )
</span><ins>+ if self.isShared() or self.isShareeResource():
+ baseProperties += (
+ customxml.Invite.qname(),
+ )
</ins><span class="cx">
</span><span class="cx"> elif (
</span><span class="cx"> config.Sharing.AddressBooks.Enabled and self.isAddressBookCollection() or
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtestutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/test/util.py (13776 => 13777)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/test/util.py        2014-07-18 18:23:07 UTC (rev 13776)
+++ CalendarServer/trunk/twistedcaldav/test/util.py        2014-07-18 18:54:57 UTC (rev 13777)
</span><span class="lines">@@ -29,19 +29,17 @@
</span><span class="cx"> from twistedcaldav import memcacher
</span><span class="cx"> from twistedcaldav.bind import doBind
</span><span class="cx"> from twistedcaldav.directory.addressbook import DirectoryAddressBookHomeProvisioningResource
</span><del>-from twistedcaldav.directory.calendar import (
- DirectoryCalendarHomeProvisioningResource
-)
</del><ins>+from twistedcaldav.directory.calendar import DirectoryCalendarHomeProvisioningResource
</ins><span class="cx"> from twistedcaldav.directory.util import transactionFromRequest
</span><span class="cx"> from twistedcaldav.memcacheclient import ClientFactory
</span><span class="cx"> from twistedcaldav.stdconfig import config
</span><span class="cx"> from txdav.common.datastore.file import CommonDataStore
</span><span class="cx"> from txdav.common.datastore.test.util import deriveQuota, CommonCommonTests
</span><span class="cx"> from txweb2.dav.test.util import SimpleRequest
</span><del>-import txweb2.dav.test.util
</del><span class="cx"> from txweb2.http import HTTPError, StatusResponse
</span><del>-import xattr
</del><span class="cx"> from txweb2.server import Site
</span><ins>+import txweb2.dav.test.util
+import xattr
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> log = Logger()
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py (13776 => 13777)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-07-18 18:23:07 UTC (rev 13776)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-07-18 18:54:57 UTC (rev 13777)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx"> from twisted.python.failure import Failure
</span><span class="cx">
</span><span class="cx"> from twistedcaldav import customxml, ical
</span><del>-from twistedcaldav.config import config
</del><ins>+from twistedcaldav.stdconfig import config
</ins><span class="cx"> from twistedcaldav.datafilters.peruserdata import PerUserDataFilter
</span><span class="cx"> from twistedcaldav.dateops import normalizeForIndex, datetimeMktime, \
</span><span class="cx"> pyCalendarTodatetime, parseSQLDateToPyCalendar
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhodirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/directory.py (13776 => 13777)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/directory.py        2014-07-18 18:23:07 UTC (rev 13776)
+++ CalendarServer/trunk/txdav/who/directory.py        2014-07-18 18:54:57 UTC (rev 13777)
</span><span class="lines">@@ -548,16 +548,27 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def expandedMembers(self, members=None):
</del><ins>+ def expandedMembers(self, members=None, seen=None):
+ """
+ Return a L{set} containing the fully expanded membership list for this group.
+ Note: handle recursive groups.
</ins><span class="cx">
</span><ins>+ @param members: membership to add to
+ @type members: L{set}
+ """
+
</ins><span class="cx"> if members is None:
</span><span class="cx"> members = set()
</span><ins>+ if seen is None:
+ seen = set()
</ins><span class="cx">
</span><del>- for member in (yield self.members()):
- if member.recordType == BaseRecordType.user:
- if member not in members:
</del><ins>+ if self not in seen:
+ seen.add(self)
+ for member in (yield self.members()):
+ if member.recordType == BaseRecordType.group:
+ yield member.expandedMembers(members, seen)
+ else:
</ins><span class="cx"> members.add(member)
</span><del>- yield member.expandedMembers(members)
</del><span class="cx">
</span><span class="cx"> returnValue(members)
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_delegatespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_delegates.py (13776 => 13777)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/test_delegates.py        2014-07-18 18:23:07 UTC (rev 13776)
+++ CalendarServer/trunk/txdav/who/test/test_delegates.py        2014-07-18 18:54:57 UTC (rev 13777)
</span><span class="lines">@@ -160,8 +160,7 @@
</span><span class="cx"> group1 = yield self.directory.recordWithUID(u"__top_group_1__")
</span><span class="cx"> group2 = yield self.directory.recordWithUID(u"__sub_group_1__")
</span><span class="cx">
</span><del>- # Add group delegate, but before the group membership has been
- # pulled in
</del><ins>+ # Add group delegate
</ins><span class="cx"> yield addDelegate(txn, delegator, group1, True)
</span><span class="cx"> # Passing expanded=False will return the group
</span><span class="cx"> delegates = (yield delegatesOf(txn, delegator, True, expanded=False))
</span><span class="lines">@@ -170,14 +169,6 @@
</span><span class="cx"> # Passing expanded=True will return not the group -- it only returns
</span><span class="cx"> # non-groups
</span><span class="cx"> delegates = (yield delegatesOf(txn, delegator, True, expanded=True))
</span><del>- self.assertEquals(0, len(delegates))
-
- # Now refresh the group and there will be 3 delegates (contained
- # within 2 nested groups)
- # guid = "49b350c69611477b94d95516b13856ab"
- yield self.groupCacher.refreshGroup(txn, group1.uid)
- yield self.groupCacher.refreshGroup(txn, group2.uid)
- delegates = (yield delegatesOf(txn, delegator, True, expanded=True))
</del><span class="cx"> self.assertEquals(
</span><span class="cx"> set([u"__sagen1__", u"__cdaboo1__", u"__glyph1__"]),
</span><span class="cx"> set([d.uid for d in delegates])
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_group_attendeespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_group_attendees.py (13776 => 13777)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/test_group_attendees.py        2014-07-18 18:23:07 UTC (rev 13776)
+++ CalendarServer/trunk/txdav/who/test/test_group_attendees.py        2014-07-18 18:54:57 UTC (rev 13777)
</span><span class="lines">@@ -545,7 +545,7 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def expandedMembers(self, records=None):
</del><ins>+ def expandedMembers(self, records=None, seen=None):
</ins><span class="cx"> yield None
</span><span class="cx"> returnValue(set())
</span><span class="cx">
</span><span class="lines">@@ -684,7 +684,7 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def expandedMembers(self, records=None):
</del><ins>+ def expandedMembers(self, records=None, seen=None):
</ins><span class="cx"> yield None
</span><span class="cx"> returnValue(set())
</span><span class="cx">
</span><span class="lines">@@ -828,7 +828,7 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def expandedMembers(self, records=None):
</del><ins>+ def expandedMembers(self, records=None, seen=None):
</ins><span class="cx"> yield None
</span><span class="cx"> returnValue(set())
</span><span class="cx">
</span><span class="lines">@@ -990,7 +990,7 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def expandedMembers(self, records=None):
</del><ins>+ def expandedMembers(self, records=None, seen=None):
</ins><span class="cx"> yield None
</span><span class="cx"> returnValue(set())
</span><span class="cx">
</span><span class="lines">@@ -1135,7 +1135,7 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def expandedMembers(self, records=None):
</del><ins>+ def expandedMembers(self, records=None, seen=None):
</ins><span class="cx"> yield None
</span><span class="cx"> returnValue(set())
</span><span class="cx">
</span><span class="lines">@@ -1281,7 +1281,7 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def expandedMembers(self, records=None):
</del><ins>+ def expandedMembers(self, records=None, seen=None):
</ins><span class="cx"> yield None
</span><span class="cx"> returnValue(set())
</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 (13776 => 13777)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/test_group_sharees.py        2014-07-18 18:23:07 UTC (rev 13776)
+++ CalendarServer/trunk/txdav/who/test/test_group_sharees.py        2014-07-18 18:54:57 UTC (rev 13777)
</span><span class="lines">@@ -109,12 +109,12 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def expandedMembers(self, records=None):
</del><ins>+ def expandedMembers(self, records=None, seen=None):
</ins><span class="cx">
</span><span class="cx"> if self.uid == "group02" or self.uid == "group03":
</span><span class="cx"> returnValue(frozenset())
</span><span class="cx"> else:
</span><del>- returnValue((yield unpatchedExpandedMembers(self, records)))
</del><ins>+ returnValue((yield unpatchedExpandedMembers(self, records, seen)))
</ins><span class="cx">
</span><span class="cx"> unpatchedExpandedMembers = CalendarDirectoryRecordMixin.expandedMembers
</span><span class="cx">
</span><span class="lines">@@ -190,12 +190,12 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def expandedMembers(self, records=None):
</del><ins>+ def expandedMembers(self, records=None, seen=None):
</ins><span class="cx">
</span><span class="cx"> if self.uid == "group02" or self.uid == "group03":
</span><span class="cx"> returnValue(frozenset())
</span><span class="cx"> else:
</span><del>- returnValue((yield unpatchedExpandedMembers(self, records)))
</del><ins>+ returnValue((yield unpatchedExpandedMembers(self, records, seen)))
</ins><span class="cx">
</span><span class="cx"> unpatchedExpandedMembers = CalendarDirectoryRecordMixin.expandedMembers
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_groupspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_groups.py (13776 => 13777)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/test_groups.py        2014-07-18 18:23:07 UTC (rev 13776)
+++ CalendarServer/trunk/txdav/who/test/test_groups.py        2014-07-18 18:54:57 UTC (rev 13777)
</span><span class="lines">@@ -167,7 +167,7 @@
</span><span class="cx"> yield self.groupCacher.refreshGroup(txn, uid)
</span><span class="cx"> (
</span><span class="cx"> groupID, _ignore_name, _ignore_membershipHash, _ignore_modified,
</span><del>- extant
</del><ins>+ _ignore_extant
</ins><span class="cx"> ) = yield txn.groupByUID(uid)
</span><span class="cx"> results = yield txn.groupByID(groupID)
</span><span class="cx"> self.assertEquals((uid, u"Top Group 1", hash, True), results)
</span><span class="lines">@@ -428,6 +428,27 @@
</span><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @inlineCallbacks
+ def test_recursiveGroup(self):
+ """
+ Verify refreshGroup() adds a group to the Groups table with the
+ expected membership hash value and members
+ """
+
+ store = self.storeUnderTest()
+ txn = store.newTransaction()
+
+ record = yield self.directory.recordWithUID(u"recursive1_coasts")
+ members = yield record.expandedMembers()
+ self.assertEquals(
+ set([r.uid for r in members]),
+ set([u'6423F94A-6B76-4A3A-815B-D52CFD77935D', u'5A985493-EE2C-4665-94CF-4DFEA3A89500'])
+ )
+
+ yield txn.commit()
+
+
+
</ins><span class="cx"> class DynamicGroupTest(StoreTestCase):
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -487,7 +508,7 @@
</span><span class="cx"> txn = store.newTransaction()
</span><span class="cx"> yield self.groupCacher.refreshGroup(txn, u"testgroup")
</span><span class="cx"> (
</span><del>- groupID, _ignore_name, membershipHash, _ignore_modified,
</del><ins>+ _ignore_groupID, _ignore_name, _ignore_membershipHash, _ignore_modified,
</ins><span class="cx"> extant
</span><span class="cx"> ) = (yield txn.groupByUID(u"testgroup"))
</span><span class="cx"> yield txn.commit()
</span><span class="lines">@@ -500,7 +521,7 @@
</span><span class="cx"> txn = store.newTransaction()
</span><span class="cx"> yield self.groupCacher.refreshGroup(txn, u"testgroup")
</span><span class="cx"> (
</span><del>- groupID, _ignore_name, membershipHash, _ignore_modified,
</del><ins>+ groupID, _ignore_name, _ignore_membershipHash, _ignore_modified,
</ins><span class="cx"> extant
</span><span class="cx"> ) = (yield txn.groupByUID(u"testgroup"))
</span><span class="cx"> yield txn.commit()
</span><span class="lines">@@ -535,7 +556,7 @@
</span><span class="cx"> txn = store.newTransaction()
</span><span class="cx"> yield self.groupCacher.refreshGroup(txn, u"testgroup")
</span><span class="cx"> (
</span><del>- groupID, _ignore_name, membershipHash, _ignore_modified,
</del><ins>+ groupID, _ignore_name, _ignore_membershipHash, _ignore_modified,
</ins><span class="cx"> extant
</span><span class="cx"> ) = (yield txn.groupByUID(u"testgroup"))
</span><span class="cx"> yield txn.commit()
</span></span></pre>
</div>
</div>
</body>
</html>