[CalendarServer-changes] [1086]
CalendarServer/branches/users/cdaboo/od-schema-1044
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jan 23 08:32:48 PST 2007
Revision: 1086
http://trac.macosforge.org/projects/calendarserver/changeset/1086
Author: cdaboo at apple.com
Date: 2007-01-23 08:32:47 -0800 (Tue, 23 Jan 2007)
Log Message:
-----------
Switch to updated schema. Now lookup /Computers record via a locally configured server virtual host name. Add
some tests to check new lookup procedure.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/od-schema-1044/conf/caldavd-test.plist
CalendarServer/branches/users/cdaboo/od-schema-1044/conf/caldavd.plist
CalendarServer/branches/users/cdaboo/od-schema-1044/support/directorysetup.py
CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/config.py
CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/directory/appleopendirectory.py
CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/directory/test/test_opendirectoryschema.py
Modified: CalendarServer/branches/users/cdaboo/od-schema-1044/conf/caldavd-test.plist
===================================================================
--- CalendarServer/branches/users/cdaboo/od-schema-1044/conf/caldavd-test.plist 2007-01-23 16:29:15 UTC (rev 1085)
+++ CalendarServer/branches/users/cdaboo/od-schema-1044/conf/caldavd-test.plist 2007-01-23 16:32:47 UTC (rev 1086)
@@ -34,6 +34,9 @@
<string>127.0.0.1</string>
</array>
+ <key>ServerHostName</key>
+ <string>localhost</string>
+
<key>Port</key>
<integer>8008</integer>
Modified: CalendarServer/branches/users/cdaboo/od-schema-1044/conf/caldavd.plist
===================================================================
--- CalendarServer/branches/users/cdaboo/od-schema-1044/conf/caldavd.plist 2007-01-23 16:29:15 UTC (rev 1085)
+++ CalendarServer/branches/users/cdaboo/od-schema-1044/conf/caldavd.plist 2007-01-23 16:32:47 UTC (rev 1086)
@@ -33,6 +33,9 @@
<array>
</array>
+ <key>ServerHostName</key>
+ <string></string>
+
<key>Port</key>
<integer>8008</integer>
Modified: CalendarServer/branches/users/cdaboo/od-schema-1044/support/directorysetup.py
===================================================================
--- CalendarServer/branches/users/cdaboo/od-schema-1044/support/directorysetup.py 2007-01-23 16:29:15 UTC (rev 1085)
+++ CalendarServer/branches/users/cdaboo/od-schema-1044/support/directorysetup.py 2007-01-23 16:32:47 UTC (rev 1086)
@@ -88,12 +88,12 @@
<key>http</key>
<dict>
<key>port</key>
- <string>80</string>
+ <integer>80</integer>
</dict>
<key>https</key>
<dict>
<key>port</key>
- <string>443</string>
+ <integer>443</integer>
</dict>
</dict>
@@ -109,23 +109,23 @@
<key>webCalendar</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/webcalendar</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/webcalendar</string>
</dict>
<key>wiki</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/wiki</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/wiki</string>
</dict>
<key>webMailingList</key>
<dict>
<key>enabled</key>
<true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/mailinglist</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/mailinglist</string>
</dict>
</dict>
</dict>
@@ -140,12 +140,12 @@
<key>http</key>
<dict>
<key>port</key>
- <string>8008</string>
+ <integer>8008</integer>
</dict>
<key>https</key>
<dict>
<key>port</key>
- <string>8443</string>
+ <integer>8443</integer>
</dict>
</dict>
Modified: CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/config.py
===================================================================
--- CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/config.py 2007-01-23 16:29:15 UTC (rev 1085)
+++ CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/config.py 2007-01-23 16:32:47 UTC (rev 1086)
@@ -47,6 +47,7 @@
'ServerStatsFile': '/Library/CalendarServer/Documents/stats.plist',
'UserQuotaBytes': 104857600,
'Verbose': False,
+ 'ServerHostName': 'localhost',
'SACLEnable': False,
'Authentication': {
'Basic': {
Modified: CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/directory/appleopendirectory.py
===================================================================
--- CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/directory/appleopendirectory.py 2007-01-23 16:29:15 UTC (rev 1085)
+++ CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/directory/appleopendirectory.py 2007-01-23 16:32:47 UTC (rev 1086)
@@ -36,6 +36,7 @@
from twisted.internet.reactor import callLater
from twisted.cred.credentials import UsernamePassword
+from twistedcaldav.config import config
from twistedcaldav.directory.directory import DirectoryService, DirectoryRecord
from twistedcaldav.directory.directory import DirectoryError, UnknownRecordTypeError
@@ -103,9 +104,14 @@
Get the OD service record for this host.
"""
- # Get MAC address
- macaddr = os.popen("/sbin/ifconfig en0|grep ether").read().replace("\n", "").split()[1]
-
+ # The server must have been configured with a virtual hostname.
+ vhostname = config.ServerHostName
+ if not vhostname:
+ raise OpenDirectoryInitError(
+ "There is no virtual hostname configured for the server for use with Open Directory (node=%s)"
+ % (self.realmName,)
+ )
+
# Find a record in /Computers with an ENetAddress attribute value equal to the MAC address
# and return some useful attributes.
attrs = [
@@ -114,47 +120,62 @@
dsattributes.kDS1AttrXMLPlist,
]
- results = opendirectory.queryRecordsWithAttributes(
+ records = opendirectory.queryRecordsWithAttributes(
self.directory,
- { dsattributes.kDS1AttrENetAddress: macaddr },
- dsattributes.eDSExact,
+ { dsattributes.kDS1AttrXMLPlist: vhostname },
+ dsattributes.eDSContains,
+ True, # case insentive for hostnames
False,
- False,
dsattributes.kDSStdRecordTypeComputers,
attrs
)
+ self._parseComputersRecords(records, vhostname)
+
+ def _parseComputersRecords(self, records, vhostname):
- # Must have a single result
- if len(results) != 1:
+ # Must have some results
+ if len(records) == 0:
raise OpenDirectoryInitError(
- "Open Directory (node=%s) has %s (!= 1) /Computers records with EnetAddress: %s"
- % (self.realmName, len(results), macaddr)
+ "Open Directory (node=%s) has no /Computers records with a virtual hostname: %s"
+ % (self.realmName, vhostname,)
)
- self.computerRecordName = results.keys()[0]
- record = results[self.computerRecordName]
-
- # Get XMLPlist value
- plist = record.get(dsattributes.kDS1AttrXMLPlist, None)
- if not plist:
+ # Now find a single record that actually matches the hostname
+ found = False
+ for recordname, record in records.iteritems():
+
+ # Must have XMLPlist value
+ plist = record.get(dsattributes.kDS1AttrXMLPlist, None)
+ if not plist:
+ continue
+
+ if not self._parseXMLPlist(vhostname, recordname, plist, record[dsattributes.kDS1AttrGeneratedUID]):
+ continue
+ elif found:
+ raise OpenDirectoryInitError(
+ "Open Directory (node=%s) multiple /Computers records found matching virtual hostname: %s"
+ % (self.realmName, vhostname,)
+ )
+ else:
+ found = True
+
+ if not found:
raise OpenDirectoryInitError(
- "Open Directory (node=%s) /Computers/%s record does not have an XMLPlist attribute value"
- % (self.realmName, self.computerRecordName)
+ "Open Directory (node=%s) no /Computers records with an enabled and valid calendar service were found matching virtual hostname: %s"
+ % (self.realmName, vhostname,)
)
-
- # Parse it and extract useful information
- self._parseXMLPlist(plist, record[dsattributes.kDS1AttrGeneratedUID])
- def _parseXMLPlist(self, plist, recordguid):
+ def _parseXMLPlist(self, vhostname, recordname, plist, recordguid):
# Parse the plist and look for our special entry
plist = readPlistFromString(plist)
vhosts = plist.get("com.apple.macosxserver.virtualhosts", None)
if not vhosts:
- raise OpenDirectoryInitError(
+ log.msg(
"Open Directory (node=%s) /Computers/%s record does not have a "
"com.apple.macosxserver.virtualhosts in its XMLPlist attribute value"
- % (self.realmName, self.computerRecordName)
+ % (self.realmName, recordname)
)
+ return False
# Iterate over each vhost and find one that is a calendar service
hostguid = None
@@ -167,29 +188,39 @@
break
if not hostguid:
- raise OpenDirectoryInitError(
+ log.msg(
"Open Directory (node=%s) /Computers/%s record does not have a "
"calendar service in its XMLPlist attribute value"
- % (self.realmName, self.computerRecordName)
+ % (self.realmName, recordname)
)
+ return False
# Get host name
hostname = vhosts[hostguid].get("hostname", None)
if not hostname:
- raise OpenDirectoryInitError(
+ log.msg(
"Open Directory (node=%s) /Computers/%s record does not have "
"any host name in its XMLPlist attribute value"
- % (self.realmName, self.computerRecordName)
+ % (self.realmName, recordname)
)
+ return False
+ if hostname != vhostname:
+ log.msg(
+ "Open Directory (node=%s) /Computers/%s record hostname (%s) "
+ "does not match this server (%s)"
+ % (self.realmName, recordname, hostname, vhostname)
+ )
+ return False
# Get host details and create host templates
hostdetails = vhosts[hostguid].get("hostDetails", None)
if not hostdetails:
- raise OpenDirectoryInitError(
+ log.msg(
"Open Directory (node=%s) /Computers/%s record does not have "
"any host details in its XMLPlist attribute value"
- % (self.realmName, self.computerRecordName)
+ % (self.realmName, recordname)
)
+ return False
self.hostvariants = []
for key, value in hostdetails.iteritems():
self.hostvariants.append((key, hostname, value["port"]))
@@ -198,36 +229,43 @@
# Look at the service data
serviceInfos = vhosts[hostguid].get("serviceInfo", None)
if not serviceInfos or not serviceInfos.has_key("calendar"):
- raise OpenDirectoryInitError(
+ log.msg(
"Open Directory (node=%s) /Computers/%s record does not have a "
"calendar service in its XMLPlist attribute value"
- % (self.realmName, self.computerRecordName)
+ % (self.realmName, recordname)
)
+ return False
serviceInfo = serviceInfos["calendar"]
# Check that this service is enabled
- enabled = serviceInfo.get("enabled", "YES")
- if enabled != "YES":
- raise OpenDirectoryInitError(
+ enabled = serviceInfo.get("enabled", True)
+ if not enabled:
+ log.msg(
"Open Directory (node=%s) /Computers/%s record does not have an "
"enabled calendar service in its XMLPlist attribute value"
- % (self.realmName, self.computerRecordName)
+ % (self.realmName, recordname)
)
+ return False
# Get useful templates
templates = serviceInfo.get("templates", None)
if not templates or not templates.has_key("calendarUserAddresses"):
- raise OpenDirectoryInitError(
+ log.msg(
"Open Directory (node=%s) /Computers/%s record does not have a "
"template for calendar user addresses in its XMLPlist attribute value"
- % (self.realmName, self.computerRecordName)
+ % (self.realmName, recordname)
)
+ return False
+ self.computerRecordName = recordname
+
# Grab the templates we need for calendar user addresses
self.cuaddrtemplates = tuple(templates["calendarUserAddresses"])
# Create the string we will use to match users with accounts on this server
self.servicetag = "%s:%s:calendar" % (recordguid, hostguid)
+
+ return True
def _templateExpandCalendarUserAddresses(self, recordType, recordName, record):
"""
Modified: CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/directory/test/test_opendirectoryschema.py
===================================================================
--- CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/directory/test/test_opendirectoryschema.py 2007-01-23 16:29:15 UTC (rev 1085)
+++ CalendarServer/branches/users/cdaboo/od-schema-1044/twistedcaldav/directory/test/test_opendirectoryschema.py 2007-01-23 16:32:47 UTC (rev 1086)
@@ -66,12 +66,12 @@
<key>http</key>
<dict>
<key>port</key>
- <string>80</string>
+ <integer>80</integer>
</dict>
<key>https</key>
<dict>
<key>port</key>
- <string>443</string>
+ <integer>443</integer>
</dict>
</dict>
@@ -87,23 +87,23 @@
<key>webCalendar</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/webcalendar</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/webcalendar</string>
</dict>
<key>wiki</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/wiki</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/wiki</string>
</dict>
<key>webMailingList</key>
<dict>
<key>enabled</key>
<true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/mailinglist</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/mailinglist</string>
</dict>
</dict>
</dict>
@@ -135,12 +135,12 @@
<key>http</key>
<dict>
<key>port</key>
- <string>80</string>
+ <integer>80</integer>
</dict>
<key>https</key>
<dict>
<key>port</key>
- <string>443</string>
+ <integer>443</integer>
</dict>
</dict>
@@ -156,23 +156,23 @@
<key>webCalendar</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/webcalendar</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/webcalendar</string>
</dict>
<key>wiki</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/wiki</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/wiki</string>
</dict>
<key>webMailingList</key>
<dict>
<key>enabled</key>
<true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/mailinglist</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/mailinglist</string>
</dict>
</dict>
</dict>
@@ -187,12 +187,12 @@
<key>http</key>
<dict>
<key>port</key>
- <string>8008</string>
+ <integer>8008</integer>
</dict>
<key>https</key>
<dict>
<key>port</key>
- <string>8443</string>
+ <integer>8443</integer>
</dict>
</dict>
@@ -206,9 +206,9 @@
<key>webCalendar</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/webcalendar</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/webcalendar</string>
</dict>
</dict>
</dict>
@@ -240,7 +240,7 @@
<key>http</key>
<dict>
<key>port</key>
- <string>80</string>
+ <integer>80</integer>
</dict>
<key>https</key>
<dict>
@@ -261,23 +261,23 @@
<key>webCalendar</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/webcalendar</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/webcalendar</string>
</dict>
<key>wiki</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/wiki</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/wiki</string>
</dict>
<key>webMailingList</key>
<dict>
<key>enabled</key>
<true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/mailinglist</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/mailinglist</string>
</dict>
</dict>
</dict>
@@ -292,12 +292,12 @@
<key>http</key>
<dict>
<key>port</key>
- <string>8008</string>
+ <integer>8008</integer>
</dict>
<key>https</key>
<dict>
<key>port</key>
- <string>8443</string>
+ <integer>8443</integer>
</dict>
</dict>
@@ -311,7 +311,7 @@
<key>calendar</key>
<dict>
<key>enabled</key>
- <string>NO</string>
+ <false/>
<key>templates</key>
<dict>
<key>principalPath</key>
@@ -354,7 +354,7 @@
<key>http</key>
<dict>
<key>port</key>
- <string>80</string>
+ <integer>80</integer>
</dict>
<key>https</key>
<dict>
@@ -375,23 +375,23 @@
<key>webCalendar</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/webcalendar</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/webcalendar</string>
</dict>
<key>wiki</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/wiki</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/wiki</string>
</dict>
<key>webMailingList</key>
<dict>
<key>enabled</key>
<true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/mailinglist</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/mailinglist</string>
</dict>
</dict>
</dict>
@@ -403,12 +403,12 @@
<key>http</key>
<dict>
<key>port</key>
- <string>8008</string>
+ <integer>8008</integer>
</dict>
<key>https</key>
<dict>
<key>port</key>
- <string>8443</string>
+ <integer>8443</integer>
</dict>
</dict>
@@ -463,7 +463,7 @@
<key>http</key>
<dict>
<key>port</key>
- <string>80</string>
+ <integer>80</integer>
</dict>
<key>https</key>
<dict>
@@ -484,23 +484,23 @@
<key>webCalendar</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/webcalendar</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/webcalendar</string>
</dict>
<key>wiki</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/wiki</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/wiki</string>
</dict>
<key>webMailingList</key>
<dict>
<key>enabled</key>
<true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/mailinglist</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/mailinglist</string>
</dict>
</dict>
</dict>
@@ -561,7 +561,7 @@
<key>http</key>
<dict>
<key>port</key>
- <string>80</string>
+ <integer>80</integer>
</dict>
<key>https</key>
<dict>
@@ -582,23 +582,23 @@
<key>webCalendar</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/webcalendar</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/webcalendar</string>
</dict>
<key>wiki</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/wiki</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/wiki</string>
</dict>
<key>webMailingList</key>
<dict>
<key>enabled</key>
<true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/mailinglist</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/mailinglist</string>
</dict>
</dict>
</dict>
@@ -613,12 +613,12 @@
<key>http</key>
<dict>
<key>port</key>
- <string>8008</string>
+ <integer>8008</integer>
</dict>
<key>https</key>
<dict>
<key>port</key>
- <string>8443</string>
+ <integer>8443</integer>
</dict>
</dict>
@@ -644,7 +644,6 @@
</dict>
</plist>
"""
-
plist_good = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@@ -667,7 +666,7 @@
<key>http</key>
<dict>
<key>port</key>
- <string>80</string>
+ <integer>80</integer>
</dict>
<key>https</key>
<dict>
@@ -688,23 +687,23 @@
<key>webCalendar</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/webcalendar</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/webcalendar</string>
</dict>
<key>wiki</key>
<dict>
<key>enabled</key>
- <string>YES</string>
+ <true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/wiki</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/wiki</string>
</dict>
<key>webMailingList</key>
<dict>
<key>enabled</key>
<true/>
<key>urlMask</key>
- <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(groupname)s/mailinglist</string>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/mailinglist</string>
</dict>
</dict>
</dict>
@@ -719,12 +718,12 @@
<key>http</key>
<dict>
<key>port</key>
- <string>8008</string>
+ <integer>8008</integer>
</dict>
<key>https</key>
<dict>
<key>port</key>
- <string>8443</string>
+ <integer>8443</integer>
</dict>
</dict>
@@ -757,14 +756,123 @@
</plist>
"""
+ plist_good_other = """<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>ReplicaName</key>
+ <string>Master</string>
+
+ <key>com.apple.od.role</key>
+ <string>master</string>
+
+ <key>com.apple.macosxserver.virtualhosts</key>
+ <dict>
+ <key>4F088107-51FD-4DE5-904D-2C0AD9C6C893</key>
+ <dict>
+ <key>hostname</key>
+ <string>foo.apple.com</string>
+
+ <key>hostDetails</key>
+ <dict>
+ <key>http</key>
+ <dict>
+ <key>port</key>
+ <integer>80</integer>
+ </dict>
+ <key>https</key>
+ <dict>
+ <key>port</key>
+ <string>443</string>
+ </dict>
+ </dict>
+
+ <key>serviceType</key>
+ <array>
+ <string>wiki</string>
+ <string>webCalendar</string>
+ <string>webMailingList</string>
+ </array>
+
+ <key>serviceInfo</key>
+ <dict>
+ <key>webCalendar</key>
+ <dict>
+ <key>enabled</key>
+ <true/>
+ <key>urlMask</key>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/webcalendar</string>
+ </dict>
+ <key>wiki</key>
+ <dict>
+ <key>enabled</key>
+ <true/>
+ <key>urlMask</key>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/wiki</string>
+ </dict>
+ <key>webMailingList</key>
+ <dict>
+ <key>enabled</key>
+ <true/>
+ <key>urlMask</key>
+ <string>%(scheme)s://%(hostname)s:%(port)s/groups/%(name)s/mailinglist</string>
+ </dict>
+ </dict>
+ </dict>
+
+ <key>C18C34AC-3D9E-403C-8A33-BFC303F3840E</key>
+ <dict>
+ <key>hostname</key>
+ <string>privatecalendar.apple.com</string>
+
+ <key>hostDetails</key>
+ <dict>
+ <key>http</key>
+ <dict>
+ <key>port</key>
+ <integer>8008</integer>
+ </dict>
+ <key>https</key>
+ <dict>
+ <key>port</key>
+ <integer>8443</integer>
+ </dict>
+ </dict>
+
+ <key>serviceType</key>
+ <array>
+ <string>calendar</string>
+ </array>
+
+ <key>serviceInfo</key>
+ <dict>
+ <key>calendar</key>
+ <dict>
+ <key>templates</key>
+ <dict>
+ <key>principalPath</key>
+ <string>/principals/%(type)s/%(name)s</string>
+ <key>calendarUserAddresses</key>
+ <array>
+ <string>%(scheme)s://%(hostname)s:%(port)s/principals/%(type)s/%(name)s</string>
+ <string>mailto:%(email)s</string>
+ <string>urn:uuid:%(guid)s</string>
+ </array>
+ </dict>
+ </dict>
+ </dict>
+ </dict>
+
+ </dict>
+ </dict>
+</plist>
+"""
+
def test_plist_errors(self):
def _doParse(plist, title):
service = OpenDirectoryService(node="/Search", dosetup=False)
- try:
- service._parseXMLPlist(plist, "GUIDIFY")
+ if service._parseXMLPlist("calendar.apple.com", "recordit", plist, "GUIDIFY"):
self.fail(msg="Plist parse should have failed: %s" % (title,))
- except OpenDirectoryInitError:
- pass
plists = (
(PlistParse.plist_nomacosxserver_key, "nomacosxserver_key"),
@@ -780,21 +888,24 @@
def test_goodplist(self):
service = OpenDirectoryService(node="/Search", dosetup=False)
- service._parseXMLPlist(PlistParse.plist_good, "GUIDIFY")
-
- # Verify that we extracted the proper items
- self.assertEqual(service.servicetag, "GUIDIFY:C18C34AC-3D9E-403C-8A33-BFC303F3840E:calendar")
- self.assertEqual(service.hostvariants, (("http", "calendar.apple.com", "8008"), ("https", "calendar.apple.com", "8443")))
- self.assertEqual(service.cuaddrtemplates, ("%(scheme)s://%(hostname)s:%(port)s/principals/%(type)s/%(name)s", "mailto:%(email)s", "urn:uuid:%(guid)s"))
+ if not service._parseXMLPlist("calendar.apple.com", "recordit", PlistParse.plist_good, "GUIDIFY"):
+ self.fail(msg="Plist parse should not have failed")
+ else:
+ # Verify that we extracted the proper items
+ self.assertEqual(service.servicetag, "GUIDIFY:C18C34AC-3D9E-403C-8A33-BFC303F3840E:calendar")
+ self.assertEqual(service.hostvariants, (("http", "calendar.apple.com", 8008), ("https", "calendar.apple.com", 8443)))
+ self.assertEqual(service.cuaddrtemplates, ("%(scheme)s://%(hostname)s:%(port)s/principals/%(type)s/%(name)s", "mailto:%(email)s", "urn:uuid:%(guid)s"))
def test_expandcuaddrs(self):
def _doTest(recordName, record, result, title):
service = OpenDirectoryService(node="/Search", dosetup=False)
- service._parseXMLPlist(PlistParse.plist_good, "GUIDIFY")
- expanded = service._templateExpandCalendarUserAddresses(DirectoryService.recordType_users, recordName, record)
-
- # Verify that we extracted the proper items
- self.assertEqual(expanded, result, msg=title % (expanded, result,))
+ if not service._parseXMLPlist("calendar.apple.com", recordName, PlistParse.plist_good, "GUIDIFY"):
+ self.fail(msg="Plist parse should not have failed: %s" % (recordName,))
+ else:
+ expanded = service._templateExpandCalendarUserAddresses(DirectoryService.recordType_users, recordName, record)
+
+ # Verify that we extracted the proper items
+ self.assertEqual(expanded, result, msg=title % (expanded, result,))
data = (
(
@@ -842,4 +953,66 @@
for recordName, record, result, title in data:
_doTest(recordName, record, result, title)
-
\ No newline at end of file
+
+ class ODRecordsParse (twisted.trial.unittest.TestCase):
+
+ record_good = ("computer1.apple.com", {
+ dsattributes.kDS1AttrGeneratedUID : "GUID1",
+ dsattributes.kDSNAttrRecordName : "computer1.apple.com",
+ dsattributes.kDS1AttrXMLPlist : PlistParse.plist_good,
+ })
+ record_good_other = ("computer2.apple.com", {
+ dsattributes.kDS1AttrGeneratedUID : "GUID1",
+ dsattributes.kDSNAttrRecordName : "computer2.apple.com",
+ dsattributes.kDS1AttrXMLPlist : PlistParse.plist_good_other,
+ })
+ record_good_duplicate = ("computer2.apple.com", {
+ dsattributes.kDS1AttrGeneratedUID : "GUID1",
+ dsattributes.kDSNAttrRecordName : "computer2.apple.com",
+ dsattributes.kDS1AttrXMLPlist : PlistParse.plist_good,
+ })
+
+ def test_odrecords_error(self):
+ def _doParseRecords(recordlist, title):
+ service = OpenDirectoryService(node="/Search", dosetup=False)
+ try:
+ service._parseComputersRecords(recordlist, "calendar.apple.com")
+ self.fail(msg="Record parse should have failed: %s" % (title,))
+ except OpenDirectoryInitError:
+ pass
+
+ records = (
+ ({}, "no records found"),
+ ({
+ ODRecordsParse.record_good[0] : ODRecordsParse.record_good[1],
+ ODRecordsParse.record_good_duplicate[0] : ODRecordsParse.record_good_duplicate[1],
+ }, "duplicate records found"),
+ ({
+ ODRecordsParse.record_good_other[0] : ODRecordsParse.record_good_other[1],
+ }, "non-matching record found"),
+ )
+
+ for recordlist, title in records:
+ _doParseRecords(recordlist, title)
+
+ def test_odrecords_good(self):
+ def _doParseRecords(recordlist, title):
+ service = OpenDirectoryService(node="/Search", dosetup=False)
+ try:
+ service._parseComputersRecords(recordlist, "calendar.apple.com")
+ except OpenDirectoryInitError, ex:
+ self.fail(msg="Record parse should not have failed: \"%s\" with error: %s" % (title, ex))
+
+ records = (
+ ({
+ ODRecordsParse.record_good[0] : ODRecordsParse.record_good[1],
+ }, "single good plist"),
+ ({
+ ODRecordsParse.record_good[0] : ODRecordsParse.record_good[1],
+ ODRecordsParse.record_good_other[0] : ODRecordsParse.record_good_other[1],
+ }, "multiple plists"),
+ )
+
+ for recordlist, title in records:
+ _doParseRecords(recordlist, title)
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070123/6a439749/attachment.html
More information about the calendarserver-changes
mailing list