[CalendarServer-changes] [1227] CalendarServer/branches/users/dreid/tap-tests

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 21 11:15:24 PST 2007


Revision: 1227
          http://trac.macosforge.org/projects/calendarserver/changeset/1227
Author:   dreid at apple.com
Date:     2007-02-21 11:15:23 -0800 (Wed, 21 Feb 2007)

Log Message:
-----------
Move the private key so we can test the SSL configuration of the service.

Add a bunch of service maker taps for the single service situation.

Remove a bunch of whitespace

Modified Paths:
--------------
    CalendarServer/branches/users/dreid/tap-tests/conf/caldavd-test-logged.plist
    CalendarServer/branches/users/dreid/tap-tests/conf/caldavd-test.plist
    CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/tap.py
    CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/test/test_tap.py

Added Paths:
-----------
    CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/test/data/server.pem

Removed Paths:
-------------
    CalendarServer/branches/users/dreid/tap-tests/conf/server.pem

Modified: CalendarServer/branches/users/dreid/tap-tests/conf/caldavd-test-logged.plist
===================================================================
--- CalendarServer/branches/users/dreid/tap-tests/conf/caldavd-test-logged.plist	2007-02-21 18:47:00 UTC (rev 1226)
+++ CalendarServer/branches/users/dreid/tap-tests/conf/caldavd-test-logged.plist	2007-02-21 19:15:23 UTC (rev 1227)
@@ -50,10 +50,10 @@
   <false/>
 
   <key>SSLPrivateKey</key>
-  <string>conf/server.pem</string>
+  <string>twistedcaldav/test/data/server.pem</string>
 
   <key>SSLCertificate</key>
-  <string>conf/server.pem</string>
+  <string>twistedcaldav/test/data/server.pem</string>
 
   <key>ServerLogFile</key>
   <string>logs/server.log</string>

Modified: CalendarServer/branches/users/dreid/tap-tests/conf/caldavd-test.plist
===================================================================
--- CalendarServer/branches/users/dreid/tap-tests/conf/caldavd-test.plist	2007-02-21 18:47:00 UTC (rev 1226)
+++ CalendarServer/branches/users/dreid/tap-tests/conf/caldavd-test.plist	2007-02-21 19:15:23 UTC (rev 1227)
@@ -56,10 +56,10 @@
   <string></string>
 
   <key>SSLPrivateKey</key>
-  <string>conf/server.pem</string>
+  <string>twistedcaldav/test/data/server.pem</string>
 
   <key>SSLCertificate</key>
-  <string>conf/server.pem</string>
+  <string>twistedcaldav/test/data/server.pem</string>
 
   <key>ServerLogFile</key>
   <string>logs/server.log</string>

Deleted: CalendarServer/branches/users/dreid/tap-tests/conf/server.pem
===================================================================
--- CalendarServer/branches/users/dreid/tap-tests/conf/server.pem	2007-02-21 18:47:00 UTC (rev 1226)
+++ CalendarServer/branches/users/dreid/tap-tests/conf/server.pem	2007-02-21 19:15:23 UTC (rev 1227)
@@ -1,36 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIICXgIBAAKBgQCxavUDWnISP/hOSGKe3vIwK5jJ4BdzsrMBz4koOt36ADBCIvZa
-Z7mnzNUmdmVvAVFYmJXsE4LhdHhM4fP1jCkuTIK+E6ftrH8SxggI4zvMtEefOpFg
-Hvff4n5DD5D+V9QdOPhv5WFR9V1PG19Q/fJWGizUoWxNjxt5XNxFhLSRnQIDAQAB
-AoGBALC+ZKeaitkzcSJLajPq1kq2o9c4ryRLeZjsLy8stcZAOdMpEVKu0n0fyZgv
-io0zOt6P44rzRQdlCBNPZcHQh5Q3PeBvntc8p3JkclkUyBptJKyByY4VQnM0MJEN
-oJW9mZ6xS+h2V2V/3XUUTpB0r53E4N1y6KzJdypI9KuuTQ8BAkEA3AgvxaqKKFzI
-cnn7ij8MHh6v8/jSYKP0aFbDGrViAaOJscaqnEXsmQ7ffT3eHX7I5gZiKRII5b2k
-AqchUGA2xQJBAM5reALlXWKzN62YifqYH+U+cnc5meNHLqycnCn9cb6+gLoQcz9i
-HgfxwOMYnY6MIpBZIT3jgeqRCzZDXVi23PkCQQCMmLqV7wxLEEaRR7rgsrq2gFtk
-ZQlg8UMabN5MsbxHWc2BiHW6V8AAaY2LRL4qULpkqY2NutVuoAguHcdeyawVAkB0
-4Yt58FAZlCtBw67VU5Az6VE9S0Nk2yiFmsQeTqE6hXo0YR4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xHTAbBgNVBAoTFEFwcGxlIENvbXB1dGVyLCBJbmMu
-MRgwFgYDVQQLEw9NYWMgT1MgWCBTZXJ2ZXIxIDAeBgNVBAMTF2NvbGxhYm9yYXRp
-b24uYXBwbGUuY29tggkAwjHTLyn/yUgwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0B
-AQQFAAOBgQB2lFDAwSr8VAtR1N2eC16TgFg5/7hT7NF+7ZRiopflcKP1Q4LtfIhH
-kS29slLq5FB/+PvEZSKj0G+5V55NjjfoUFauqf3ytfmMOJS9GUGE0jU3+K8JKOFs
-kn9JlyRmJQJqT7MxM3Jit0K7ns/5arpq6fTZiW0kmycNXlUtsyNXbA==
------END CERTIFICATE-----

Modified: CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/tap.py
===================================================================
--- CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/tap.py	2007-02-21 18:47:00 UTC (rev 1226)
+++ CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/tap.py	2007-02-21 19:15:23 UTC (rev 1227)
@@ -79,7 +79,7 @@
         ["config", "f", "/etc/caldavd/caldavd.plist",
          "Path to configuration file."],
         ]
-        
+
     zsh_actions = {"config" : "_files -g '*.plist'"}
 
     def __init__(self, *args, **kwargs):
@@ -89,9 +89,9 @@
 
     def opt_option(self, option):
         """
-        Set an option to override a value in the config file. True, False, int, 
+        Set an option to override a value in the config file. True, False, int,
         and float options are supported, as well as comma seperated lists. Only
-        one option may be given for each --option flag, however multiple 
+        one option may be given for each --option flag, however multiple
         --option flags may be specified.
         """
 
@@ -104,14 +104,14 @@
 
                 elif isinstance(defaultConfig[key], (int, float, long)):
                     value = type(defaultConfig[key])(value)
-                
+
                 elif isinstance(defaultConfig[key], (list, tuple)):
                     value = value.split(',')
 
                 elif isinstance(defaultConfig[key], dict):
                     raise UsageError(
                         "We do not support dict options on the command line")
-                        
+
                 elif value == 'None':
                     value = None
 
@@ -123,7 +123,8 @@
 
     def postOptions(self):
         if not os.path.exists(self['config']):
-            print "Config file %s not found, using defaults" % (self['config'],)
+            log.msg("Config file %s not found, using defaults" % (
+                    self['config'],))
 
         parseConfig(self['config'])
 
@@ -132,7 +133,7 @@
         uid, gid = None, None
 
         if self.parent['uid'] or self.parent['gid']:
-            uid, gid = getid(self.parent['uid'], 
+            uid, gid = getid(self.parent['uid'],
                              self.parent['gid'])
 
         if uid:
@@ -154,7 +155,7 @@
 
         # Verify that document root actually exists
         self.checkDirectory(config.DocumentRoot, "Document root")
-            
+
         # Verify that ssl certs exist if needed
         if config.SSLEnable:
             self.checkFile(config.SSLPrivateKey, "SSL Private key")
@@ -172,7 +173,7 @@
             raise ValueError("%s does not exist: %s" % (description, dirpath,))
         elif not os.path.isdir(dirpath):
             raise ValueError("%s is not a directory: %s" % (description, dirpath,))
-    
+
     def checkFile(self, filepath, description):
         if not os.path.exists(filepath):
             raise ValueError("%s does not exist: %s" % (description, filepath,))
@@ -201,12 +202,12 @@
         # Setup the Directory
         #
         directories = []
-        
+
         directoryClass = namedClass(config.DirectoryService['type'])
-        
+
         log.msg("Configuring directory service of type: %s" % (
             config.DirectoryService['type'],))
-        
+
         baseDirectory = directoryClass(**config.DirectoryService['params'])
 
         directories.append(baseDirectory)
@@ -216,7 +217,7 @@
         if config.SudoersFile and os.path.exists(config.SudoersFile):
             log.msg("Configuring SudoDirectoryService with file: %s" % (
                 config.SudoersFile,))
-                
+
             sudoDirectory = SudoDirectoryService(config.SudoersFile)
             sudoDirectory.realmName = baseDirectory.realmName
 
@@ -238,7 +239,7 @@
         #
 
         log.msg("Setting up document root at: %s" % (config.DocumentRoot,))
-        
+
         log.msg("Setting up principal collection: %r" % (
             self.principalResourceClass,))
 
@@ -256,11 +257,11 @@
             directory,
             '/calendars/'
         )
