W3C home > Mailing lists > Public > w3c-dist-auth@w3.org > October to December 2005

Test cases for "If" header checks

From: Julian Reschke <julian.reschke@gmx.de>
Date: Sat, 22 Oct 2005 21:45:17 +0200
Message-ID: <435A96CD.4010005@gmx.de>
To: w3c-dist-auth@w3.org

Hi.

Below is a test script (for Microsoft's XMLHTTPRequest component) that 
tests various forms of "If" headers.

Basically it does some sanity checks first, and then tries the new 
syntax allowing comma-separated lists (or multiple headers).

Of the servers I tested, none supported the new format (not 
surprisingly), but most (*) replied with 400 (bad request). This means 
clients can test that, and there doesn't seem to be any need for a new 
compliance class just for this use case.

Best regards, Julian

(* I notified the maintainers of the other two servers, one of which 
happens to be myself)

--

var req = new ActiveXObject ("MSXML2.ServerXMLHTTP");

if (WScript.Arguments.length == 0) {
   WScript.Echo("Test case If header eval");
   WScript.Echo("Usage: cscript if_fail.js URI {username} {password}");
   WScript.Quit(2);
}

var uri = WScript.Arguments(0);
var user = null;
var pwd = null;

function dumpResponse(r) {
   WScript.Echo(r.status);
   WScript.Echo(r.getAllResponseHeaders());
   WScript.Echo(r.responseText);
}


if (WScript.Arguments.length > 1) {
   user = WScript.Arguments(1);
}

if (WScript.Arguments.length > 2) {
   pwd = WScript.Arguments(2);
}

var x = 1;

function testPut(ifheader, desc) {

   WScript.Echo("\n\n\nTest case " + x + ", If header: " + ifheader);
   WScript.Echo("(" + desc + ")");
   req.open("PUT", uri, false, user, pwd);
   if (ifheader != null) req.setRequestHeader("If", ifheader);
   req.send("test case " + x);
   dumpResponse(req);
   x += 1;
}


// delete content
WScript.Echo("DELETE " + uri);
req.open("DELETE", uri, false, user, pwd);
req.send("foobar");
dumpResponse(req);

testPut(null, "initial content");
if (req.status < 200 || req.status >= 300) {
   WScript.Echo("unexpected status upon PUT");
   WScript.Quit(2);
}

testPut("(<DAV:no-lock>)", "const false");
if (req.status != 412) {
   WScript.Echo("unexpected status upon PUT");
}

testPut("(Not <DAV:no-lock>)", "const true");
if (req.status != 204 && req.status != 200) {
   WScript.Echo("unexpected status upon PUT");
}

testPut("(<DAV:no-lock> Not <DAV:no-lock>)", "const false");
if (req.status != 412) {
   WScript.Echo("unexpected status upon PUT");
}

testPut("(<DAV:no-lock>), (Not <DAV:no-lock>)", "const true using comma 
notation");
if (req.status == 200 || req.status == 204) {
   WScript.Echo("Server seems to understand ',' in If-List as per 
RFC2518bis");
}
else if (req.status == 400) {
   WScript.Echo("Server seems not to understand ',' in If-List as per 
RFC2518bis, rejecting the request with 400");
}
else {
   WScript.Echo("unexpected status upon PUT");
}

testPut("(Not <DAV:no-lock>), (Not <DAV:no-lock>)", "const false using 
comma notation");
if (req.status == 412) {
   WScript.Echo("Server seems to understand ',' in If-List as per 
RFC2518bis");
}
else if (req.status == 400) {
   WScript.Echo("Server seems not to understand ',' in If-List as per 
RFC2518bis, rejecting the request with 400");
}
else {
   WScript.Echo("unexpected status upon PUT");
}
Received on Saturday, 22 October 2005 19:45:47 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 2 June 2009 18:44:10 GMT