[CalendarServer-changes] [13993] CalDAVTester/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Sep 22 12:46:49 PDT 2014


Revision: 13993
          http://trac.calendarserver.org//changeset/13993
Author:   cdaboo at apple.com
Date:     2014-09-22 12:46:49 -0700 (Mon, 22 Sep 2014)
Log Message:
-----------
Add GETROTHER method to make it easier to find new siblings of an existing resource. Allow request data files to be "parameterized" on a per-request basis.

Modified Paths:
--------------
    CalDAVTester/trunk/README.txt
    CalDAVTester/trunk/scripts/tests/CalDAV/caldavtest.dtd
    CalDAVTester/trunk/scripts/tests/CardDAV/caldavtest.dtd
    CalDAVTester/trunk/scripts/tests-pod/CalDAV/caldavtest.dtd
    CalDAVTester/trunk/src/caldavtest.py
    CalDAVTester/trunk/src/request.py
    CalDAVTester/trunk/src/xmlDefs.py

Modified: CalDAVTester/trunk/README.txt
===================================================================
--- CalDAVTester/trunk/README.txt	2014-09-22 19:04:09 UTC (rev 13992)
+++ CalDAVTester/trunk/README.txt	2014-09-22 19:46:49 UTC (rev 13993)
@@ -304,6 +304,7 @@
 				6) GETCHANGED - the tool tracks the Etags on resources retrieved via GET. This special method will poll the specified
 								resource until the Etag returned in the response is different from the one found in the most recent
 								test.  
+				6) GETOTHER - the tool finds the newest sibling resource to the one specified in the <ruri> element.  
 	
 		ELEMENT <ruri>
 			the URI of the request. Multiple <ruri>'s are allowed with DELETEALL only.
@@ -337,6 +338,15 @@
 			ELEMENT <filepath>
 				the relative path for the file containing the request body
 				data.
+	
+			ELEMENT <substitute>
+				a set of substitution variables to use on this data only.
+			
+				ELEMENT <name>
+					the variable name.
+		
+				ELEMENT <value>
+					the variable value.
 
 		ELEMENT <verify>
 			if present, used to specify a procedures for verifying that the