-        
+
         log.msg("Setting up root resource: %r" % (self.rootResourceClass,))
-        
+
         root = self.rootResourceClass(
-            config.DocumentRoot, 
+            config.DocumentRoot,
             principalCollections=(principalCollection,)
         )
 
@@ -277,12 +278,12 @@
                 davxml.Grant(davxml.Privilege(davxml.Read())),
             ),
         ]
-        
+
         log.msg("Setting up AdminPrincipals")
 
         for principal in config.AdminPrincipals:
             log.msg("Added %s as admin principal" % (principal,))
-            
+
             rootACEs.append(
                 davxml.ACE(
                     davxml.Principal(davxml.HRef(principal)),
@@ -314,10 +315,10 @@
             scheme = scheme.lower()
 
             credFactory = None
-            
+
             if schemeConfig['Enabled']:
                 log.msg("Setting up scheme: %s" % (scheme,))
-                
+
                 if scheme == 'kerberos':
                     if not NegotiateCredentialFactory:
                         log.msg("Kerberos support not available")
@@ -352,7 +353,7 @@
 
         #
         # Configure the service
-        # 
+        #
 
         log.msg("Setting up service")
 
@@ -362,7 +363,7 @@
             config.ServerLogFile,))
 
         logObserver = RotatingFileAccessLoggingObserver(config.ServerLogFile)
-        
+
         service = CalDAVService(logObserver)
 
         if not config.BindAddress:
@@ -372,7 +373,7 @@
             if not config.SSLOnly:
                 log.msg("Adding server at %s:%s" % (
                     bindAddress, config.Port))
-                    
+
                 httpService = internet.TCPServer(int(config.Port), channel,
                                                  interface=bindAddress)
                 httpService.setServiceParent(service)
@@ -381,7 +382,7 @@
                 from twisted.internet.ssl import DefaultOpenSSLContextFactory
                 log.msg("Adding SSL server at %s:%s" % (
                     bindAddress, config.Port))
-                
+
                 httpsService = internet.SSLServer(
                     int(config.SSLPort),
                     channel,
@@ -390,7 +391,7 @@
                     interface=bindAddress
                     )
                 httpsService.setServiceParent(service)
-            
+
         return service
 
     makeService_slave = makeService_singleprocess
@@ -401,7 +402,7 @@
 
     def makeService(self, options):
         serverType = config.ServerType
-        
+
         serviceMethod = getattr(self, 'makeService_%s' % (serverType,), None)
 
         if not serviceMethod:
@@ -411,6 +412,6 @@
 
         else:
             return serviceMethod(options)
-            
 
-                                
+
+

