[CalendarServer-changes] [10891] CalendarServer/branches/users/gaya/sharedgroups

source_changes at macosforge.org source_changes at macosforge.org
Mon Mar 11 18:16:12 PDT 2013


Revision: 10891
          http://trac.calendarserver.org//changeset/10891
Author:   gaya at apple.com
Date:     2013-03-11 18:16:12 -0700 (Mon, 11 Mar 2013)
Log Message:
-----------
Fix CalDAV/default-addressbook.xml, CalDAV/mkcol.xml

Modified Paths:
--------------
    CalDAVTester/branches/users/gaya/sharedgroupstester/scripts/tests/CardDAV/default-addressbook.xml
    CalDAVTester/branches/users/gaya/sharedgroupstester/scripts/tests/CardDAV/mkcol.xml
    CalendarServer/branches/users/gaya/sharedgroups/twext/web2/resource.py
    CalendarServer/branches/users/gaya/sharedgroups/twistedcaldav/directory/addressbook.py
    CalendarServer/branches/users/gaya/sharedgroups/twistedcaldav/resource.py
    CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py

Removed Paths:
-------------
    CalDAVTester/branches/users/gaya/sharedgroupstester/Resource/CardDAV/default-addressbook/4.xml
    CalDAVTester/branches/users/gaya/sharedgroupstester/Resource/CardDAV/mkcol/2.xml
    CalDAVTester/branches/users/gaya/sharedgroupstester/Resource/CardDAV/mkcol/3.xml

Deleted: CalDAVTester/branches/users/gaya/sharedgroupstester/Resource/CardDAV/default-addressbook/4.xml
===================================================================
--- CalDAVTester/branches/users/gaya/sharedgroupstester/Resource/CardDAV/default-addressbook/4.xml	2013-03-11 23:31:15 UTC (rev 10890)
+++ CalDAVTester/branches/users/gaya/sharedgroupstester/Resource/CardDAV/default-addressbook/4.xml	2013-03-12 01:16:12 UTC (rev 10891)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<D:propertyupdate xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
-<D:set>
-<D:prop>
-<C:default-addressbook-URL><D:href>$addressbookpath1:/</D:href></C:default-addressbook-URL>
-</D:prop>
-</D:set>
-</D:propertyupdate>

Deleted: CalDAVTester/branches/users/gaya/sharedgroupstester/Resource/CardDAV/mkcol/2.xml
===================================================================
--- CalDAVTester/branches/users/gaya/sharedgroupstester/Resource/CardDAV/mkcol/2.xml	2013-03-11 23:31:15 UTC (rev 10890)
+++ CalDAVTester/branches/users/gaya/sharedgroupstester/Resource/CardDAV/mkcol/2.xml	2013-03-12 01:16:12 UTC (rev 10891)
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<D:mkcol xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
-<D:set>
-<D:prop>
-<D:resourcetype><D:collection/><C:addressbook/></D:resourcetype>
-<D:getetag>An Address Book</D:getetag>
-<D:displayname>An Address Book</D:displayname>
-<C:addressbook-description xml:lang="en">First CardDAV address book.</C:addressbook-description>
-</D:prop>
-</D:set>
-</D:mkcol>

Deleted: CalDAVTester/branches/users/gaya/sharedgroupstester/Resource/CardDAV/mkcol/3.xml
===================================================================
--- CalDAVTester/branches/users/gaya/sharedgroupstester/Resource/CardDAV/mkcol/3.xml	2013-03-11 23:31:15 UTC (rev 10890)
+++ CalDAVTester/branches/users/gaya/sharedgroupstester/Resource/CardDAV/mkcol/3.xml	2013-03-12 01:16:12 UTC (rev 10891)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<D:mkcol xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
-<D:set>
-<D:prop>
-<D:resourcetype><D:collection/><D:displayname/></D:resourcetype>
-</D:prop>
-</D:set>
-</D:mkcol>

Modified: CalDAVTester/branches/users/gaya/sharedgroupstester/scripts/tests/CardDAV/default-addressbook.xml
===================================================================
--- CalDAVTester/branches/users/gaya/sharedgroupstester/scripts/tests/CardDAV/default-addressbook.xml	2013-03-11 23:31:15 UTC (rev 10890)
+++ CalDAVTester/branches/users/gaya/sharedgroupstester/scripts/tests/CardDAV/default-addressbook.xml	2013-03-12 01:16:12 UTC (rev 10891)
@@ -52,24 +52,6 @@
 	</test-suite>
 
 	<test-suite name='Change property' ignore='no'>
