[CalendarServer-changes] [13606] CalendarServer/trunk/txdav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jun 4 11:51:13 PDT 2014
Revision: 13606
http://trac.calendarserver.org//changeset/13606
Author: sagen at apple.com
Date: 2014-06-04 11:51:13 -0700 (Wed, 04 Jun 2014)
Log Message:
-----------
Fix GroupsCommand
Modified Paths:
--------------
CalendarServer/trunk/txdav/common/datastore/test/accounts/accounts.xml
CalendarServer/trunk/txdav/dps/commands.py
CalendarServer/trunk/txdav/dps/server.py
CalendarServer/trunk/txdav/dps/test/test_client.py
Modified: CalendarServer/trunk/txdav/common/datastore/test/accounts/accounts.xml
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/accounts/accounts.xml 2014-06-04 04:28:02 UTC (rev 13605)
+++ CalendarServer/trunk/txdav/common/datastore/test/accounts/accounts.xml 2014-06-04 18:51:13 UTC (rev 13606)
@@ -387,6 +387,12 @@
<member-uid>8B4288F6-CC82-491D-8EF9-642EF4F3E7D0</member-uid>
</record>
+ <record type="group">
+ <uid>emptygroup</uid>
+ <short-name>emptygroup</short-name>
+ <full-name>Empty Group</full-name>
+ </record>
+
<!-- Calverify test records -->
<record type="user">
Modified: CalendarServer/trunk/txdav/dps/commands.py
===================================================================
--- CalendarServer/trunk/txdav/dps/commands.py 2014-06-04 04:28:02 UTC (rev 13605)
+++ CalendarServer/trunk/txdav/dps/commands.py 2014-06-04 18:51:13 UTC (rev 13606)
@@ -144,6 +144,7 @@
]
response = [
('fieldsList', amp.ListOf(amp.String())),
+ ('continuation', amp.String(optional=True)),
]
Modified: CalendarServer/trunk/txdav/dps/server.py
===================================================================
--- CalendarServer/trunk/txdav/dps/server.py 2014-06-04 04:28:02 UTC (rev 13605)
+++ CalendarServer/trunk/txdav/dps/server.py 2014-06-04 18:51:13 UTC (rev 13606)
@@ -362,12 +362,10 @@
log.error("Failed in groups", error=e)
record = None
- fieldsList = []
+ records = []
for group in (yield record.groups()):
- fieldsList.append(self.recordToDict(group))
- response = {
- "fieldsList": pickle.dumps(fieldsList),
- }
+ records.append(group)
+ response = self._recordsToResponse(records)
log.debug("Responding with: {response}", response=response)
returnValue(response)
Modified: CalendarServer/trunk/txdav/dps/test/test_client.py
===================================================================
--- CalendarServer/trunk/txdav/dps/test/test_client.py 2014-06-04 04:28:02 UTC (rev 13605)
+++ CalendarServer/trunk/txdav/dps/test/test_client.py 2014-06-04 18:51:13 UTC (rev 13606)
@@ -27,14 +27,15 @@
from twisted.python.filepath import FilePath
from twisted.test.testutils import returnConnected
from twisted.trial import unittest
+from twistedcaldav.config import config
+from twistedcaldav.test.util import StoreTestCase
from txdav.dps.client import DirectoryService
from txdav.dps.server import DirectoryProxyAMPProtocol
from txdav.who.directory import CalendarDirectoryServiceMixin
+from txdav.who.groups import GroupCacher
from txdav.who.test.support import (
TestRecord, CalendarInMemoryDirectoryService
)
-from twistedcaldav.test.util import StoreTestCase
-from twistedcaldav.config import config
testMode = "xml" # "xml" or "od"
@@ -247,6 +248,22 @@
@inlineCallbacks
+ def test_members(self):
+ group = yield self.directory.recordWithUID(u"__calendar-dev__")
+ members = yield group.members()
+ self.assertEquals(len(members), 5)
+
+
+ @inlineCallbacks
+ def test_groups(self):
+ # No need to use group cacher as the XML service directly supports
+ # groups()
+ record = yield self.directory.recordWithUID(u"__sagen__")
+ groups = yield record.groups()
+ self.assertEquals(len(groups), 1)
+
+
+ @inlineCallbacks
def test_verifyPlaintextPassword(self):
expectations = (
(testPassword, True), # Correct
@@ -540,6 +557,35 @@
@inlineCallbacks
+ def test_members(self):
+ group = yield self.client.recordWithUID(u"__top_group_1__")
+ members = yield group.members()
+ self.assertEquals(len(members), 3)
+
+ group = yield self.client.recordWithUID(u"emptygroup")
+ members = yield group.members()
+ self.assertEquals(len(members), 0)
+
+
+ @inlineCallbacks
+ def test_groups(self):
+
+ # A group must first be "refreshed" into the DB otherwise we won't
+ # consider it for group memberships
+ txn = self.store.newTransaction()
+ groupCacher = GroupCacher(self.directory)
+ yield groupCacher.refreshGroup(txn, u"__sub_group_1__")
+ yield txn.commit()
+
+ # record = yield self.client.recordWithUID(u"__sagen1__")
+ # FIXME: this call hangs during unit tests, but not in a real server:
+ # groups = yield record.groups()
+ # self.assertEquals(len(groups), 1)
+
+ test_groups.todo = "Figure out why this hangs"
+
+
+ @inlineCallbacks
def test_verifyPlaintextPassword(self):
expectations = (
(u"zehcnasw", True), # Correct
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140604/5db65c50/attachment.html>
More information about the calendarserver-changes
mailing list