Copied: CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/test/data/server.pem (from rev 1219, CalendarServer/branches/users/dreid/tap-tests/conf/server.pem)
===================================================================
--- CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/test/data/server.pem	                        (rev 0)
+++ CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/test/data/server.pem	2007-02-21 19:15:23 UTC (rev 1227)
@@ -0,0 +1,36 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXgIBAAKBgQCxavUDWnISP/hOSGKe3vIwK5jJ4BdzsrMBz4koOt36ADBCIvZa
+Z7mnzNUmdmVvAVFYmJXsE4LhdHhM4fP1jCkuTIK+E6ftrH8SxggI4zvMtEefOpFg
+Hvff4n5DD5D+V9QdOPhv5WFR9V1PG19Q/fJWGizUoWxNjxt5XNxFhLSRnQIDAQAB
+AoGBALC+ZKeaitkzcSJLajPq1kq2o9c4ryRLeZjsLy8stcZAOdMpEVKu0n0fyZgv
+io0zOt6P44rzRQdlCBNPZcHQh5Q3PeBvntc8p3JkclkUyBptJKyByY4VQnM0MJEN
+oJW9mZ6xS+h2V2V/3XUUTpB0r53E4N1y6KzJdypI9KuuTQ8BAkEA3AgvxaqKKFzI
+cnn7ij8MHh6v8/jSYKP0aFbDGrViAaOJscaqnEXsmQ7ffT3eHX7I5gZiKRII5b2k
+AqchUGA2xQJBAM5reALlXWKzN62YifqYH+U+cnc5meNHLqycnCn9cb6+gLoQcz9i
+HgfxwOMYnY6MIpBZIT3jgeqRCzZDXVi23PkCQQCMmLqV7wxLEEaRR7rgsrq2gFtk
+ZQlg8UMabN5MsbxHWc2BiHW6V8AAaY2LRL4qULpkqY2NutVuoAguHcdeyawVAkB0
+4Yt58FAZlCtBw67VU5Az6VE9S0Nk2yiFmsQeTqE6hXo0YR4w1Kj2jKBQtt54Gcd0
+ftOAzLMClBCKMEjJ8/lZAkEAyFemVG2VTSVeW0w9fSm8dsqyUv9WbHjX6KQaGg/E
+hPA1NcQNZcsGj43upDl66uonI7oaKVF/kAXiiu2KTUBGsQ==
+-----END RSA PRIVATE KEY-----
+-----BEGIN CERTIFICATE-----
+MIIDhDCCAu2gAwIBAgIJAMIx0y8p/8lIMA0GCSqGSIb3DQEBBAU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ZRiopflcKP1Q4LtfIhH
+kS29slLq5FB/+PvEZSKj0G+5V55NjjfoUFauqf3ytfmMOJS9GUGE0jU3+K8JKOFs
+kn9JlyRmJQJqT7MxM3Jit0K7ns/5arpq6fTZiW0kmycNXlUtsyNXbA==
+-----END CERTIFICATE-----

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 18:47:00 UTC (rev 1226)
+++ CalendarServer/branches/users/dreid/tap-tests/twistedcaldav/test/test_tap.py	2007-02-21 19:15:23 UTC (rev 1227)
@@ -16,14 +16,22 @@
 # DRI: David Reid, dreid at apple.com
 ##
 
+import os
+from copy import deepcopy
+
 from twisted.trial import unittest
 
 from twisted.python.usage import Options, UsageError
+from twisted.python.util import sibpath
+from twisted.application.service import IService
+from twisted.application import internet
 
-from twistedcaldav.tap import CalDAVOptions
+from twistedcaldav.tap import CalDAVOptions, CalDAVServiceMaker
+from twistedcaldav import tap
 
 from twistedcaldav.config import config
 from twistedcaldav import config as config_mod
+from twistedcaldav.py.plistlib import writePlist
 
 
 class TestCalDAVOptions(CalDAVOptions):