-		<test name='1'  ignore='yes'>
-			<description>MKCOL with correct request body</description>
-			<request end-delete='yes'>
-				<method>MKCOL</method>
-				<ruri>$addressbookhome1:/adbktest1/</ruri>
-				<data>
-					<content-type>text/xml; charset=utf-8</content-type>
-					<filepath>Resource/Common/MKCOL/addressbook.xml</filepath>
-				</data>
-				<verify>
-					<callback>statusCode</callback>
-					<arg>
-						<name>status</name>
-						<value>201</value>
-					</arg>
-				</verify>
-			</request>
-		</test>
 		<test name='2'>
 			<description>Set invalid property on home</description>
 			<request print-response='no'>
@@ -130,45 +112,6 @@
 		</test>
 	</test-suite>
 
-	<test-suite name='Move delete' ignore='yes'>
-		<test name='1'>
-			<description>MOVE</description>
-			<request end-delete='yes'>
-				<method>MOVE</method>
-				<ruri>$addressbookhome1:/adbktest1/</ruri>
-				<header>
-					<name>Destination</name>
-					<value>$host:$addressbookhome1:/adbktest2/</value>
-				</header>
-				<verify>
-					<callback>statusCode</callback>
-				</verify>
-			</request>
-		</test>
-		<test name='2'>
-			<description>PROPFIND on home</description>
-			<request end-delete='yes'>
-				<method>PROPFIND</method>
-				<ruri>$addressbookhome1:/</ruri>
-				<header>
-					<name>Depth</name>
-					<value>0</value>
-				</header>
-				<data>
-					<content-type>text/xml; charset=utf-8</content-type>
-					<filepath>Resource/CardDAV/default-addressbook/1.xml</filepath>
-				</data>
-				<verify>
-					<callback>propfindItems</callback>
-					<arg>
-						<name>okprops</name>
-						<value><![CDATA[{urn:ietf:params:xml:ns:carddav}default-addressbook-URL$<href xmlns="DAV:">$addressbookhome1:/adbktest2/</href>]]></value>
-					</arg>
-				</verify>
-			</request>
-		</test>
-	</test-suite>
-
 	<test-suite name='No default delete'>
 		<test name='1' ignore='yes'>
 			<description>DELETE</description>

Modified: CalDAVTester/branches/users/gaya/sharedgroupstester/scripts/tests/CardDAV/mkcol.xml
===================================================================
--- CalDAVTester/branches/users/gaya/sharedgroupstester/scripts/tests/CardDAV/mkcol.xml	2013-03-11 23:31:15 UTC (rev 10890)
+++ CalDAVTester/branches/users/gaya/sharedgroupstester/scripts/tests/CardDAV/mkcol.xml	2013-03-12 01:16:12 UTC (rev 10891)
@@ -27,7 +27,7 @@
 	
 	<test-suite name='OPTIONS header' ignore='no'>
 		<test name='1'>
-			<description>Look for options header tag</description>
+			<description>Look for options header DAV</description>
 			<request print-response="no">
 				<method>OPTIONS</method>
 				<ruri>$addressbookhome1:/</ruri>
@@ -35,14 +35,28 @@
 					<callback>header</callback>
 					<arg>
 						<name>header</name>
-						<value>*DAV$.*extended-mkcol.*</value>
+						<value>*DAV!.*extended-mkcol.*</value>
 					</arg>
 				</verify>
 			</request>
 		</test>
+		<test name='2'>
+			<description>Look for options header Allow</description>
+			<request print-response="no">
+				<method>OPTIONS</method>
+				<ruri>$addressbookhome1:/</ruri>
+				<verify>
+					<callback>header</callback>
+					<arg>
+						<name>header</name>
+						<value>*Allow!.*MKCOL.*</value>
+					</arg>
+				</verify>
+			</request>
+		</test>
 	</test-suite>
 
-	<test-suite name='MKCOL with body' ignore='yes'>
+	<test-suite name='MKCOL with body'>
 		<test name='1'>
 			<description>MKCOL with correct request body</description>
 			<request end-delete='yes'>
@@ -56,105 +70,11 @@
 					<callback>statusCode</callback>
 					<arg>
 						<name>status</name>
