<!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>[3314] 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.macosforge.org/projects/calendarserver/changeset/3314">3314</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2008-11-03 19:11:42 -0800 (Mon, 03 Nov 2008)</dd>
</dl>

<h3>Log Message</h3>
<pre>Tweaked header tests to allow grabbing header values for later tests.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalDAVTestertrunkscriptstestscaldavtestdtd">CalDAVTester/trunk/scripts/tests/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>
<li><a href="#CalDAVTestertrunkverifiersheaderpy">CalDAVTester/trunk/verifiers/header.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalDAVTestertrunkscriptstestscaldavtestdtd"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/scripts/tests/caldavtest.dtd (3313 => 3314)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/scripts/tests/caldavtest.dtd        2008-11-04 03:10:03 UTC (rev 3313)
+++ CalDAVTester/trunk/scripts/tests/caldavtest.dtd        2008-11-04 03:11:42 UTC (rev 3314)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">         &lt;!ELEMENT start (request*)&gt;
</span><span class="cx">         &lt;!ELEMENT end (request*)&gt;
</span><span class="cx"> 
</span><del>-        &lt;!ELEMENT request (method, header*, ruri?, data?, verify*, grablocation?, grabproperty?)&gt;
</del><ins>+        &lt;!ELEMENT request (method, header*, ruri*, data?, verify*, grabheader?, grabproperty?)&gt;
</ins><span class="cx">                 &lt;!ATTLIST request auth (yes|no) &quot;yes&quot;
</span><span class="cx">                                                  user CDATA &quot;&quot;
</span><span class="cx">                                                  pswd CDATA &quot;&quot;
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx">                                 &lt;!ELEMENT callback (#PCDATA)&gt;
</span><span class="cx">                                 &lt;!ELEMENT arg (name, value+)&gt;
</span><span class="cx">                 
</span><del>-                &lt;!ELEMENT grablocation EMPTY&gt;
</del><ins>+                &lt;!ELEMENT grabheader (name, variable)&gt;
</ins><span class="cx">         
</span><span class="cx">                 &lt;!ELEMENT grabproperty (property, variable)&gt;
</span><span class="cx">                         &lt;!ELEMENT property (#PCDATA)&gt;
</span></span></pre></div>
<a id="CalDAVTestertrunksrccaldavtestpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/caldavtest.py (3313 => 3314)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/caldavtest.py        2008-11-04 03:10:03 UTC (rev 3313)
+++ CalDAVTester/trunk/src/caldavtest.py        2008-11-04 03:11:42 UTC (rev 3314)
</span><span class="lines">@@ -165,6 +165,7 @@
</span><span class="cx">         hrefs = []
</span><span class="cx">         req = request(self.manager)
</span><span class="cx">         req.method = &quot;PROPFIND&quot;
</span><ins>+        req.ruris.append(collection[0])
</ins><span class="cx">         req.ruri = collection[0]
</span><span class="cx">         req.headers[&quot;Depth&quot;] = &quot;1&quot;
</span><span class="cx">         if len(collection[1]):
</span><span class="lines">@@ -211,6 +212,7 @@
</span><span class="cx">         for deleter in deletes:
</span><span class="cx">             req = request(self.manager)
</span><span class="cx">             req.method = &quot;DELETE&quot;
</span><ins>+            req.ruris.append(deleter[0])
</ins><span class="cx">             req.ruri = deleter[0]
</span><span class="cx">             if len(deleter[1]):
</span><span class="cx">                 req.user = deleter[1]
</span><span class="lines">@@ -222,6 +224,7 @@
</span><span class="cx">         hresult = &quot;&quot;
</span><span class="cx">         req = request(self.manager)
</span><span class="cx">         req.method = &quot;PROPFIND&quot;
</span><ins>+        req.ruris.append(collection[0])
</ins><span class="cx">         req.ruri = collection[0]
</span><span class="cx">         req.headers[&quot;Depth&quot;] = &quot;1&quot;
</span><span class="cx">         if len(collection[1]):
</span><span class="lines">@@ -301,6 +304,7 @@
</span><span class="cx">         for deleter in self.end_deletes:
</span><span class="cx">             req = request(self.manager)
</span><span class="cx">             req.method = &quot;DELETE&quot;
</span><ins>+            req.ruris.append(deleter[0])
</ins><span class="cx">             req.ruri = deleter[0]
</span><span class="cx">             if len(deleter[1]):
</span><span class="cx">                 req.user = deleter[1]
</span><span class="lines">@@ -369,13 +373,14 @@
</span><span class="cx">         
</span><span class="cx">         # Special check for DELETEALL
</span><span class="cx">         if req.method == &quot;DELETEALL&quot;:
</span><del>-            collection = (req.ruri, req.user, req.pswd)
-            hrefs = self.dofindall(collection)
-            self.dodeleteall(hrefs)
</del><ins>+            for ruri in req.ruris:
+                collection = (ruri, req.user, req.pswd)
+                hrefs = self.dofindall(collection)
+                self.dodeleteall(hrefs)
</ins><span class="cx">             return True, &quot;&quot;, None, None
</span><span class="cx">         
</span><span class="cx">         # Special check for ACCESS-DISABLE
</span><del>-        if req.method == &quot;ACCESS-DISABLE&quot;:
</del><ins>+        elif req.method == &quot;ACCESS-DISABLE&quot;:
</ins><span class="cx">             if self.doaccess(req.ruri, False):
</span><span class="cx">                 return True, &quot;&quot;, None, None
</span><span class="cx">             else:
</span><span class="lines">@@ -387,7 +392,7 @@
</span><span class="cx">                 return False, &quot;Could not remove caldav-access-disabled xattr on file&quot;, None, None
</span><span class="cx"> 
</span><span class="cx">         # Special check for QUOTA
</span><del>-        if req.method == &quot;QUOTA-DISABLE&quot;:
</del><ins>+        elif req.method == &quot;QUOTA-DISABLE&quot;:
</ins><span class="cx">             if self.doquota(req.ruri, None):
</span><span class="cx">                 return True, &quot;&quot;, None, None
</span><span class="cx">             else:
</span><span class="lines">@@ -399,7 +404,7 @@
</span><span class="cx">                 return False, &quot;Could not set quota-root xattr on file&quot;, None, None
</span><span class="cx"> 
</span><span class="cx">         # Special for delay
</span><del>-        if req.method == &quot;DELAY&quot;:
</del><ins>+        elif req.method == &quot;DELAY&quot;:
</ins><span class="cx">             # self.ruri contains a numeric delay in seconds
</span><span class="cx">             delay = int(req.ruri)
</span><span class="cx">             starttime = time.time()
</span><span class="lines">@@ -407,14 +412,8 @@
</span><span class="cx">                 pass
</span><span class="cx">             return True, &quot;&quot;, None, None
</span><span class="cx"> 
</span><del>-        # Special for LISTNEW
-        if req.method == &quot;LISTNEW&quot;:
-            collection = (req.ruri, req.user, req.pswd)
-            self.grabbedlocation = self.dofindnew(collection)
-            return True, &quot;&quot;, None, None
-            
</del><span class="cx">         # Special for GETNEW
</span><del>-        if req.method == &quot;GETNEW&quot;:
</del><ins>+        elif req.method == &quot;GETNEW&quot;:
</ins><span class="cx">             collection = (req.ruri, req.user, req.pswd)
</span><span class="cx">             self.grabbedlocation = self.dofindnew(collection)
</span><span class="cx">             req.method = &quot;GET&quot;
</span><span class="lines">@@ -480,10 +479,10 @@
</span><span class="cx">             resulttxt += str(response.msg) + &quot;\n&quot; + respdata
</span><span class="cx">             resulttxt += &quot;\n--------END:RESPONSE--------\n&quot;
</span><span class="cx">         
</span><del>-        if req.grablocation:
-            hdrs = response.msg.getheaders(&quot;Location&quot;)
</del><ins>+        if req.grabheader:
+            hdrs = response.msg.getheaders(req.grabheader[0])
</ins><span class="cx">             if hdrs:
</span><del>-                self.grabbedlocation = hdrs[0]
</del><ins>+                self.manager.server_info.addextrasubs({req.grabheader[1]: hdrs[0].encode(&quot;utf-8&quot;)})
</ins><span class="cx"> 
</span><span class="cx">         if req.grabproperty:
</span><span class="cx">             if response.status == 207:
</span></span></pre></div>
<a id="CalDAVTestertrunksrcrequestpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/request.py (3313 => 3314)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/request.py        2008-11-04 03:10:03 UTC (rev 3313)
+++ CalDAVTester/trunk/src/request.py        2008-11-04 03:11:42 UTC (rev 3314)
</span><span class="lines">@@ -127,8 +127,8 @@
</span><span class="cx">     be used to determine a satisfactory output or not.
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     __slots__  = ['manager', 'auth', 'user', 'pswd', 'end_delete', 'print_response',
</span><del>-                  'method', 'headers', 'ruri', 'data', 'datasubs', 'verifiers',
-                  'grablocation', 'grabproperty']
</del><ins>+                  'method', 'headers', 'ruris', 'ruri', 'data', 'datasubs', 'verifiers',
+                  'grabheader', 'grabproperty']
</ins><span class="cx">     
</span><span class="cx">     def __init__( self, manager ):
</span><span class="cx">         self.manager = manager
</span><span class="lines">@@ -139,15 +139,16 @@
</span><span class="cx">         self.print_response = False
</span><span class="cx">         self.method = &quot;&quot;
</span><span class="cx">         self.headers = {}
</span><ins>+        self.ruris = []
</ins><span class="cx">         self.ruri = &quot;&quot;
</span><span class="cx">         self.data = None
</span><span class="cx">         self.datasubs = True
</span><span class="cx">         self.verifiers = []
</span><del>-        self.grablocation = False
</del><ins>+        self.grabheader = None
</ins><span class="cx">         self.grabproperty = None
</span><span class="cx">     
</span><span class="cx">     def __str__(self):
</span><del>-        return &quot;Method: %s; uri: %s&quot; % (self.method, self.ruri)
</del><ins>+        return &quot;Method: %s; uris: %s&quot; % (self.method, self.ruris if len(self.ruris) &gt; 1 else self.ruri,)
</ins><span class="cx"> 
</span><span class="cx">     def getURI( self, si ):
</span><span class="cx">         if self.ruri == &quot;$&quot;:
</span><span class="lines">@@ -161,6 +162,8 @@
</span><span class="cx">         
</span><span class="cx">     def getHeaders( self, si ):
</span><span class="cx">         hdrs = self.headers
</span><ins>+        for key, value in hdrs.items():
+            hdrs[key] = si.extrasubs(value)
</ins><span class="cx">         
</span><span class="cx">         # Content type
</span><span class="cx">         if self.data != None:
</span><span class="lines">@@ -279,15 +282,17 @@
</span><span class="cx">             elif child._get_localName() == src.xmlDefs.ELEMENT_HEADER:
</span><span class="cx">                 self.parseHeader(child)
</span><span class="cx">             elif child._get_localName() == src.xmlDefs.ELEMENT_RURI:
</span><del>-                self.ruri = self.manager.server_info.subs(child.firstChild.data.encode(&quot;utf-8&quot;))
</del><ins>+                self.ruris.append(self.manager.server_info.subs(child.firstChild.data.encode(&quot;utf-8&quot;)))
+                if len(self.ruris) == 1:
+                    self.ruri = self.ruris[0]
</ins><span class="cx">             elif child._get_localName() == src.xmlDefs.ELEMENT_DATA:
</span><span class="cx">                 self.data = data()
</span><span class="cx">                 self.datasubs = self.data.parseXML( child )
</span><span class="cx">             elif child._get_localName() == src.xmlDefs.ELEMENT_VERIFY:
</span><span class="cx">                 self.verifiers.append(verify(self.manager))
</span><span class="cx">                 self.verifiers[-1].parseXML( child )
</span><del>-            elif child._get_localName() == src.xmlDefs.ELEMENT_GRABLOCATION:
-                self.grablocation = True
</del><ins>+            elif child._get_localName() == src.xmlDefs.ELEMENT_GRABHEADER:
+                self.parseGrabHeader(child)
</ins><span class="cx">             elif child._get_localName() == src.xmlDefs.ELEMENT_GRABPROPERTY:
</span><span class="cx">                 self.parseGrabProperty(child)
</span><span class="cx"> 
</span><span class="lines">@@ -315,6 +320,19 @@
</span><span class="cx">                 
</span><span class="cx">     parseList = staticmethod( parseList )
</span><span class="cx"> 
</span><ins>+    def parseGrabHeader(self, node):
+        
+        header = None
+        variable = None
+        for child in node._get_childNodes():
+            if child._get_localName() == src.xmlDefs.ELEMENT_NAME:
+                header = child.firstChild.data.encode(&quot;utf-8&quot;)
+            elif child._get_localName() == src.xmlDefs.ELEMENT_VARIABLE:
+                variable = self.manager.server_info.subs(child.firstChild.data.encode(&quot;utf-8&quot;))
+        
+        if (header is not None) and (variable is not None):
+            self.grabheader = (header, variable)
+
</ins><span class="cx">     def parseGrabProperty(self, node):
</span><span class="cx">         
</span><span class="cx">         property = None
</span></span></pre></div>
<a id="CalDAVTestertrunksrcxmlDefspy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/src/xmlDefs.py (3313 => 3314)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/src/xmlDefs.py        2008-11-04 03:10:03 UTC (rev 3313)
+++ CalDAVTester/trunk/src/xmlDefs.py        2008-11-04 03:11:42 UTC (rev 3314)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> ELEMENT_DESCRIPTION = &quot;description&quot;
</span><span class="cx"> ELEMENT_END = &quot;end&quot;
</span><span class="cx"> ELEMENT_FILEPATH = &quot;filepath&quot;
</span><del>-ELEMENT_GRABLOCATION = &quot;grablocation&quot;
</del><ins>+ELEMENT_GRABHEADER = &quot;grabheader&quot;
</ins><span class="cx"> ELEMENT_GRABPROPERTY = &quot;grabproperty&quot;
</span><span class="cx"> ELEMENT_HEADER = &quot;header&quot;
</span><span class="cx"> ELEMENT_HOST = &quot;host&quot;
</span></span></pre></div>
<a id="CalDAVTestertrunkverifiersheaderpy"></a>
<div class="modfile"><h4>Modified: CalDAVTester/trunk/verifiers/header.py (3313 => 3314)</h4>
<pre class="diff"><span>
<span class="info">--- CalDAVTester/trunk/verifiers/header.py        2008-11-04 03:10:03 UTC (rev 3313)
+++ CalDAVTester/trunk/verifiers/header.py        2008-11-04 03:11:42 UTC (rev 3314)
</span><span class="lines">@@ -35,50 +35,52 @@
</span><span class="cx">                 p = p[1:]
</span><span class="cx">                 present = &quot;multiple&quot;
</span><span class="cx">             if p.find(&quot;$&quot;) != -1:
</span><del>-                testheader[i] = (p.split(&quot;$&quot;, 1)[0], p.split(&quot;$&quot;, 1)[1], present,)
</del><ins>+                testheader[i] = (p.split(&quot;$&quot;, 1)[0], p.split(&quot;$&quot;, 1)[1], present, True,)
+            elif p.find(&quot;!&quot;) != -1:
+                testheader[i] = (p.split(&quot;!&quot;, 1)[0], p.split(&quot;!&quot;, 1)[1], present, False,)
</ins><span class="cx">             else:
</span><del>-                testheader[i] = (p, None, present,)
</del><ins>+                testheader[i] = (p, None, present, True,)
</ins><span class="cx">         
</span><span class="cx">         result = True
</span><span class="cx">         resulttxt = &quot;&quot;
</span><del>-        for test in testheader:
-            hdrs = response.msg.getheaders(test[0])
</del><ins>+        for hdrname, hdrvalue, presence, matchvalue in testheader:
+            hdrs = response.msg.getheaders(hdrname)
</ins><span class="cx">             if (hdrs is None or (len(hdrs) == 0)):
</span><del>-                if test[2] != &quot;none&quot;:
</del><ins>+                if presence != &quot;none&quot;:
</ins><span class="cx">                     result = False
</span><span class="cx">                     if len(resulttxt):
</span><span class="cx">                         resulttxt += &quot;\n&quot;
</span><del>-                    resulttxt += &quot;        Missing Response Header: %s&quot; % (test[0],)
</del><ins>+                    resulttxt += &quot;        Missing Response Header: %s&quot; % (hdrname,)
</ins><span class="cx">                     continue
</span><span class="cx">                 else:
</span><span class="cx">                     continue
</span><span class="cx"> 
</span><del>-            if (hdrs is not None) and (len(hdrs) != 0) and (test[2] == &quot;none&quot;):
</del><ins>+            if (hdrs is not None) and (len(hdrs) != 0) and (presence == &quot;none&quot;):
</ins><span class="cx">                 result = False
</span><span class="cx">                 if len(resulttxt):
</span><span class="cx">                     resulttxt += &quot;\n&quot;
</span><del>-                resulttxt += &quot;        Response Header was present one or more times: %s&quot; % (test[0],)
</del><ins>+                resulttxt += &quot;        Response Header was present one or more times: %s&quot; % (hdrname,)
</ins><span class="cx">                 continue
</span><span class="cx">                
</span><del>-            if (len(hdrs) != 1) and (test[2] == &quot;single&quot;):
</del><ins>+            if (len(hdrs) != 1) and (presence == &quot;single&quot;):
</ins><span class="cx">                 result = False
</span><span class="cx">                 if len(resulttxt):
</span><span class="cx">                     resulttxt += &quot;\n&quot;
</span><del>-                resulttxt += &quot;        Multiple Response Headers: %s&quot; % (test[0],)
</del><ins>+                resulttxt += &quot;        Multiple Response Headers: %s&quot; % (hdrname,)
</ins><span class="cx">                 continue
</span><span class="cx">             
</span><del>-            if (test[1] is not None):
</del><ins>+            if (hdrvalue is not None):
</ins><span class="cx">                 matched = False
</span><span class="cx">                 for hdr in hdrs:
</span><del>-                    if (re.match(test[1], hdr) is not None):
</del><ins>+                    if (re.match(hdrvalue, hdr) is not None):
</ins><span class="cx">                         matched = True
</span><span class="cx">                         break
</span><span class="cx">                         
</span><del>-                if not matched:
</del><ins>+                if matchvalue and not matched or not matchvalue and matched:
</ins><span class="cx">                     result = False
</span><span class="cx">                     if len(resulttxt):
</span><span class="cx">                         resulttxt += &quot;\n&quot;
</span><del>-                    resulttxt += &quot;        Wrong Response Header Value: %s: %s&quot; % (test[0], str(hdrs))
</del><ins>+                    resulttxt += &quot;        Wrong Response Header Value: %s: %s&quot; % (hdrname, str(hdrs))
</ins><span class="cx"> 
</span><span class="cx">         return result, resulttxt
</span><span class="cx">             
</span></span></pre>
</div>
</div>

</body>
</html>