@@ -106,7 +114,6 @@
         loads the global config with those values properly.
         """
 
-        from copy import deepcopy
         myConfig = deepcopy(config_mod.defaultConfig)
 
         myConfig['Authentication']['Basic']['Enabled'] = False
@@ -117,8 +124,6 @@
 
         myConfig['ServerHostName'] = 'calendar.calenderserver.org'
 
-        from twistedcaldav.py.plistlib import writePlist
-
         myConfigFile = self.mktemp()
         writePlist(myConfig, myConfigFile)
 
@@ -135,3 +140,196 @@
 
         self.assertEquals(config.Authentication['Basic']['Enabled'],
                           myConfig['Authentication']['Basic']['Enabled'])
+
+
+class BaseServiceMakerTests(unittest.TestCase):
+    """
+    Utility class for ServiceMaker tests.
+    """
+
+    def setUp(self):
+        self.options = TestCalDAVOptions()
+        self.options.parent = Options()
+        self.options.parent['gid'] = None
+        self.options.parent['uid'] = None
+
+        self.config = deepcopy(config_mod.defaultConfig)
+
+        accountsFile = sibpath(os.path.dirname(__file__),
+                               'directory/test/accounts.xml')
+
+        self.config['DirectoryService'] = {
+            'params': {'xmlFile': accountsFile},
+            'type': 'twistedcaldav.directory.xmlfile.XMLDirectoryService'
+            }
+
+        self.config['DocumentRoot'] = self.mktemp()
+
+        self.config['SSLPrivateKey'] = sibpath(__file__, 'data/server.pem')
+        self.config['SSLCertificate'] = sibpath(__file__, 'data/server.pem')
+        self.config['SSLOnly'] = False
+
+        os.mkdir(self.config['DocumentRoot'])
+
+        self.configFile = self.mktemp()
+
+        self.writeConfig()
+
+    def writeConfig(self):
+        """
+        Flush self.config out to self.configFile
+        """
+
+        writePlist(self.config, self.configFile)
+
+    def makeService(self):
+        """
+        Create a service by calling into CalDAVServiceMaker with
+        self.configFile
+        """
+
+        self.options.parseOptions(['-f', self.configFile])
+
+        return CalDAVServiceMaker().makeService(self.options)
+
+
+class SingleServiceTest(BaseServiceMakerTests):
+    """
+    Test various configurations of the single service
+    """
+
+    def test_defaultService(self):
+        """
+        Test the value of a single process service in it's simplest
+        configuration.
+        """
+
+        service = self.makeService()
+
+        self.failUnless(IService(service))
+        
+        self.failUnless(service.services)
+
+        self.failUnless(isinstance(service, tap.CalDAVService))
+
+    def test_defaultListeners(self):
+        """
+        Test that the single process service has sub services with the
+        default TCP and SSL configuration
+        """
+
+        service = self.makeService()
+
+        expectedSubServices = ((internet.TCPServer, self.config['Port']),
+                               (internet.SSLServer, self.config['SSLPort']))
+
+        configuredSubServices = [(s.__class__, s.args) 
+                                 for s in service.services]
+
+        for serviceClass, serviceArgs in configuredSubServices:
+            self.failUnless(
+                serviceClass in (s[0] for s in expectedSubServices))
+
+            self.assertEquals(serviceArgs[0], 
+                              dict(expectedSubServices)[serviceClass])
+
+    def test_SSLKeyConfiguration(self):
+        """
+        Test that the configuration of the SSLServer reflect the config file's
+        SSL Private Key and SSL Certificate
+        """
+
+        service = self.makeService()
+
+        sslService = None
+        for s in service.services:
+            if isinstance(s, internet.SSLServer):
+                sslService = s
+                break
+
+        context = sslService.args[2]
+
+        self.assertEquals(self.config['SSLPrivateKey'],
+                          context.privateKeyFileName)
+
+        self.assertEquals(self.config['SSLCertificate'],
+                          context.certificateFileName)
+
+    def test_noSSL(self):
+        """
+        Test the single service to make sure there is no SSL Service when SSL
+        is disabled
+        """
+
+        self.config['SSLEnable'] = False
+        self.writeConfig()
+        service = self.makeService()
+
+        self.failIf(
+            internet.SSLServer in [s.__class__ for s in service.services])
+
+    def test_SSLOnly(self):
+        """
+        Test the single service to make sure there is no TCPServer when 
+        SSLOnly is turned on.
+        """
+
+        self.config['SSLOnly'] = True
+        self.writeConfig()
+        service = self.makeService()
+
+        self.failIf(
+            internet.TCPServer in [s.__class__ for s in service.services])
+
+    def test_singleBindAddress(self):
+        """
+        Test that the TCPServer and SSLServers are bound to the proper address
+        """
+
+        self.config['BindAddress'] = ['127.0.0.1']
+        self.writeConfig()
+        service = self.makeService()
+        
+        for s in service.services:
+            self.assertEquals(s.kwargs['interface'], '127.0.0.1')
+
+    def test_multipleBindAddress(self):
+        """
+        Test that the TCPServer and SSLServers are bound to the proper 
+        addresses.
+        """
+
+        self.config['BindAddress'] = ['127.0.0.1', '10.0.0.2', '172.53.13.123']
+        self.writeConfig()
+        service = self.makeService()
+
+        tcpServers = []
+        sslServers = []
+
+        for s in service.services:
+            if isinstance(s, internet.TCPServer):
+                tcpServers.append(s)
+            elif isinstance(s, internet.SSLServer):
+                sslServers.append(s)
+
+        self.assertEquals(len(tcpServers), len(self.config['BindAddress']))
+        self.assertEquals(len(sslServers), len(self.config['BindAddress']))
+
+        for addr in self.config['BindAddress']:
+            for s in tcpServers:
+                if s.kwargs['interface'] == addr:
+                    tcpServers.remove(s)
+                    
+            for s in sslServers:
+                if s.kwargs['interface'] == addr:
+                    sslServers.remove(s)
+
+        self.assertEquals(len(tcpServers), 0)
+        self.assertEquals(len(sslServers), 0)
+
+
+class ServiceHTTPFactoryTests(BaseServiceMakerTests):
+    """
+    Test the configuration of the initial resource hierarchy of the
+    single service
+    """

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070221/79efceeb/attachment.html


More information about the calendarserver-changes mailing list