-						<value>201</value>
-					</arg>
-				</verify>
-			</request>
-		</test>
-		<test name='2'>
-			<description>MKCOL with correct request body on existing resource</description>
-			<request>
-				<method>MKCOL</method>
-				<ruri>$addressbookhome1:/adbktest1/</ruri>
-				<data>
-					<content-type>text/xml; charset=utf-8</content-type>
-					<filepath>Resource/CardDAV/mkcol/1.xml</filepath>
-				</data>
-				<verify>
-					<callback>prepostcondition</callback>
-					<arg>
-						<name>error</name>
-						<value>{DAV:}resource-must-be-null</value>
-					</arg>
-				</verify>
-			</request>
-		</test>
- 		<test name='3'>
-			<description>MKCOL with incorrect request body</description>
-			<request end-delete='yes' print-response='no'>
-				<method>MKCOL</method>
-				<ruri>$addressbookhome1:/adbktest2/</ruri>
-				<data>
-					<content-type>text/xml; charset=utf-8</content-type>
-					<filepath>Resource/CardDAV/mkcol/2.xml</filepath>
-				</data>
-				<verify>
-					<callback>propfindItems</callback>
-					<arg>
-						<name>status</name>
 						<value>403</value>
 					</arg>
-					<arg>
-						<name>root-element</name>
-						<value>{DAV:}mkcol-response</value>
-					</arg>
-					<arg>
-						<name>badprops</name>
-						<value>{DAV:}resourcetype</value>
-						<value>{DAV:}getetag</value>
-						<value>{DAV:}displayname</value>
-						<value>{urn:ietf:params:xml:ns:carddav}addressbook-description</value>
-					</arg>
 				</verify>
 			</request>
-			<request print-response='no'>
-				<method>GET</method>
-				<ruri>$addressbookhome1:/adbktest2/</ruri>
-				<verify>
-					<callback>statusCode</callback>
-					<arg>
-						<name>status</name>
-						<value>404</value>
-					</arg>
-				</verify>
-			</request>
 		</test>
-		<test name='4'>
-			<description>MKCOL with incorrect request body on existing resource</description>
-			<request>
-				<method>MKCOL</method>
-				<ruri>$addressbookhome1:/adbktest1/</ruri>
-				<data>
-					<content-type>text/xml; charset=utf-8</content-type>
-					<filepath>Resource/CardDAV/mkcol/2.xml</filepath>
-				</data>
-				<verify>
-					<callback>prepostcondition</callback>
-					<arg>
-						<name>error</name>
-						<value>{DAV:}resource-must-be-null</value>
-					</arg>
-				</verify>
-			</request>
-		</test>
-		<test name='5'>
-			<description>MKCOL with incorrect resourcetype on new resource</description>
-			<request>
-				<method>MKCOL</method>
-				<ruri>$addressbookhome1:/adbktest3/</ruri>
-				<data>
-					<content-type>text/xml; charset=utf-8</content-type>
-					<filepath>Resource/CardDAV/mkcol/3.xml</filepath>
-				</data>
-				<verify>
-					<callback>statusCode</callback>
-					<arg>
-						<name>status</name>
-						<value>400</value>
-					</arg>
-				</verify>
-			</request>
-		</test>
 	</test-suite>
 
 	<end/>

Modified: CalendarServer/branches/users/gaya/sharedgroups/twext/web2/resource.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups/twext/web2/resource.py	2013-03-11 23:31:15 UTC (rev 10890)
+++ CalendarServer/branches/users/gaya/sharedgroups/twext/web2/resource.py	2013-03-12 01:16:12 UTC (rev 10891)
@@ -45,7 +45,8 @@
         @return: A tuple of HTTP methods that are allowed to be invoked on this resource.
         """
         if not hasattr(self, "_allowed_methods"):
-            self._allowed_methods = tuple([name[5:] for name in dir(self) if name.startswith('http_')])
+            self._allowed_methods = tuple([name[5:] for name in dir(self) 
+                if name.startswith('http_') and getattr(self, name) is not None])
         return self._allowed_methods
 
     def checkPreconditions(self, request):
@@ -189,7 +190,7 @@
         of this resource which matches one or more of the given C{segments} in
         sequence, and a list of remaining segments.
         """
-        w = getattr(self, 'child_%s' % (segments[0], ), None)
+        w = getattr(self, 'child_%s' % (segments[0],), None)
 
         if w:
             r = iweb.IResource(w, None)
@@ -227,12 +228,12 @@
             resource (e.g. C{/foo/}) specify C{path} as C{""}.
         @param child: an object adaptable to L{iweb.IResource}.
         """
-        setattr(self, 'child_%s' % (path, ), child)
+        setattr(self, 'child_%s' % (path,), child)
 
     def http_GET(self, request):
         if self.addSlash and request.prepath[-1] != '':
             # If this is a directory-ish resource...
-            return http.RedirectResponse(request.unparseURL(path=request.path+'/'))
+            return http.RedirectResponse(request.unparseURL(path=request.path + '/'))
 
         return super(Resource, self).http_GET(request)
 
@@ -287,7 +288,7 @@
         default to the corresponding component of the URL of the request being
         redirected.
         """
