<!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>[13993] 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/13993">13993</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-09-22 12:46:49 -0700 (Mon, 22 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add GETROTHER method to make it easier to find new siblings of an existing resource. Allow request data files to be &quot;parameterized&quot; on a per-request basis.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalDAVTestertrunkREADMEtxt">CalDAVTester/trunk/README.txt</a></li>
<li><a href="#CalDAVTestertrunkscriptstestsCalDAVcaldavtestdtd">CalDAVTester/trunk/scripts/tests/CalDAV/caldavtest.dtd</a></li>
<li><a href="#CalDAVTestertrunkscriptstestsCardDAVcaldavtestdtd">CalDAVTester/trunk/scripts/tests/CardDAV/caldavtest.dtd</a></li>
<li><a href="#CalDAVTestertrunkscriptstestspodCalDAVcaldavtestdtd">CalDAVTester/trunk/scripts/tests-pod/CalDAV/caldavtest.dtd</a></li>
<li><a href="#CalDAVTestertrunksrccaldavtestpy">CalDAVTester/trunk/src/caldavtest.py</a></li>
<li><a href="#CalDAVTestertrunksrcrequestpy">CalDAVTester/trunk/src/request.py</a></li>
<li><a href="#CalDAVTestertrunksrcxmlDefspy">CalDAVTester/trunk/src/xmlDefs.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalDAVTestertrunkREADMEtxt"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/README.txt (13992 => 13993)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -304,6 +304,7 @@
</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><ins>+                                6) GETOTHER - the tool finds the newest sibling resource to the one specified in the &lt;ruri&gt; element.  
</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 class="lines">@@ -337,6 +338,15 @@
</span><span class="cx">                         ELEMENT &lt;filepath&gt;
</span><span class="cx">                                 the relative path for the file containing the request body
</span><span class="cx">                                 data.
</span><ins>+        
+                        ELEMENT &lt;substitute&gt;
+                                a set of substitution variables to use on this data only.
+                        
+                                ELEMENT &lt;name&gt;
+                                        the variable name.
+                
+                                ELEMENT &lt;value&gt;
+                                        the variable value.
</ins><span class="cx"> 
</span><span class="cx">                 ELEMENT &lt;verify&gt;
</span><span class="cx">                         if present, used to specify a procedures for verifying that the
</span></span></pre></div>
<a id="CalDAVTestertrunkscriptstestsCalDAVcaldavtestdtd"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/scripts/tests/CalDAV/caldavtest.dtd (13992 => 13993)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -45,11 +45,12 @@
</span><span class="cx">                 &lt;!ELEMENT header (name, value)&gt;
</span><span class="cx">                         &lt;!ELEMENT name (#PCDATA)&gt;
</span><span class="cx">                         &lt;!ELEMENT value (#PCDATA)&gt;
</span><del>-                &lt;!ELEMENT data (content-type, filepath)&gt;
</del><ins>+                &lt;!ELEMENT data (content-type, filepath, substitute*)&gt;
</ins><span class="cx">                         &lt;!ATTLIST data substitutions (yes|no) &quot;yes&quot;
</span><span class="cx">                                        generate      (yes|no) &quot;no&quot;&gt;
</span><span class="cx">                         &lt;!ELEMENT content-type (#PCDATA)&gt;
</span><span class="cx">                         &lt;!ELEMENT filepath (#PCDATA)&gt;
</span><ins>+                        &lt;!ELEMENT substitute (name, value)&gt;
</ins><span class="cx"> 
</span><span class="cx">                 &lt;!ELEMENT verify (require-feature?, exclude-feature?, callback, arg*)&gt;
</span><span class="cx">                         
</span></span></pre></div>
<a id="CalDAVTestertrunkscriptstestsCardDAVcaldavtestdtd"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/scripts/tests/CardDAV/caldavtest.dtd (13992 => 13993)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -45,11 +45,12 @@
</span><span class="cx">                 &lt;!ELEMENT header (name, value)&gt;
</span><span class="cx">                         &lt;!ELEMENT name (#PCDATA)&gt;
</span><span class="cx">                         &lt;!ELEMENT value (#PCDATA)&gt;
</span><del>-                &lt;!ELEMENT data (content-type, filepath)&gt;
</del><ins>+                &lt;!ELEMENT data (content-type, filepath, substitute*)&gt;
</ins><span class="cx">                         &lt;!ATTLIST data substitutions (yes|no) &quot;yes&quot;
</span><span class="cx">                                        generate      (yes|no) &quot;no&quot;&gt;
</span><span class="cx">                         &lt;!ELEMENT content-type (#PCDATA)&gt;
</span><span class="cx">                         &lt;!ELEMENT filepath (#PCDATA)&gt;
</span><ins>+                        &lt;!ELEMENT substitute (name, value)&gt;
</ins><span class="cx"> 
</span><span class="cx">                 &lt;!ELEMENT verify (require-feature?, exclude-feature?, callback, arg*)&gt;
</span><span class="cx">                         
</span></span></pre></div>
<a id="CalDAVTestertrunkscriptstestspodCalDAVcaldavtestdtd"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/scripts/tests-pod/CalDAV/caldavtest.dtd (13992 => 13993)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -45,11 +45,12 @@
</span><span class="cx">                 &lt;!ELEMENT header (name, value)&gt;
</span><span class="cx">                         &lt;!ELEMENT name (#PCDATA)&gt;
</span><span class="cx">                         &lt;!ELEMENT value (#PCDATA)&gt;
</span><del>-                &lt;!ELEMENT data (content-type, filepath)&gt;
</del><ins>+                &lt;!ELEMENT data (content-type, filepath, substitute*)&gt;
</ins><span class="cx">                         &lt;!ATTLIST data substitutions (yes|no) &quot;yes&quot;
</span><span class="cx">                                        generate      (yes|no) &quot;no&quot;&gt;
</span><span class="cx">                         &lt;!ELEMENT content-type (#PCDATA)&gt;
</span><span class="cx">                         &lt;!ELEMENT filepath (#PCDATA)&gt;
</span><ins>+                        &lt;!ELEMENT substitute (name, value)&gt;
</ins><span class="cx"> 
</span><span class="cx">                 &lt;!ELEMENT verify (require-feature?, exclude-feature?, callback, arg*)&gt;
</span><span class="cx">                         
</span><span class="lines">@@ -74,7 +75,8 @@
</span><span class="cx">         &lt;!ELEMENT test-suite (require-feature?, exclude-feature?, test*)&gt;
</span><span class="cx">                 &lt;!ATTLIST test-suite name CDATA #REQUIRED
</span><span class="cx">                                                         ignore (yes|no) &quot;no&quot;
</span><del>-                                                        only (yes|no) &quot;no&quot;&gt;
</del><ins>+                                                        only (yes|no) &quot;no&quot;
+                                                        change-uid (yes|no) &quot;no&quot;&gt;
</ins><span class="cx">         
</span><span class="cx">                 &lt;!ELEMENT test (require-feature?, exclude-feature?, description?, (request|pause)+)&gt;
</span><span class="cx">                         &lt;!ATTLIST test name CDATA #REQUIRED
</span></span></pre></div>
<a id="CalDAVTestertrunksrccaldavtestpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/caldavtest.py (13992 => 13993)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -255,7 +255,7 @@
</span><span class="cx">             req.user = collection[1]
</span><span class="cx">         if len(collection[2]):
</span><span class="cx">             req.pswd = collection[2]
</span><del>-        req.data = data()
</del><ins>+        req.data = data(self.manager)
</ins><span class="cx">         req.data.value = &quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
</span><span class="cx"> &lt;D:propfind xmlns:D=&quot;DAV:&quot;&gt;
</span><span class="cx"> &lt;D:prop&gt;
</span><span class="lines">@@ -303,19 +303,27 @@
</span><span class="cx">         return True
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def dofindnew(self, collection, label=&quot;&quot;):
</del><ins>+    def dofindnew(self, collection, label=&quot;&quot;, other=False):
</ins><span class="cx">         hresult = &quot;&quot;
</span><ins>+
+        uri = collection[0]
+        if other:
+            uri = self.manager.server_info.extrasubs(uri)
+            skip = uri
+            uri = &quot;/&quot;.join(uri.split(&quot;/&quot;)[:-1]) + &quot;/&quot;
+        else:
+            skip = None
</ins><span class="cx">         possible_matches = set()
</span><span class="cx">         req = request(self.manager)
</span><span class="cx">         req.method = &quot;PROPFIND&quot;
</span><del>-        req.ruris.append(collection[0])
-        req.ruri = collection[0]
</del><ins>+        req.ruris.append(uri)
+        req.ruri = uri
</ins><span class="cx">         req.headers[&quot;Depth&quot;] = &quot;1&quot;
</span><span class="cx">         if len(collection[1]):
</span><span class="cx">             req.user = collection[1]
</span><span class="cx">         if len(collection[2]):
</span><span class="cx">             req.pswd = collection[2]
</span><del>-        req.data = data()
</del><ins>+        req.data = data(self.manager)
</ins><span class="cx">         req.data.value = &quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
</span><span class="cx"> &lt;D:propfind xmlns:D=&quot;DAV:&quot;&gt;
</span><span class="cx"> &lt;D:prop&gt;
</span><span class="lines">@@ -341,7 +349,7 @@
</span><span class="cx">                 if len(href) != 1:
</span><span class="cx">                     return False, &quot;           Wrong number of DAV:href elements\n&quot;
</span><span class="cx">                 href = href[0].text
</span><del>-                if href != request_uri:
</del><ins>+                if href != request_uri and (not other or href != skip):
</ins><span class="cx"> 
</span><span class="cx">                     # Get all property status
</span><span class="cx">                     propstatus = response.findall(&quot;{DAV:}propstat&quot;)
</span><span class="lines">@@ -400,7 +408,7 @@
</span><span class="cx">                 req.user = collection[1]
</span><span class="cx">             if len(collection[2]):
</span><span class="cx">                 req.pswd = collection[2]
</span><del>-            req.data = data()
</del><ins>+            req.data = data(self.manager)
</ins><span class="cx">             req.data.value = &quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
</span><span class="cx"> &lt;D:propfind xmlns:D=&quot;DAV:&quot;&gt;
</span><span class="cx"> &lt;D:prop&gt;
</span><span class="lines">@@ -525,6 +533,15 @@
</span><span class="cx">                 self.manager.server_info.addextrasubs({req.graburi: self.grabbedlocation})
</span><span class="cx">             return True, &quot;&quot;, None, None
</span><span class="cx"> 
</span><ins>+        # Special for GETOTHER
+        elif req.method == &quot;GETOTHER&quot;:
+            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 = &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>
<a id="CalDAVTestertrunksrcrequestpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/request.py (13992 => 13993)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -306,6 +306,8 @@
</span><span class="cx">             data = str(self.manager.server_info.subs(data))
</span><span class="cx">             self.manager.server_info.addextrasubs({&quot;$request_count:&quot;: str(self.count)})
</span><span class="cx">             data = self.manager.server_info.extrasubs(data)
</span><ins>+            if self.data.substitutions:
+                data = self.manager.server_info.subs(data, self.data.substitutions)
</ins><span class="cx">             if self.data.generate:
</span><span class="cx">                 if self.data.content_type.startswith(&quot;text/calendar&quot;):
</span><span class="cx">                     data = self.generateCalendarData(data)
</span><span class="lines">@@ -377,7 +379,7 @@
</span><span class="cx">                 if len(self.ruris) == 1:
</span><span class="cx">                     self.ruri = self.ruris[0]
</span><span class="cx">             elif child.tag == src.xmlDefs.ELEMENT_DATA:
</span><del>-                self.data = data()
</del><ins>+                self.data = data(self.manager)
</ins><span class="cx">                 self.data.parseXML(child)
</span><span class="cx">             elif child.tag == src.xmlDefs.ELEMENT_VERIFY:
</span><span class="cx">                 self.verifiers.append(verify(self.manager))
</span><span class="lines">@@ -470,10 +472,12 @@
</span><span class="cx">     Represents the data/body portion of an HTTP request.
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-    def __init__(self):
</del><ins>+    def __init__(self, manager):
+        self.manager = manager
</ins><span class="cx">         self.content_type = &quot;&quot;
</span><span class="cx">         self.filepath = &quot;&quot;
</span><span class="cx">         self.value = &quot;&quot;
</span><ins>+        self.substitutions = {}
</ins><span class="cx">         self.substitute = False
</span><span class="cx">         self.generate = False
</span><span class="cx"> 
</span><span class="lines">@@ -488,9 +492,23 @@
</span><span class="cx">                 self.content_type = child.text.encode(&quot;utf-8&quot;)
</span><span class="cx">             elif child.tag == src.xmlDefs.ELEMENT_FILEPATH:
</span><span class="cx">                 self.filepath = child.text.encode(&quot;utf-8&quot;)
</span><ins>+            elif child.tag == src.xmlDefs.ELEMENT_SUBSTITUTE:
+                self.parseSubstituteXML(child)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def parseSubstituteXML(self, node):
+        name = None
+        value = None
+        for child in node.getchildren():
+            if child.tag == src.xmlDefs.ELEMENT_NAME:
+                name = child.text.encode(&quot;utf-8&quot;)
+            elif child.tag == src.xmlDefs.ELEMENT_VALUE:
+                value = self.manager.server_info.subs(child.text.encode(&quot;utf-8&quot;))
+        if name and value:
+            self.substitutions[name] = value
</ins><span class="cx"> 
</span><ins>+
+
</ins><span class="cx"> class verify(object):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Defines how the result of a request should be verified. This is done
</span></span></pre></div>
<a id="CalDAVTestertrunksrcxmlDefspy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/xmlDefs.py (13992 => 13993)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -64,6 +64,7 @@
</span><span class="cx"> ELEMENT_SSLPORT2 = &quot;sslport2&quot;
</span><span class="cx"> ELEMENT_START = &quot;start&quot;
</span><span class="cx"> ELEMENT_SUBJECT = &quot;subject&quot;
</span><ins>+ELEMENT_SUBSTITUTE = &quot;substitute&quot;
</ins><span class="cx"> ELEMENT_SUBSTITUTIONS = &quot;substitutions&quot;
</span><span class="cx"> ELEMENT_SUBSTITUTION = &quot;substitution&quot;
</span><span class="cx"> ELEMENT_TEST = &quot;test&quot;
</span></span></pre>
</div>
</div>

</body>
</html>