Commit b77f0963 authored by Geoff Simmons's avatar Geoff Simmons

add tests for the previous commit, and permit uppercase hex encoding

parent 3c5b47e6
......@@ -11,32 +11,76 @@ varnish v1 -vcl+backend {
import convert from "${vmod_topbuild}/src/.libs/libvmod_convert.so";
sub vcl_deliver {
set resp.http.hex =
set resp.http.hexlcxcode =
convert.transcode(IDENTITY, HEXLC, req.url +
"Hel" + "lo " + "" + "world" +
req.url);
set resp.http.hexucxcode =
convert.transcode(IDENTITY, HEX, req.url +
"Hel" + "lo " + "" + "world" +
req.url);
set resp.http.b64xcode =
convert.transcode(IDENTITY, BASE64, req.url + "Hello world" +
req.url);
set resp.http.b64urlxcode =
convert.transcode(IDENTITY, BASE64URL, req.url + "Hello world" +
req.url);
set resp.http.b64urlnopadxcode =
convert.transcode(IDENTITY, BASE64URLNOPAD,
req.url + "Hello world" + req.url);
set resp.http.id =
convert.encode(IDENTITY, convert.decode(IDENTITY,
"The quick brown fox jumps over the lazy dog"));
set resp.http.idlist =
convert.encode(IDENTITY, convert.decode(IDENTITY, "" + req.url +
"The quick " + "brown fox jumps over " + "" +
"the lazy dog" + "" + req.url + ""));
convert.encode(IDENTITY, convert.decode(IDENTITY,
"" + req.http.unset + req.url +
"The quick brown fox jumps over " +
req.http.unset + "" + req.http.unset + "" +
"the lazy dog" + req.url + req.http.unset + ""));
set resp.http.idempty =
convert.encode(IDENTITY, convert.decode(IDENTITY, ""));
set resp.http.undef =
convert.encode(IDENTITY, convert.decode(IDENTITY,
req.http.unset));
set resp.http.idemptylist =
convert.encode(IDENTITY, convert.decode(IDENTITY, "" + "" + ""));
convert.encode(IDENTITY, convert.decode(IDENTITY,
req.http.unset + "" + req.http.unset + ""));
set resp.http.hexlc =
convert.encode(HEXLC, convert.decode(IDENTITY,
"The quick brown fox jumps over the lazy dog"));
set resp.http.hexuc =
convert.encode(HEX, convert.decode(IDENTITY,
"The quick brown fox jumps over the lazy dog"));
set resp.http.b64 =
convert.encode(BASE64, convert.decode(IDENTITY,
"The quick brown fox jumps over the lazy dog"));
set resp.http.b64url =
convert.encode(BASE64URL, convert.decode(IDENTITY,
"The quick brown fox jumps over the lazy dog"));
set resp.http.b64urlnopad =
convert.encode(BASE64URLNOPAD, convert.decode(IDENTITY,
"The quick brown fox jumps over the lazy dog"));
}
} -start
client c1 {
txreq -url "/"
rxresp
expect resp.http.hex == "2f48656c6c6f20776f726c642f"
expect resp.http.hexlcxcode == "2f48656c6c6f20776f726c642f"
expect resp.http.hexucxcode == "2F48656C6C6F20776F726C642F"
expect resp.http.b64xcode == "L0hlbGxvIHdvcmxkLw=="
expect resp.http.b64urlxcode == "L0hlbGxvIHdvcmxkLw=="
expect resp.http.b64urlnopadxcode == "L0hlbGxvIHdvcmxkLw"
expect resp.http.id == "The quick brown fox jumps over the lazy dog"
expect resp.http.idlist == "/The quick brown fox jumps over the lazy dog/"
expect resp.http.idempty == ""
expect resp.http.undef == ""
expect resp.http.idemptylist == ""
expect resp.http.hexlc == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67"
expect resp.http.hexuc == "54686520717569636B2062726F776E20666F78206A756D7073206F76657220746865206C617A7920646F67"
expect resp.http.b64 == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=="
expect resp.http.b64url == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=="
expect resp.http.b64urlnopad == "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw"
}
client c1 -run
......@@ -465,6 +465,7 @@ vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, const char *p, ...) {
case IDENTITY:
len = id_encode(enc, wb.w, wb_space(&wb), buf, len);
break;
case HEX:
case HEXLC:
len = hex_encode(enc, wb.w, wb_space(&wb), buf, len);
break;
......
......@@ -16,9 +16,9 @@ $Event event
$Function BLOB decode(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX}, STRING_LIST)
XXX DOC
$Function STRING encode(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEXLC}, BLOB)
$Function STRING encode(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, HEXLC}, BLOB)
XXX DOC
$Function STRING transcode(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX}, ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEXLC}, STRING_LIST)
$Function STRING transcode(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX}, ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, HEXLC}, STRING_LIST)
XXX DOC
$Function BLOB transcode_blob(ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX}, ENUM { IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEXLC}, BLOB)
XXX DOC
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