[CalendarServer-changes] [468]
CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/
directory
source_changes at macosforge.org
source_changes at macosforge.org
Wed Nov 15 11:33:04 PST 2006
Revision: 468
http://trac.macosforge.org/projects/calendarserver/changeset/468
Author: wsanchez at apple.com
Date: 2006-11-15 11:33:04 -0800 (Wed, 15 Nov 2006)
Log Message:
-----------
Start on Apache-compatible directory
Added Paths:
-----------
CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/apache.py
CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/
CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/__init__.py
CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/basic
CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/digest
CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/groups
CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/test_apache.py
Added: CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/apache.py
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/apache.py (rev 0)
+++ CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/apache.py 2006-11-15 19:33:04 UTC (rev 468)
@@ -0,0 +1,81 @@
+##
+# Copyright (c) 2006 Apple Computer, 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.
+#
+# DRI: Wilfredo Sanchez, wsanchez at apple.com
+##
+
+"""
+Apache UserFile/GroupFile compatible directory service implementation.
+"""
+
+__all__ = [
+ "FileDirectoryService",
+ "FileDirectoryRecord",
+]
+
+from twisted.python.filepath import FilePath
+
+from twistedcaldav.directory.directory import DirectoryService, DirectoryRecord
+
+class FileDirectoryService(DirectoryService):
+ """
+ Apache UserFile/GroupFile implementation of L{IDirectoryService}.
+ """
+ def __repr__(self):
+ return "<%s %r %r>" % (self.__class__.__name__, self.userFile, self.groupFile)
+
+ def __init__(self, userFile, groupFile=None):
+ if type(userFile) is str:
+ userFile = FilePath(userFile)
+ if type(groupFile) is str:
+ groupFile = FilePath(groupFile)
+
+ self.userFile = userFile
+ self.groupFile = groupFile
+
+ def recordTypes(self):
+ recordTypes = ("user",)
+ if self.groupFile is not None:
+ recordTypes += ("group",)
+ return recordTypes
+
+ def listRecords(self, recordType):
+ raise NotImplementedError()
+
+ def recordWithShortName(self, recordType, shortName):
+ raise NotImplementedError()
+
+ def recordWithGUID(self, guid):
+ raise NotImplementedError()
+
+class FileDirectoryRecord(DirectoryRecord):
+ """
+ Apache UserFile/GroupFile implementation of L{IDirectoryRecord}.
+ """
+ def __init__(self):
+ service = None
+ recordType = None
+ guid = None
+ shortName = None
+ fullName = None
+
+ def members(self):
+ raise NotImplementedError()
+
+ def group(self):
+ raise NotImplementedError()
+
+ def verifyCredentials(self, credentials):
+ raise NotImplementedError()
Added: CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/__init__.py
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/__init__.py (rev 0)
+++ CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/__init__.py 2006-11-15 19:33:04 UTC (rev 468)
@@ -0,0 +1,17 @@
+##
+# Copyright (c) 2005-2006 Apple Computer, 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.
+#
+# DRI: Wilfredo Sanchez, wsanchez at apple.com
+##
Added: CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/basic
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/basic (rev 0)
+++ CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/basic 2006-11-15 19:33:04 UTC (rev 468)
@@ -0,0 +1,4 @@
+wsanchez:Cytm0Bwm7CPJs
+cdaboo:I.Ef5FJl5GVh2
+dreid:LVhqAv4qSrYPs
+lecroy:/7/5VDrkrLxY.
Added: CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/digest
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/digest (rev 0)
+++ CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/digest 2006-11-15 19:33:04 UTC (rev 468)
@@ -0,0 +1,4 @@
+wsanchez:Test:decbe233ab3d997cacc2fc058b19db8c
+cdaboo:Test:61164bf3d607d072fe8a7ac420b24aac
+dreid:Test:8ee67801004b2752f72b84e7064889a6
+lecroy:Test:60d4feb424430953be045738041e51be
Added: CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/groups
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/groups (rev 0)
+++ CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/groups 2006-11-15 19:33:04 UTC (rev 468)
@@ -0,0 +1,4 @@
+managers: lecroy
+grunts: wsanchez, cdaboo, dreid
+right_coast: cdaboo
+left_coast: wsanchez, dreid, lecroy
Added: CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/test_apache.py
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/test_apache.py (rev 0)
+++ CalendarServer/branches/users/wsanchez/provisioning/twistedcaldav/directory/test/test_apache.py 2006-11-15 19:33:04 UTC (rev 468)
@@ -0,0 +1,137 @@
+##
+# Copyright (c) 2005-2006 Apple Computer, 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.
+#
+# DRI: Wilfredo Sanchez, wsanchez at apple.com
+##
+
+import os
+
+import twisted.trial.unittest
+from twisted.cred.credentials import UsernamePassword
+
+from twistedcaldav.directory.apache import FileDirectoryService, FileDirectoryRecord
+
+users = {
+ "wsanchez": "foo" ,
+ "cdaboo" : "bar" ,
+ "dreid" : "baz" ,
+ "lecroy" : "quux",
+}
+
+groups = {
+ "managers" : ("lecroy",),
+ "grunts" : ("wsanchez", "cdaboo", "dreid"),
+ "right_coast": ("cdaboo",),
+ "left_coast" : ("wsanchez", "dreid", "lecroy"),
+}
+
+digestRealm = "Test"
+
+basicUserFile = os.path.join(os.path.dirname(__file__), "basic")
+digestUserFile = os.path.join(os.path.dirname(__file__), "digest")
+groupFile = os.path.join(os.path.dirname(__file__), "groups")
+
+# FIXME: Add tests for GUID hooey, once we figure out what that means here
+
+class Basic (twisted.trial.unittest.TestCase):
+ """
+ Test Apache-Compatible UserFile/GroupFile directory implementation.
+ """
+ def test_recordTypes_user(self):
+ """
+ FileDirectoryService.recordTypes(userFile)
+ """
+ service = FileDirectoryService(basicUserFile)
+ self.assertEquals(set(service.recordTypes()), set(("user",)))
+
+ def test_recordTypes_group(self):
+ """
+ FileDirectoryService.recordTypes(userFile, groupFile)
+ """
+ service = FileDirectoryService(basicUserFile, groupFile)
+ self.assertEquals(set(service.recordTypes()), set(("user", "group")))
+
+ def test_listRecords_user(self):
+ """
+ FileDirectoryService.listRecords("user")
+ """
+ service = FileDirectoryService(basicUserFile)
+ self.assertEquals(set(service.listRecords("user")), set(users.keys()))
+
+ test_listRecords_user.todo = "unimplemented"
+
+ def test_listRecords_group(self):
+ """
+ FileDirectoryService.listRecords("group")
+ """
+ service = FileDirectoryService(basicUserFile, groupFile)
+ self.assertEquals(set(service.listRecords("group")), set(groups.keys()))
+
+ test_listRecords_group.todo = "unimplemented"
+
+ def test_recordWithShortName_user(self):
+ """
+ FileDirectoryService.recordWithShortName("user")
+ """
+ service = FileDirectoryService(basicUserFile)
+ for user in users:
+ record = service.recordWithShortName("user", user)
+ self.assertEquals(record.shortName, user)
+
+ test_recordWithShortName_user.todo = "unimplemented"
+
+ def test_recordWithShortName_group(self):
+ """
+ FileDirectoryService.recordWithShortName("group")
+ """
+ service = FileDirectoryService(basicUserFile, groupFile)
+ for group in groups:
+ groupRecord = service.recordWithShortName("group", group)
+ self.assertEquals(groupRecord.shortName, group)
+
+ test_recordWithShortName_group.todo = "unimplemented"
+
+ def test_groupMembers(self):
+ """
+ FileDirectoryRecord.members()
+ """
+ service = FileDirectoryService(basicUserFile, groupFile)
+ for group in groups:
+ groupRecord = service.recordWithShortName("group", group)
+ self.assertEquals(set(m.shortName for m in groupRecord.members()), set(groups[group]))
+
+ test_groupMembers.todo = "unimplemented"
+
+ def test_groupMemberships(self):
+ """
+ FileDirectoryRecord.groups()
+ """
+ service = FileDirectoryService(basicUserFile)
+ for user in users:
+ userRecord = service.recordWithShortName("user", user)
+ self.assertEquals(set(g.shortName for g in userRecord.groups()), set(g for g in groups if user in groups[g]))
+
+ test_groupMemberships.todo = "unimplemented"
+
+ def test_verifyCredentials(self):
+ """
+ FileDirectoryRecord.verifyCredentials()
+ """
+ service = FileDirectoryService(basicUserFile)
+ for user in users:
+ userRecord = service.recordWithShortName("user", user)
+ self.assertUnless(userRecord.verifyCredentials(UsernamePassword(user, users[user])))
+
+ test_verifyCredentials.todo = "unimplemented"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061115/528415c2/attachment.html
More information about the calendarserver-changes
mailing list