<!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>[15443] 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/15443">15443</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2016-01-23 10:33:22 -0800 (Sat, 23 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Tweaks to better support running tests for another type of server.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalDAVTestertrunkREADMEtxt">CalDAVTester/trunk/README.txt</a></li>
<li><a href="#CalDAVTestertrunksrcmanagerpy">CalDAVTester/trunk/src/manager.py</a></li>
<li><a href="#CalDAVTestertrunksrcserverinfopy">CalDAVTester/trunk/src/serverinfo.py</a></li>
<li><a href="#CalDAVTestertrunkverifiersdataStringpy">CalDAVTester/trunk/verifiers/dataString.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalDAVTestertrunkREADMEtxt"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/README.txt (15442 => 15443)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/README.txt        2016-01-22 21:22:35 UTC (rev 15442)
+++ CalDAVTester/trunk/README.txt        2016-01-23 18:33:22 UTC (rev 15443)
</span><span class="lines">@@ -398,11 +398,18 @@
</span><span class="cx">                                 ELEMENT &lt;value&gt;
</span><span class="cx">                                         values for the argument.
</span><span class="cx">         
</span><del>-                ELEMENT &lt;graburi&gt;
-                        if present, this stores the value of the actual request URI
-                        used in a named variable which can be used in subsequent requests.
-                        Useful for capturing URIs when the GETNEW method is used.
-                        
</del><ins>+        ELEMENT &lt;graburi&gt;
+            if present, this stores the value of the actual request URI
+            used in a named variable which can be used in subsequent requests.
+            Useful for capturing URIs when the GETNEW method is used.
+            
+        ELEMENT &lt;grabcount&gt;
+            if present, this stores the number of child responses in a
+            {DAV:}multistatus response into the named variable which
+            can be used in subsequent requests. This is useful for
+            capturing the current count so that a change in the count
+            can be tested for later.
+            
</ins><span class="cx">                 ELEMENT &lt;grabheader&gt;
</span><span class="cx">                         if present, this stores the value of the specified header
</span><span class="cx">                         returned in the response in a named variable which can be used
</span><span class="lines">@@ -413,11 +420,16 @@
</span><span class="cx">                         returned in a PROPFIND response in a named variable which can
</span><span class="cx">                         be used in subsequent requests.
</span><span class="cx">                         
</span><del>-                ELEMENT &lt;grabelement&gt;
-                        if present, this stores the text representation of an XML
-                        element extracted from the response body in a named variable
-                        which can be used in subsequent requests.
-                        
</del><ins>+        ELEMENT &lt;grabelement&gt;
+            if present, this stores the text representation of an XML
+            element extracted from the response body in a named variable
+            which can be used in subsequent requests.
+            
+        ELEMENT &lt;grabjson&gt;
+            if present, this stores the text representation of a JSON
+            object extracted from the response body in a named variable
+            which can be used in subsequent requests.
+            
</ins><span class="cx">                 ELEMENT &lt;grabcalproperty&gt;
</span><span class="cx">                         if present, this stores a calendar property value in a named
</span><span class="cx">                         variable which can be used in subsequent request. The syntax for
</span><span class="lines">@@ -498,9 +510,12 @@
</span><span class="cx">         Performs a check of response body tries to find occurrences of the specified strings or the
</span><span class="cx">         absence of specified strings.
</span><span class="cx"> 
</span><del>-        Argument: 'contains'
-                One or more strings that must be contained in the data (case-sensitive).
-        
</del><ins>+    Argument: 'equals'
+        One or more strings that must match exactly in the data (case-sensitive).
+    
+    Argument: 'contains'
+        One or more strings that must be contained in the data (case-sensitive).
+    
</ins><span class="cx">         Argument: 'notcontains'
</span><span class="cx">                 One or more strings that must not be contained in the data (case-sensitive).
</span><span class="cx">         
</span><span class="lines">@@ -598,7 +613,7 @@
</span><span class="cx">         string value can be checked by append &quot;~$&quot; and the string value to test
</span><span class="cx">         to the JSON pointer value. A single &quot;.&quot; can be used as a reference-token
</span><span class="cx">         in the JSON pointer to match against any member or array item at that
</span><del>-        poisition in the document.
</del><ins>+        position in the document.
</ins><span class="cx">         
</span><span class="cx">         Argument: 'exists'
</span><span class="cx">                 JSON pointer for a JSON item to check the presence of
</span><span class="lines">@@ -711,8 +726,8 @@
</span><span class="cx">         whether the returned properties (and optionally their values) are good (2xx) or bad
</span><span class="cx">         (non-2xx) response code. The overall response status must be 207.
</span><span class="cx"> 
</span><del>-        Argument: 'roor-element'
-                Exepected root element for the XML response. Normally this is DAV:multistatus
</del><ins>+        Argument: 'root-element'
+                Expected root element for the XML response. Normally this is DAV:multistatus
</ins><span class="cx">                 but, e.g., MKCOL ext uses a different root, but mostly looks like multistatus
</span><span class="cx">                 otherwise.
</span><span class="cx"> 
</span><span class="lines">@@ -819,7 +834,7 @@
</span><span class="cx">                 Any specified XML elements will have their content removed from the
</span><span class="cx">                 response XML data before the comparison with the file data is done.
</span><span class="cx">                 This can be used to ignore element values that change in each request,
</span><del>-                e.g., a timestamp.
</del><ins>+                e.g., a time stamp.
</ins><span class="cx">         
</span><span class="cx">         Example:
</span><span class="cx">         
</span></span></pre></div>
<a id="CalDAVTestertrunksrcmanagerpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/manager.py (15442 => 15443)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/manager.py        2016-01-22 21:22:35 UTC (rev 15442)
+++ CalDAVTester/trunk/src/manager.py        2016-01-23 18:33:22 UTC (rev 15443)
</span><span class="lines">@@ -47,6 +47,7 @@
</span><span class="cx"> 
</span><span class="cx">     def __init__(self, text=True):
</span><span class="cx">         self.server_info = serverinfo()
</span><ins>+        self.base_dir = &quot;&quot;
</ins><span class="cx">         self.data_dir = None
</span><span class="cx">         self.pretest = None
</span><span class="cx">         self.posttest = None
</span><span class="lines">@@ -199,6 +200,8 @@
</span><span class="cx">                 raise EX_INVALID_CONFIG_FILE
</span><span class="cx"> 
</span><span class="cx">             self.message(&quot;Reading Test Details from \&quot;{f}\&quot;&quot;.format(f=fname))
</span><ins>+            if self.base_dir:
+                fname = fname[len(self.base_dir) + 1:]
</ins><span class="cx">             test = caldavtest(self, fname)
</span><span class="cx">             test.parseXML(caldavtest_node)
</span><span class="cx">             return test
</span><span class="lines">@@ -226,7 +229,6 @@
</span><span class="cx">     def readCommandLine(self):
</span><span class="cx">         sname = &quot;scripts/server/serverinfo.xml&quot;
</span><span class="cx">         dname = &quot;scripts/tests&quot;
</span><del>-        basedir = None
</del><span class="cx">         fnames = []
</span><span class="cx">         ssl = False
</span><span class="cx">         all = False
</span><span class="lines">@@ -272,13 +274,13 @@
</span><span class="cx">             elif option == &quot;--all&quot;:
</span><span class="cx">                 all = True
</span><span class="cx">             elif option == &quot;--basedir&quot;:
</span><del>-                basedir = value
-                sname = os.path.join(basedir, &quot;serverinfo.xml&quot;)
-                dname = os.path.join(basedir, &quot;tests&quot;)
-                self.data_dir = os.path.join(basedir, &quot;data&quot;)
</del><ins>+                self.base_dir = value
+                sname = os.path.join(self.base_dir, &quot;serverinfo.xml&quot;)
+                dname = os.path.join(self.base_dir, &quot;tests&quot;)
+                self.data_dir = os.path.join(self.base_dir, &quot;data&quot;)
</ins><span class="cx"> 
</span><span class="cx">                 # Also add parent to PYTHON path
</span><del>-                sys.path.append(os.path.dirname(basedir))
</del><ins>+                sys.path.append(os.path.dirname(self.base_dir))
</ins><span class="cx"> 
</span><span class="cx">             elif option == &quot;--subdir&quot;:
</span><span class="cx">                 subdir = value + &quot;/&quot;
</span></span></pre></div>
<a id="CalDAVTestertrunksrcserverinfopy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/serverinfo.py (15442 => 15443)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/serverinfo.py        2016-01-22 21:22:35 UTC (rev 15442)
+++ CalDAVTester/trunk/src/serverinfo.py        2016-01-23 18:33:22 UTC (rev 15443)
</span><span class="lines">@@ -13,7 +13,6 @@
</span><span class="cx"> # See the License for the specific language governing permissions and
</span><span class="cx"> # limitations under the License.
</span><span class="cx"> ##
</span><del>-from uuid import uuid4
</del><span class="cx"> 
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> Class that encapsulates the server information for a CalDAV test run.
</span><span class="lines">@@ -22,6 +21,8 @@
</span><span class="cx"> import datetime
</span><span class="cx"> import re
</span><span class="cx"> import src.xmlDefs
</span><ins>+from uuid import uuid4
+from urlparse import urlparse
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> class serverinfo(object):
</span><span class="lines">@@ -147,6 +148,12 @@
</span><span class="cx">             if variable.startswith(&quot;basename(&quot;):
</span><span class="cx">                 variable = variable[len(&quot;basename(&quot;):-1]
</span><span class="cx">                 value = value.rstrip(&quot;/&quot;).split(&quot;/&quot;)[-1]
</span><ins>+
+            # urlpath() - extract just the URL path segment from the value
+            elif variable.startswith(&quot;urlpath(&quot;):
+                variable = variable[len(&quot;urlpath(&quot;):-1]
+                value = urlparse(value).path
+
</ins><span class="cx">             processed[variable] = value
</span><span class="cx"> 
</span><span class="cx">         self.addsubs(processed, self.extrasubsdict)
</span></span></pre></div>
<a id="CalDAVTestertrunkverifiersdataStringpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/verifiers/dataString.py (15442 => 15443)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/verifiers/dataString.py        2016-01-22 21:22:35 UTC (rev 15442)
+++ CalDAVTester/trunk/verifiers/dataString.py        2016-01-23 18:33:22 UTC (rev 15443)
</span><span class="lines">@@ -22,6 +22,7 @@
</span><span class="cx"> 
</span><span class="cx">     def verify(self, manager, uri, response, respdata, args): #@UnusedVariable
</span><span class="cx">         # Get arguments
</span><ins>+        equals = args.get(&quot;equals&quot;, [])
</ins><span class="cx">         contains = args.get(&quot;contains&quot;, [])
</span><span class="cx">         notcontains = args.get(&quot;notcontains&quot;, [])
</span><span class="cx">         unwrap = args.get(&quot;unwrap&quot;)
</span><span class="lines">@@ -44,6 +45,10 @@
</span><span class="cx">         else:
</span><span class="cx">             newrespdata = respdata
</span><span class="cx">         # Check each contains and not-contains (AND operation)
</span><ins>+        for item in equals:
+            item = manager.server_info.subs(item)
+            if newrespdata != item:
+                return False, &quot;        Response data does not equal \&quot;%s\&quot;&quot; % (item,)
</ins><span class="cx">         for item in contains:
</span><span class="cx">             item = manager.server_info.subs(item)
</span><span class="cx">             if newrespdata.find(item.replace(&quot;\n&quot;, &quot;\r\n&quot;)) == -1 and newrespdata.find(item) == -1:
</span></span></pre>
</div>
</div>

</body>
</html>