<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[15065] CalDAVTester/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/15065">15065</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2015-08-21 12:43:09 -0700 (Fri, 21 Aug 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add a new test mode to detect one resource in a collection that has contents matching a specific string.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalDAVTestertrunkREADMEtxt">CalDAVTester/trunk/README.txt</a></li>
<li><a href="#CalDAVTestertrunksrccaldavtestpy">CalDAVTester/trunk/src/caldavtest.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalDAVTestertrunkREADMEtxt"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/README.txt (15064 => 15065)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -302,13 +302,14 @@
</span><span class="cx">                                 2) DELAY - pause for the number of seconds specified by the &lt;ruri&gt; element.
</span><span class="cx">                                 3) GETNEW - get the data from the newest resource in the collection specified by the &lt;ruri&gt; element and put its URI
</span><span class="cx">                                                     into the $ variable for later use in an &lt;ruri&gt; element.
</span><del>-                                4) WAITCOUNT - wait until at least a certain number of resources appear in a collection.
</del><ins>+                                4) WAITCOUNT N - wait until at least a certain number of resources &quot;N&quot; appear in a collection.
</ins><span class="cx">                                 5) WAITDELETEALL - wait until at least a certain number of resources appear in a collection, then delete all child
</span><span class="cx">                                                                    resources in that collection.
</span><span class="cx">                                 6) GETCHANGED - the tool tracks the Etags on resources retrieved via GET. This special method will poll the specified
</span><span class="cx">                                                                 resource until the Etag returned in the response is different from the one found in the most recent
</span><span class="cx">                                                                 test.  
</span><span class="cx">                                 6) GETOTHER - the tool finds the newest sibling resource to the one specified in the &lt;ruri&gt; element.  
</span><ins>+                                6) GETCONTAINS XXX - the tool finds the child resource whose content contains the supplied text &quot;XXX&quot;.  
</ins><span class="cx">         
</span><span class="cx">                 ELEMENT &lt;ruri&gt;
</span><span class="cx">                         the URI of the request. Multiple &lt;ruri&gt;'s are allowed with DELETEALL only.
</span></span></pre></div>
<a id="CalDAVTestertrunksrccaldavtestpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/caldavtest.py (15064 => 15065)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -435,6 +435,56 @@
</span><span class="cx">         return hresult
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def dofindcontains(self, original_request, collection, match, label=&quot;&quot;):
+        hresult = &quot;&quot;
+
+        uri = collection[0]
+        req = request(self.manager)
+        req.method = &quot;PROPFIND&quot;
+        req.host = original_request.host
+        req.port = original_request.port
+        req.ruris.append(uri)
+        req.ruri = uri
+        req.headers[&quot;Depth&quot;] = &quot;1&quot;
+        if len(collection[1]):
+            req.user = collection[1]
+        if len(collection[2]):
+            req.pswd = collection[2]
+        req.data = data(self.manager)
+        req.data.value = &quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
+&lt;D:propfind xmlns:D=&quot;DAV:&quot;&gt;
+&lt;D:prop&gt;
+&lt;D:getetag/&gt;
+&lt;/D:prop&gt;
+&lt;/D:propfind&gt;
+&quot;&quot;&quot;
+        req.data.content_type = &quot;text/xml&quot;
+        result, _ignore_resulttxt, response, respdata = self.dorequest(req, False, False, label=&quot;%s | %s&quot; % (label, &quot;FINDNEW&quot;))
+        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(&quot;{DAV:}response&quot;):
+
+                # Get href for this response
+                href = response.findall(&quot;{DAV:}href&quot;)
+                if len(href) != 1:
+                    return False, &quot;           Wrong number of DAV:href elements\n&quot;
+                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
+
+
</ins><span class="cx">     def dowaitcount(self, original_request, collection, count, label=&quot;&quot;):
</span><span class="cx"> 
</span><span class="cx">         hrefs = []
</span><span class="lines">@@ -605,6 +655,18 @@
</span><span class="cx">             req.method = &quot;GET&quot;
</span><span class="cx">             req.ruri = &quot;$&quot;
</span><span class="cx"> 
</span><ins>+        # Special for GETCONTAINS
+        elif req.method.startswith(&quot;GETCONTAINS&quot;):
+            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, &quot;No matching resource&quot;, None, None
+            if req.graburi:
+                self.manager.server_info.addextrasubs({req.graburi: self.grabbedlocation})
+            req.method = &quot;GET&quot;
+            req.ruri = &quot;$&quot;
+
</ins><span class="cx">         # Special check for WAITCOUNT
</span><span class="cx">         elif req.method.startswith(&quot;WAITCOUNT&quot;):
</span><span class="cx">             count = int(req.method[10:])
</span></span></pre>
</div>
</div>

</body>
</html>