Modified: CalDAVTester/trunk/scripts/tests/CalDAV/caldavtest.dtd
===================================================================
--- CalDAVTester/trunk/scripts/tests/CalDAV/caldavtest.dtd	2014-09-22 19:04:09 UTC (rev 13992)
+++ CalDAVTester/trunk/scripts/tests/CalDAV/caldavtest.dtd	2014-09-22 19:46:49 UTC (rev 13993)
@@ -45,11 +45,12 @@
 		<!ELEMENT header (name, value)>
 			<!ELEMENT name (#PCDATA)>
 			<!ELEMENT value (#PCDATA)>
-		<!ELEMENT data (content-type, filepath)>
+		<!ELEMENT data (content-type, filepath, substitute*)>
 			<!ATTLIST data substitutions (yes|no) "yes"
 			               generate      (yes|no) "no">
 			<!ELEMENT content-type (#PCDATA)>
 			<!ELEMENT filepath (#PCDATA)>
+			<!ELEMENT substitute (name, value)>
 
 		<!ELEMENT verify (require-feature?, exclude-feature?, callback, arg*)>
 			

Modified: CalDAVTester/trunk/scripts/tests/CardDAV/caldavtest.dtd
===================================================================
--- CalDAVTester/trunk/scripts/tests/CardDAV/caldavtest.dtd	2014-09-22 19:04:09 UTC (rev 13992)
+++ CalDAVTester/trunk/scripts/tests/CardDAV/caldavtest.dtd	2014-09-22 19:46:49 UTC (rev 13993)
@@ -45,11 +45,12 @@
 		<!ELEMENT header (name, value)>
 			<!ELEMENT name (#PCDATA)>
 			<!ELEMENT value (#PCDATA)>
-		<!ELEMENT data (content-type, filepath)>
+		<!ELEMENT data (content-type, filepath, substitute*)>
 			<!ATTLIST data substitutions (yes|no) "yes"
 			               generate      (yes|no) "no">
 			<!ELEMENT content-type (#PCDATA)>
 			<!ELEMENT filepath (#PCDATA)>
+			<!ELEMENT substitute (name, value)>
 
 		<!ELEMENT verify (require-feature?, exclude-feature?, callback, arg*)>
 			

Modified: CalDAVTester/trunk/scripts/tests-pod/CalDAV/caldavtest.dtd
===================================================================
--- CalDAVTester/trunk/scripts/tests-pod/CalDAV/caldavtest.dtd	2014-09-22 19:04:09 UTC (rev 13992)
+++ CalDAVTester/trunk/scripts/tests-pod/CalDAV/caldavtest.dtd	2014-09-22 19:46:49 UTC (rev 13993)
@@ -45,11 +45,12 @@
 		<!ELEMENT header (name, value)>
 			<!ELEMENT name (#PCDATA)>
 			<!ELEMENT value (#PCDATA)>
-		<!ELEMENT data (content-type, filepath)>
+		<!ELEMENT data (content-type, filepath, substitute*)>
 			<!ATTLIST data substitutions (yes|no) "yes"
 			               generate      (yes|no) "no">
 			<!ELEMENT content-type (#PCDATA)>
 			<!ELEMENT filepath (#PCDATA)>
+			<!ELEMENT substitute (name, value)>
 
 		<!ELEMENT verify (require-feature?, exclude-feature?, callback, arg*)>
 			
@@ -74,7 +75,8 @@
 	<!ELEMENT test-suite (require-feature?, exclude-feature?, test*)>
 		<!ATTLIST test-suite name CDATA #REQUIRED
 							ignore (yes|no) "no"
-							only (yes|no) "no">
+							only (yes|no) "no"
+							change-uid (yes|no) "no">
 	
 		<!ELEMENT test (require-feature?, exclude-feature?, description?, (request|pause)+)>
 			<!ATTLIST test name CDATA #REQUIRED

Modified: CalDAVTester/trunk/src/caldavtest.py
===================================================================
--- CalDAVTester/trunk/src/caldavtest.py	2014-09-22 19:04:09 UTC (rev 13992)
+++ CalDAVTester/trunk/src/caldavtest.py	2014-09-22 19:46:49 UTC (rev 13993)
@@ -255,7 +255,7 @@
             req.user = collection[1]
         if len(collection[2]):
             req.pswd = collection[2]
-        req.data = data()
+        req.data = data(self.manager)
         req.data.value = """<?xml version="1.0" encoding="utf-8" ?>
 <D:propfind xmlns:D="DAV:">
 <D:prop>
@@ -303,19 +303,27 @@
         return True
 
 
-    def dofindnew(self, collection, label=""):
+    def dofindnew(self, collection, label="", other=False):
         hresult = ""
+
+        uri = collection[0]
+        if other:
+            uri = self.manager.server_info.extrasubs(uri)
+            skip = uri
+            uri = "/".join(uri.split("/")[:-1]) + "/"
+        else:
+            skip = None
         possible_matches = set()
         req = request(self.manager)
         req.method = "PROPFIND"
-        req.ruris.append(collection[0])
-        req.ruri = collection[0]
+        req.ruris.append(uri)
+        req.ruri = uri
         req.headers["Depth"] = "1"
         if len(collection[1]):
             req.user = collection[1]
         if len(collection[2]):
             req.pswd = collection[2]
-        req.data = data()
+        req.data = data(self.manager)
         req.data.value = """<?xml version="1.0" encoding="utf-8" ?>
 <D:propfind xmlns:D="DAV:">
 <D:prop>
@@ -341,7 +349,7 @@
                 if len(href) != 1:
                     return False, "           Wrong number of DAV:href elements\n"
                 href = href[0].text
-                if href != request_uri:
+                if href != request_uri and (not other or href != skip):
 
                     # Get all property status
                     propstatus = response.findall("{DAV:}propstat")
@@ -400,7 +408,7 @@
                 req.user = collection[1]
             if len(collection[2]):
                 req.pswd = collection[2]
-            req.data = data()
+            req.data = data(self.manager)
             req.data.value = """<?xml version="1.0" encoding="utf-8" ?>
 <D:propfind xmlns:D="DAV:">
 <D:prop>
@@ -525,6 +533,15 @@
                 self.manager.server_info.addextrasubs({req.graburi: self.grabbedlocation})
             return True, "", None, None
 
+        # Special for GETOTHER
+        elif req.method == "GETOTHER":
+            collection = (req.ruri, req.user, req.pswd)
+            self.grabbedlocation = self.dofindnew(collection, label=label, other=True)
+            if req.graburi:
+                self.manager.server_info.addextrasubs({req.graburi: self.grabbedlocation})
+            req.method = "GET"
+            req.ruri = "$"
+
         # Special check for WAITCOUNT
         elif req.method.startswith("WAITCOUNT"):
             count = int(req.method[10:])

Modified: CalDAVTester/trunk/src/request.py
===================================================================
--- CalDAVTester/trunk/src/request.py	2014-09-22 19:04:09 UTC (rev 13992)
+++ CalDAVTester/trunk/src/request.py	2014-09-22 19:46:49 UTC (rev 13993)
@@ -306,6 +306,8 @@
             data = str(self.manager.server_info.subs(data))
             self.manager.server_info.addextrasubs({"$request_count:": str(self.count)})
             data = self.manager.server_info.extrasubs(data)
+            if self.data.substitutions:
+                data = self.manager.server_info.subs(data, self.data.substitutions)
             if self.data.generate:
                 if self.data.content_type.startswith("text/calendar"):
                     data = self.generateCalendarData(data)
@@ -377,7 +379,7 @@
                 if len(self.ruris) == 1:
                     self.ruri = self.ruris[0]
             elif child.tag == src.xmlDefs.ELEMENT_DATA:
-                self.data = data()
+                self.data = data(self.manager)
                 self.data.parseXML(child)
             elif child.tag == src.xmlDefs.ELEMENT_VERIFY:
                 self.verifiers.append(verify(self.manager))
@@ -470,10 +472,12 @@
     Represents the data/body portion of an HTTP request.
     """
 
-    def __init__(self):
+    def __init__(self, manager):
+        self.manager = manager
         self.content_type = ""
         self.filepath = ""
         self.value = ""
+        self.substitutions = {}
         self.substitute = False
         self.generate = False
 
@@ -488,9 +492,23 @@
                 self.content_type = child.text.encode("utf-8")
             elif child.tag == src.xmlDefs.ELEMENT_FILEPATH:
                 self.filepath = child.text.encode("utf-8")
+            elif child.tag == src.xmlDefs.ELEMENT_SUBSTITUTE:
+                self.parseSubstituteXML(child)
 
 
+    def parseSubstituteXML(self, node):
+        name = None
+        value = None
+        for child in node.getchildren():
+            if child.tag == src.xmlDefs.ELEMENT_NAME:
+                name = child.text.encode("utf-8")
+            elif child.tag == src.xmlDefs.ELEMENT_VALUE:
+                value = self.manager.server_info.subs(child.text.encode("utf-8"))
+        if name and value:
+            self.substitutions[name] = value
 
+
+
 class verify(object):
     """
     Defines how the result of a request should be verified. This is done

Modified: CalDAVTester/trunk/src/xmlDefs.py
===================================================================
--- CalDAVTester/trunk/src/xmlDefs.py	2014-09-22 19:04:09 UTC (rev 13992)
+++ CalDAVTester/trunk/src/xmlDefs.py	2014-09-22 19:46:49 UTC (rev 13993)
@@ -64,6 +64,7 @@
 ELEMENT_SSLPORT2 = "sslport2"
 ELEMENT_START = "start"
 ELEMENT_SUBJECT = "subject"
+ELEMENT_SUBSTITUTE = "substitute"
 ELEMENT_SUBSTITUTIONS = "substitutions"
 ELEMENT_SUBSTITUTION = "substitution"
 ELEMENT_TEST = "test"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140922/7c427418/attachment-0001.html>


More information about the calendarserver-changes mailing list