-        self._args   = args
+        self._args = args
         self._kwargs = kwargs
 
     def renderHTTP(self, request):
@@ -302,7 +303,7 @@
     implements(iweb.IResource)
 
     def __init__(self, resource):
-        self.resource=resource
+        self.resource = resource
 
     def hook(self, request):
         """

Modified: CalendarServer/branches/users/gaya/sharedgroups/twistedcaldav/directory/addressbook.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups/twistedcaldav/directory/addressbook.py	2013-03-11 23:31:15 UTC (rev 10890)
+++ CalendarServer/branches/users/gaya/sharedgroups/twistedcaldav/directory/addressbook.py	2013-03-12 01:16:12 UTC (rev 10891)
@@ -33,13 +33,14 @@
 
 from twisted.internet.defer import inlineCallbacks, returnValue, succeed
 
+from twistedcaldav import mkcolxml
 from twistedcaldav.config import config
 from twistedcaldav.directory.idirectory import IDirectoryService
 
-from twistedcaldav.directory.common import CommonUIDProvisioningResource,\
+from twistedcaldav.directory.common import CommonUIDProvisioningResource, \
     uidsResourceName, CommonHomeTypeProvisioningResource
 
-from twistedcaldav.extensions import ReadOnlyResourceMixIn, DAVResource,\
+from twistedcaldav.extensions import ReadOnlyResourceMixIn, DAVResource, \
     DAVResourceWithChildrenMixin
 from twistedcaldav.resource import AddressBookHomeResource
 
@@ -51,11 +52,13 @@
 # FIXME: copied from resource.py to avoid circular dependency
 class CalDAVComplianceMixIn(object):
     def davComplianceClasses(self):
-        return (
-            tuple(super(CalDAVComplianceMixIn, self).davComplianceClasses())
+        result = tuple(super(CalDAVComplianceMixIn, self).davComplianceClasses()) \
             + config.CalDAVComplianceClasses
-        )
+        if mkcolxml.mkcol_compliance in result:
+            list(result).remove(mkcolxml.mkcol_compliance)
+        return tuple(result)
 
+
 class DirectoryAddressBookProvisioningResource (
     ReadOnlyResourceMixIn,
     CalDAVComplianceMixIn,
@@ -129,7 +132,7 @@
     ##
     # DAV
     ##
-    
+
     def isCollection(self):
         return True
 
@@ -183,7 +186,7 @@
     ##
     # DAV
     ##
-    
+
     def isCollection(self):
         return True
 

Modified: CalendarServer/branches/users/gaya/sharedgroups/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups/twistedcaldav/resource.py	2013-03-11 23:31:15 UTC (rev 10890)
+++ CalendarServer/branches/users/gaya/sharedgroups/twistedcaldav/resource.py	2013-03-12 01:16:12 UTC (rev 10891)
@@ -57,8 +57,7 @@
 from twext.web2.http_headers import MimeType, ETag
 from twext.web2.stream import MemoryStream
 
-from twistedcaldav import caldavxml, customxml
-from twistedcaldav import carddavxml
+from twistedcaldav import caldavxml, customxml, carddavxml, mkcolxml
 from twistedcaldav.cache import PropfindCacheMixin, DisabledCacheNotifier, \
     CacheStoreNotifier
 from twistedcaldav.caldavxml import caldav_namespace
@@ -2732,11 +2731,25 @@
 
 
 
-class AddressBookHomeResource (CommonHomeResource):
+class AddressBookHomeResource (CommonHomeResource, CalDAVComplianceMixIn):
     """
     Address book home collection resource.
     """
 
+
+    def __init__(self, *args, **kw):
+        super(AddressBookHomeResource, self).__init__(*args, **kw)
+        self.http_MKCOL = None
+        self.http_MKCALENDAR = None
+
+
+    def davComplianceClasses(self):
+        result = super(CalDAVComplianceMixIn, self).davComplianceClasses()
+        if mkcolxml.mkcol_compliance in result:
+            list(result).remove(mkcolxml.mkcol_compliance)
+        return tuple(result)
+
+
     @classmethod
     @inlineCallbacks
     def homeFromTransaction(cls, transaction, uid):

Modified: CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py	2013-03-11 23:31:15 UTC (rev 10890)
+++ CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py	2013-03-12 01:16:12 UTC (rev 10891)
@@ -395,7 +395,8 @@
             #raise HomeChildNameAlreadyExistsError
             pass
         else:
-            raise HomeChildNameNotAllowedError
+            #raise HomeChildNameNotAllowedError
+            raise HTTPError(FORBIDDEN)
 
 
     @inlineCallbacks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130311/27879767/attachment-0001.html>


More information about the calendarserver-changes mailing list