Commit 2ca0f54d authored by Geoff Simmons's avatar Geoff Simmons

test blob object with the URL encoding

parent ec63ff15
......@@ -152,6 +152,8 @@ varnish v1 -vcl+backend {
set resp.http.b642b64nopad = b64.encode(BASE64URLNOPAD);
set resp.http.b642hexuc = b64.encode(HEXUC);
set resp.http.b642hexlc = b64.encode(HEXLC);
set resp.http.b642urluc = b64.encode(URLUC);
set resp.http.b642urllc = b64.encode(URLLC);
set resp.http.b64url2id = b64url.encode(IDENTITY);
set resp.http.b64url2b64 = b64url.encode(BASE64);
......@@ -159,6 +161,8 @@ varnish v1 -vcl+backend {
set resp.http.b64url2b64nopad = b64url.encode(BASE64URLNOPAD);
set resp.http.b64url2hexuc = b64url.encode(HEXUC);
set resp.http.b64url2hexlc = b64url.encode(HEXLC);
set resp.http.b64url2urluc = b64url.encode(URLUC);
set resp.http.b64url2urllc = b64url.encode(URLLC);
set resp.http.b64nopad2id = b64nopad.encode(IDENTITY);
set resp.http.b64nopad2b64 = b64nopad.encode(BASE64);
......@@ -166,6 +170,8 @@ varnish v1 -vcl+backend {
set resp.http.b64nopad2b64nopad = b64nopad.encode(BASE64URLNOPAD);
set resp.http.b64nopad2hexuc = b64nopad.encode(HEXUC);
set resp.http.b64nopad2hexlc = b64nopad.encode(HEXLC);
set resp.http.b64nopad2urluc = b64nopad.encode(URLUC);
set resp.http.b64nopad2urllc = b64nopad.encode(URLLC);
}
}
......@@ -178,6 +184,8 @@ client c2 {
expect resp.http.b642b64nopad == "L0hlbGxvIHdvcmxkLw"
expect resp.http.b642hexuc == "2F48656C6C6F20776F726C642F"
expect resp.http.b642hexlc == "2f48656c6c6f20776f726c642f"
expect resp.http.b642urluc == "%2FHello%20world%2F"
expect resp.http.b642urllc == "%2fHello%20world%2f"
expect resp.http.b64url2id == "/Hello world/"
expect resp.http.b64url2b64 == "L0hlbGxvIHdvcmxkLw=="
......@@ -185,6 +193,8 @@ client c2 {
expect resp.http.b64url2b64nopad == "L0hlbGxvIHdvcmxkLw"
expect resp.http.b64url2hexuc == "2F48656C6C6F20776F726C642F"
expect resp.http.b64url2hexlc == "2f48656c6c6f20776f726c642f"
expect resp.http.b64url2urluc == "%2FHello%20world%2F"
expect resp.http.b64url2urllc == "%2fHello%20world%2f"
expect resp.http.b64nopad2id == "/Hello world/"
expect resp.http.b64nopad2b64 == "L0hlbGxvIHdvcmxkLw=="
......@@ -192,11 +202,75 @@ client c2 {
expect resp.http.b64nopad2b64nopad == "L0hlbGxvIHdvcmxkLw"
expect resp.http.b64nopad2hexuc == "2F48656C6C6F20776F726C642F"
expect resp.http.b64nopad2hexlc == "2f48656c6c6f20776f726c642f"
expect resp.http.b64nopad2urluc == "%2FHello%20world%2F"
expect resp.http.b64nopad2urllc == "%2fHello%20world%2f"
} -run
# run twice
client c2 -run
varnish v1 -vcl+backend {
import blobcode from "${vmod_topbuild}/src/.libs/libvmod_blobcode.so";
sub vcl_init {
new id = blobcode.blob(IDENTITY,
"The quick brown fox jumps over the lazy dog");
new url = blobcode.blob(URL, "foo%3Abar%3abaz%3Aquux");
new idempty = blobcode.blob(IDENTITY, "");
new hexuc = blobcode.blob(HEX, "666F6F206261722062617A2071757578");
new hexlc = blobcode.blob(HEX, "666f6f206261722062617a2071757578");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.id2urluc = id.encode(URLUC);
set resp.http.id2urllc = id.encode(URLLC);
set resp.http.emptyurluc = idempty.encode(URLUC);
set resp.http.emptyurllc = idempty.encode(URLLC);
set resp.http.url = blobcode.encode(IDENTITY, url.get());
set resp.http.hexuc2urluc = hexuc.encode(URLUC);
set resp.http.hexuc2urllc = hexuc.encode(URLLC);
set resp.http.hexlc2urluc = hexlc.encode(URLUC);
set resp.http.hexlc2urllc = hexlc.encode(URLLC);
set resp.http.url2id = url.encode(IDENTITY);
set resp.http.url2b64 = url.encode(BASE64);
set resp.http.url2b64url = url.encode(BASE64URL);
set resp.http.url2b64nopad = url.encode(BASE64URLNOPAD);
set resp.http.url2hexuc = url.encode(HEXUC);
set resp.http.url2hexlc = url.encode(HEXLC);
set resp.http.url2urluc = url.encode(URLUC);
set resp.http.url2urllc = url.encode(URLLC);
}
}
client c3 {
txreq
rxresp
expect resp.http.id2urluc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog"
expect resp.http.id2urllc == "The%20quick%20brown%20fox%20jumps%20over%20the%20lazy%20dog"
expect resp.http.emptyurluc == ""
expect resp.http.emptyurllc == ""
expect resp.http.hexuc2urluc == "foo%20bar%20baz%20quux"
expect resp.http.hexuc2urllc == "foo%20bar%20baz%20quux"
expect resp.http.hexlc2urluc == "foo%20bar%20baz%20quux"
expect resp.http.hexlc2urllc == "foo%20bar%20baz%20quux"
expect resp.http.url == "foo:bar:baz:quux"
expect resp.http.url2id == "foo:bar:baz:quux"
expect resp.http.url2b64 == "Zm9vOmJhcjpiYXo6cXV1eA=="
expect resp.http.url2b64url == "Zm9vOmJhcjpiYXo6cXV1eA=="
expect resp.http.url2b64nopad == "Zm9vOmJhcjpiYXo6cXV1eA"
expect resp.http.url2hexuc == "666F6F3A6261723A62617A3A71757578"
expect resp.http.url2hexlc == "666f6f3a6261723a62617a3a71757578"
expect resp.http.url2urluc == "foo%3Abar%3Abaz%3Aquux"
expect resp.http.url2urllc == "foo%3abar%3abaz%3aquux"
} -run
# run twice
client c3 -run
varnish v1 -errvcl {vmod blobcode error: cannot create blob err, illegal encoding beginning with "g"} {
import blobcode from "${vmod_topbuild}/src/.libs/libvmod_blobcode.so";
backend b { .host="${bad_ip}"; }
......@@ -228,3 +302,35 @@ varnish v1 -errvcl {vmod blobcode error: cannot create blob badpad, illegal enco
new badpad = blobcode.blob(BASE64URLNOPAD, "YWI=");
}
}
varnish v1 -errvcl {vmod blobcode error: cannot create blob badurl, illegal encoding beginning with "%"} {
import blobcode from "${vmod_topbuild}/src/.libs/libvmod_blobcode.so";
backend b { .host="${bad_ip}"; }
sub vcl_init {
new badurl = blobcode.blob(URL, "%");
}
}
varnish v1 -errvcl {vmod blobcode error: cannot create blob badurl, illegal encoding beginning with "%2"} {
import blobcode from "${vmod_topbuild}/src/.libs/libvmod_blobcode.so";
backend b { .host="${bad_ip}"; }
sub vcl_init {
new badurl = blobcode.blob(URL, "%2");
}
}
varnish v1 -errvcl {vmod blobcode error: cannot create blob badurl, illegal encoding beginning with "%q"} {
import blobcode from "${vmod_topbuild}/src/.libs/libvmod_blobcode.so";
backend b { .host="${bad_ip}"; }
sub vcl_init {
new badurl = blobcode.blob(URL, "%q");
}
}
varnish v1 -errvcl {vmod blobcode error: cannot create blob badurl, illegal encoding beginning with "%2q"} {
import blobcode from "${vmod_topbuild}/src/.libs/libvmod_blobcode.so";
backend b { .host="${bad_ip}"; }
sub vcl_init {
new badurl = blobcode.blob(URL, "%2q");
}
}
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