Commit 8ce3713d authored by Joshua Bussdieker's avatar Joshua Bussdieker

Add autogenerated tests and finish quoted string support.

parent f1b5d3f8
......@@ -219,6 +219,33 @@ int parameter_prefix_matcher(const char *p, const char *fv, int ps, int case_sen
return 0;
}
int unescape(char *dst, const char *src, int len) {
int i, j;
i = j = 0;
while (i < len) {
switch (src[i]) {
case '\\':
switch(src[++i]) {
case '\"':
dst[j++] = '\"';
i++;
break;
default:
dst[j++] = '\\';
dst[j] = src[i];
break;
}
break;
default:
dst[j] = src[i];
i++;
j++;
break;
}
}
return j;
}
/*
* Find length of a key entry
*/
......@@ -291,7 +318,15 @@ KEY_Create(struct busyobj *bo, struct vsb **psb)
error = 1;
break;
} else {
VSB_printf(sbm, "%c%.*s%c", type, size, match, 0);
// Crazy complicated unescape
struct vsb *sbtmp = VSB_new_auto();
AN(sbtmp);
VSB_printf(sbtmp, "%.*s", size, match);
AZ(VSB_finish(sbtmp));
int ms = unescape(VSB_data(sbtmp), VSB_data(sbtmp), size);
VSB_printf(sbm, "%c%.*s%c", type, ms, VSB_data(sbtmp), 0);
VSB_delete(sbtmp);
q += read;
}
}
......
varnishtest "Test Key matcher functionality (CASE)"
server s1 {
rxreq
txresp -hdr "Key: Foobar;b=\"A\""
rxreq
txresp -hdr "Key: Foobar;c;b=\"B\""
rxreq
txresp -hdr "Key: Foobar;c;b=\"B\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: Apple"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: ardvark"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
txreq -hdr "Foobar: Ball"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1004"
txreq -hdr "Foobar: brick"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1006"
} -run
......@@ -2,21 +2,21 @@ varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"a\""
txresp -hdr "Key: Foobar;b=\"a\""
rxreq
txresp -hdr "Key: Foobar;w=\"a\""
txresp -hdr "Key: Foobar;b=\"a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: b"
txreq -hdr "Foobar: Apple"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: b"
txreq -hdr "Foobar: Apple"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003"
expect resp.http.X-Varnish == "1003 1002"
} -run
......@@ -2,21 +2,21 @@ varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;c;w=\"a\""
txresp -hdr "Key: Foobar;b=\"a\""
rxreq
txresp -hdr "Key: Foobar;c;w=\"a\""
txresp -hdr "Key: Foobar;b=\"a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: A"
txreq -hdr "Foobar: ardvark"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: A"
txreq -hdr "Foobar: ardvark"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003"
expect resp.http.X-Varnish == "1003 1002"
} -run
......@@ -2,21 +2,21 @@ varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;n;w=\"a\""
txresp -hdr "Key: Foobar;c;b=\"a\""
rxreq
txresp -hdr "Key: Foobar;n;w=\"a\""
txresp -hdr "Key: Foobar;c;b=\"a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: b"
txreq -hdr "Foobar: Apple"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: b"
txreq -hdr "Foobar: Apple"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
expect resp.http.X-Varnish == "1003"
} -run
......@@ -2,20 +2,20 @@ varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"a\";n;w=\"b\""
txresp -hdr "Key: Foobar;c;b=\"a\""
rxreq
txresp -hdr "Key: Foobar;w=\"a\";n;w=\"b\""
txresp -hdr "Key: Foobar;c;b=\"a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: a, c"
txreq -hdr "Foobar: ardvark"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: a, c"
txreq -hdr "Foobar: ardvark"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
......
......@@ -2,21 +2,21 @@ varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"a\";n;w=\"b\""
txresp -hdr "Key: Foobar;w=\"a\";w=\"b\";w=\"c\""
rxreq
txresp -hdr "Key: Foobar;w=\"a\";n;w=\"b\""
txresp -hdr "Key: Foobar;w=\"a\";w=\"b\";w=\"c\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: a, b"
txreq -hdr "Foobar: c,a,b"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: a, b"
txreq -hdr "Foobar: c,a,b"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003"
expect resp.http.X-Varnish == "1003 1002"
} -run
......@@ -2,20 +2,20 @@ varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"\\\"a\\\"\""
txresp -hdr "Key: Foobar;w=\"a\""
rxreq
txresp -hdr "Key: Foobar;w=\"\\\"a\\\"\""
txresp -hdr "Key: Foobar;w=\"a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: \"a\""
txreq -hdr "Foobar: apple,a"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: \"a\""
txreq -hdr "Foobar: apple,a"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
......
......@@ -2,21 +2,21 @@ varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"\\\"a\\\"\""
txresp -hdr "Key: Foobar;w=\"a\""
rxreq
txresp -hdr "Key: Foobar;w=\"\\\"a\\\"\""
txresp -hdr "Key: Foobar;w=\"a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: \"a\""
txreq -hdr "Foobar: b"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: \"a\""
txreq -hdr "Foobar: b"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
expect resp.http.X-Varnish == "1003"
} -run
......@@ -2,20 +2,20 @@ varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"\\a\""
txresp -hdr "Key: Foobar;w=\"a\""
rxreq
txresp -hdr "Key: Foobar;w=\"\\a\""
txresp -hdr "Key: Foobar;w=\"a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: \\a"
txreq -hdr "Foobar: a,b"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: \\a"
txreq -hdr "Foobar: a,b"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
......
......@@ -2,20 +2,20 @@ varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
txresp -hdr "Key: Foobar;w=\"a\""
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
txresp -hdr "Key: Foobar;w=\"a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: text/html"
txreq -hdr "Foobar: b,a"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: text/html"
txreq -hdr "Foobar: b,a"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
......
......@@ -2,20 +2,20 @@ varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
txresp -hdr "Key: Foobar;n;b=\"a\""
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
txresp -hdr "Key: Foobar;n;b=\"a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: text/html; q=0.5"
txreq -hdr "Foobar: car"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: text/html; q=0.5"
txreq -hdr "Foobar: car"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
......
......@@ -2,20 +2,20 @@ varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
txresp -hdr "Key: Foobar;n;b=\"a\""
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
txresp -hdr "Key: Foobar;n;b=\"a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: text/html;q=0.1"
txreq -hdr "Foobar: duck"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: text/html;q=0.1"
txreq -hdr "Foobar: duck"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
......
......@@ -2,21 +2,21 @@ varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
txresp -hdr "Key: Foobar;c;w=\"a\""
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
txresp -hdr "Key: Foobar;c;w=\"a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: text/html; foo=\"bar\""
txreq -hdr "Foobar: A"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: text/html; foo=\"bar\""
txreq -hdr "Foobar: A"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
expect resp.http.X-Varnish == "1003"
} -run
varnishtest "Test Key matcher functionality (BEGINNING)"
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;b=\"A\""
txresp -hdr "Key: Foobar;n;w=\"a\""
rxreq
txresp -hdr "Key: Foobar;n;w=\"a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: Apple"
txreq -hdr "Foobar: b"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: Ardvark"
txreq -hdr "Foobar: b"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
......
varnishtest "Test Key matcher functionality (WORD)"
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"A\";w=\"B\";w=\"C\""
txresp -hdr "Key: Foobar;w=\"a\";n;w=\"b\""
rxreq
txresp -hdr "Key: Foobar;w=\"a\";n;w=\"b\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: A,B,C"
txreq -hdr "Foobar: a, c"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: C,A,B"
txreq -hdr "Foobar: a, c"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
......
varnishtest "Test Key matcher functionality (WORD)"
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"A\""
txresp -hdr "Key: Foobar;w=\"a\";n;w=\"b\""
rxreq
txresp -hdr "Key: Foobar;w=\"B\""
txresp -hdr "Key: Foobar;w=\"a\";n;w=\"b\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: A"
txreq -hdr "Foobar: a, b"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: B"
txreq -hdr "Foobar: a, b"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003"
......
varnishtest "Test Key matcher functionality (NOT)"
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;n;b=\"A\""
txresp -hdr "Key: Foobar;w=\"\\\"a\\\"\""
rxreq
txresp -hdr "Key: Foobar;w=\"\\\"a\\\"\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: Car"
txreq -hdr "Foobar: \"a\""
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: Duck"
txreq -hdr "Foobar: \"a\""
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
......
varnishtest "Test Key matcher functionality (WORD)"
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"A\""
txresp -hdr "Key: Foobar;w=\"\\\"a\\\"\""
rxreq
txresp -hdr "Key: Foobar;w=\"\\\"a\\\"\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: A,B"
txreq -hdr "Foobar: \"a\""
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: B,A"
txreq -hdr "Foobar: \"a\""
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
......
varnishtest "Test Key matcher functionality (WORD)"
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"A\""
txresp -hdr "Key: Foobar;w=\"\\a\""
rxreq
txresp -hdr "Key: Foobar;w=\"A\""
txresp -hdr "Key: Foobar;w=\"\\a\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: APPLE,A"
txreq -hdr "Foobar: \\a"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: APPLE,A"
txreq -hdr "Foobar: \\a"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
......
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: text/html"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: text/html"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
} -run
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: text/html; q=0.5"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: text/html; q=0.5"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
} -run
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: text/html;q=0.1"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: text/html;q=0.1"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
} -run
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
rxreq
txresp -hdr "Key: Foobar;p=\"text/html\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: text/html; foo=\"bar\""
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: text/html; foo=\"bar\""
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
} -run
varnishtest "Test Key matcher functionality"
server s1 {
rxreq
txresp -hdr "Key: Foobar;w=\"foo\";p=\"test\";b=\"win\";c;s=\"iNnInG\";n;w=\"bar\""
rxreq
txresp -hdr "Key: Foobar;w=\"foo\";p=\"test\";b=\"win\";c;s=\"iNnInG\";n;w=\"bar\""
} -start
varnish v1 -vcl+backend {} -start
client c1 {
txreq -hdr "Foobar: foo,test;bar,wiNnInG"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
txreq -hdr "Foobar: foo,test;bar,wiNnInG"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1003 1002"
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment