[CalendarServer-changes] [15065] CalDAVTester/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Aug 21 12:43:09 PDT 2015


Revision: 15065
          http://trac.calendarserver.org//changeset/15065
Author:   cdaboo at apple.com
Date:     2015-08-21 12:43:09 -0700 (Fri, 21 Aug 2015)
Log Message:
-----------
Add a new test mode to detect one resource in a collection that has contents matching a specific string.

Modified Paths:
--------------
    CalDAVTester/trunk/README.txt
    CalDAVTester/trunk/src/caldavtest.py

Modified: CalDAVTester/trunk/README.txt
===================================================================
--- CalDAVTester/trunk/README.txt	2015-08-20 18:43:39 UTC (rev 15064)
+++ CalDAVTester/trunk/README.txt	2015-08-21 19:43:09 UTC (rev 15065)
@@ -302,13 +302,14 @@
 				2) DELAY - pause for the number of seconds specified by the <ruri> element.
 				3) GETNEW - get the data from the newest resource in the collection specified by the <ruri> element and put its URI
 						    into the $ variable for later use in an <ruri> element.
-				4) WAITCOUNT - wait until at least a certain number of resources appear in a collection.
+				4) WAITCOUNT N - wait until at least a certain number of resources "N" appear in a collection.
 				5) WAITDELETEALL - wait until at least a certain number of resources appear in a collection, then delete all child
 								   resources in that collection.
 				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.  
+				6) GETCONTAINS XXX - the tool finds the child resource whose content contains the supplied text "XXX".  
 	
 		ELEMENT <ruri>
 			the URI of the request. Multiple <ruri>'s are allowed with DELETEALL only.

Modified: CalDAVTester/trunk/src/caldavtest.py
===================================================================
--- CalDAVTester/trunk/src/caldavtest.py	2015-08-20 18:43:39 UTC (rev 15064)
+++ CalDAVTester/trunk/src/caldavtest.py	2015-08-21 19:43:09 UTC (rev 15065)
@@ -435,6 +435,56 @@
         return hresult
 
 
+    def dofindcontains(self, original_request, collection, match, label=""):
+        hresult = ""
+
+        uri = collection[0]
+        req = request(self.manager)
+        req.method = "PROPFIND"
+        req.host = original_request.host
+        req.port = original_request.port
+        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(self.manager)
+        req.data.value = """<?xml version="1.0" encoding="utf-8" ?>
+<D:propfind xmlns:D="DAV:">
+<D:prop>
+<D:getetag/>
+</D:prop>
+</D:propfind>
+"""
+        req.data.content_type = "text/xml"
+        result, _ignore_resulttxt, response, respdata = self.dorequest(req, False, False, label="%s | %s" % (label, "FINDNEW"))
+        if result and (response is not None) and (response.status == 207) and (respdata is not None):
+            try:
+                tree = ElementTree(file=StringIO(respdata))
+            except Exception:
+                return hresult
+
+            request_uri = req.getURI(self.manager.server_info)
+            for response in tree.findall("{DAV:}response"):
+
+                # Get href for this response
+                href = response.findall("{DAV:}href")
+                if len(href) != 1:
+                    return False, "           Wrong number of DAV:href elements\n"
+                href = href[0].text
+                if href != request_uri:
+
+                    _ignore_result, respdata = self.doget(req, (href, collection[1], collection[2],), label)
+                    if respdata.find(match) != -1:
+                        break
+            else:
+                href = None
+
+        return href
+
+
     def dowaitcount(self, original_request, collection, count, label=""):
 
         hrefs = []
@@ -605,6 +655,18 @@
             req.method = "GET"
             req.ruri = "$"
 
+        # Special for GETCONTAINS
+        elif req.method.startswith("GETCONTAINS"):
+            match = req.method[12:]
+            collection = (req.ruri, req.user, req.pswd)
+            self.grabbedlocation = self.dofindcontains(req, collection, match, label=label)
+            if not self.grabbedlocation:
+                return False, "No matching resource", None, None
+            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:])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150821/64a095c9/attachment.html>


More information about the calendarserver-changes mailing list