[CalendarServer-changes] [1231]
CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/test/
test_tap.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 21 14:12:45 PST 2007
Revision: 1231
http://trac.macosforge.org/projects/calendarserver/changeset/1231
Author: dreid at apple.com
Date: 2007-02-21 14:12:45 -0800 (Wed, 21 Feb 2007)
Log Message:
-----------
A bunch of directory service related tests.
Modified Paths:
--------------
CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/test/test_tap.py
Modified: CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/test/test_tap.py
===================================================================
--- CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/test/test_tap.py 2007-02-21 21:49:23 UTC (rev 1230)
+++ CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/test/test_tap.py 2007-02-21 22:12:45 UTC (rev 1231)
@@ -23,9 +23,13 @@
from twisted.python.usage import Options, UsageError
from twisted.python.util import sibpath
+from twisted.python.reflect import namedAny
from twisted.application.service import IService
from twisted.application import internet
+from twisted.web2.dav import auth
+from twisted.web2.log import LogWrapperResource
+
from twistedcaldav.tap import CalDAVOptions, CalDAVServiceMaker
from twistedcaldav import tap
@@ -33,7 +37,11 @@
from twistedcaldav import config as config_mod
from twistedcaldav.py.plistlib import writePlist
+from twistedcaldav.directory.aggregate import AggregateDirectoryService
+from twistedcaldav.directory.sudo import SudoDirectoryService
+from twistedcaldav.directory.directory import UnknownRecordTypeError
+
class TestCalDAVOptions(CalDAVOptions):
"""
A fake that implementation of CalDAVOptions that provides
@@ -192,7 +200,17 @@
return CalDAVServiceMaker().makeService(self.options)
+ def getSite(self):
+ """
+ Get the server.Site from the service by finding the HTTPFactory
+ """
+ service = self.makeService()
+
+ return service.services[0].args[1].protocolArgs['requestFactory']
+
+
+
class CalDAVServiceMakerTests(BaseServiceMakerTests):
"""
Test the service maker's behavior
@@ -355,11 +373,6 @@
single service
"""
- def getSite(self):
- service = self.makeService()
-
- return service.services[0].args[1].protocolArgs['requestFactory']
-
def test_AuthWrapperAllEnabled(self):
"""
Test the configuration of the authentication wrapper
@@ -372,8 +385,6 @@
self.writeConfig()
site = self.getSite()
- from twisted.web2.dav import auth
-
self.failUnless(isinstance(
site.resource.resource,
auth.AuthenticationWrapper))
@@ -418,8 +429,6 @@
site = self.getSite()
- from twisted.web2.log import LogWrapperResource
-
self.failUnless(isinstance(
site.resource,
LogWrapperResource))
@@ -467,28 +476,103 @@
to the same DirectoryService as the calendar hierarchy
"""
- test_sameDirectory.todo = "Not Implemented Yet"
+ site = self.getSite()
+ principals = site.resource.resource.resource.getChild('principals')
+ calendars = site.resource.resource.resource.getChild('calendars')
+ self.assertEquals(principals.directory,
+ calendars.directory)
+
def test_aggregateDirectory(self):
"""
Assert that the base directory service is actually
an AggregateDirectoryService
"""
+ site = self.getSite()
+ principals = site.resource.resource.resource.getChild('principals')
+ directory = principals.directory
- test_aggregateDirectory.todo = "Not implemented yet"
+ self.failUnless(isinstance(
+ directory,
+ AggregateDirectoryService))
def test_sudoDirectoryService(self):
"""
Test that a sudo directory service is available if the
SudoersFile is set and exists
"""
+ site = self.getSite()
+ principals = site.resource.resource.resource.getChild('principals')
+ directory = principals.directory
- test_sudoDirectoryService.todo = "Not implemented yet"
+ self.failUnless(self.config['SudoersFile'])
+ sudoService = directory.serviceForRecordType(
+ SudoDirectoryService.recordType_sudoers)
+
+ self.assertEquals(sudoService.plistFile.path,
+ os.path.abspath(self.config['SudoersFile']))
+
+ self.failUnless(SudoDirectoryService.recordType_sudoers in
+ directory.userRecordTypes)
+
+ def test_sudoDirectoryServiceNoFile(self):
+ """
+ Test that there is no SudoDirectoryService if
+ the SudoersFile does not exist.
+ """
+ self.config['SudoersFile'] = self.mktemp()
+
+ self.writeConfig()
+ site = self.getSite()
+ principals = site.resource.resource.resource.getChild('principals')
+ directory = principals.directory
+
+ self.failUnless(self.config['SudoersFile'])
+
+ self.assertRaises(
+ UnknownRecordTypeError,
+ directory.serviceForRecordType,
+ SudoDirectoryService.recordType_sudoers)
+
+ def test_sudoDirectoryServiceNotConfigured(self):
+ """
+ Test that there is no SudoDirectoryService if
+ the SudoersFile is not configured
+ """
+
+ self.config['SudoersFile'] = ''
+ self.writeConfig()
+
+ site = self.getSite()
+ principals = site.resource.resource.resource.getChild('principals')
+ directory = principals.directory
+
+ self.failIf(self.config['SudoersFile'])
+
+ self.assertRaises(
+ UnknownRecordTypeError,
+ directory.serviceForRecordType,
+ SudoDirectoryService.recordType_sudoers)
+
def test_configuredDirectoryService(self):
"""
Test that the real directory service is the directory service
set in the configuration file.
"""
- test_configuredDirectoryService.todo = "Not implemented yet"
+ self.config['SudoersFile'] = ''
+ self.writeConfig()
+
+ site = self.getSite()
+ principals = site.resource.resource.resource.getChild('principals')
+ directory = principals.directory
+
+ realDirectory = directory.serviceForRecordType('users')
+
+ configuredDirectory = namedAny(
+ self.config['DirectoryService']['type'])
+
+ self.failUnless(isinstance(
+ realDirectory,
+ configuredDirectory))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070221/a24b8ee4/attachment.html
More information about the calendarserver-changes
mailing list