Commit ae773ead authored by Geoff Simmons's avatar Geoff Simmons

reorganize test cases

parent f16546e7
# looks like -*- perl -*-
varnishtest "Test convert vmod"
varnishtest "base64 encode and decode"
server s1 {
rxreq
txresp
} -start
server s1 {} -start
varnish v1 -vcl+backend {
import convert from "${vmod_topbuild}/src/.libs/libvmod_convert.so";
sub vcl_deliver {
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.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,
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"));
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
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"));
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);
}
} -start
client c1 {
txreq -url "/"
rxresp
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"
expect resp.http.b64xcode == "L0hlbGxvIHdvcmxkLw=="
expect resp.http.b64urlxcode == "L0hlbGxvIHdvcmxkLw=="
expect resp.http.b64urlnopadxcode == "L0hlbGxvIHdvcmxkLw"
}
client c1 -run
# looks like -*- perl -*-
varnishtest "hex encode and decode"
server s1 {} -start
varnish v1 -vcl+backend {
import convert from "${vmod_topbuild}/src/.libs/libvmod_convert.so";
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
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.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);
}
} -start
client c1 {
txreq -url "/"
rxresp
expect resp.http.hexlc == "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67"
expect resp.http.hexuc == "54686520717569636B2062726F776E20666F78206A756D7073206F76657220746865206C617A7920646F67"
expect resp.http.hexlcxcode == "2f48656c6c6f20776f726c642f"
expect resp.http.hexucxcode == "2F48656C6C6F20776F726C642F"
}
client c1 -run
# looks like -*- perl -*-
varnishtest "IDENTITY encode and decode"
server s1 {} -start
varnish v1 -vcl+backend {
import convert from "${vmod_topbuild}/src/.libs/libvmod_convert.so";
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.id =
convert.encode(IDENTITY, convert.decode(IDENTITY,
"The quick brown fox jumps over the lazy dog"));
set resp.http.list =
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.empty =
convert.encode(IDENTITY, convert.decode(IDENTITY, ""));
set resp.http.undef =
convert.encode(IDENTITY, convert.decode(IDENTITY,
req.http.unset));
set resp.http.emptylist =
convert.encode(IDENTITY, convert.decode(IDENTITY,
req.http.unset + "" + req.http.unset + ""));
}
} -start
client c1 {
txreq -url "/"
rxresp
expect resp.http.id == "The quick brown fox jumps over the lazy dog"
expect resp.http.list == "/The quick brown fox jumps over the lazy dog/"
expect resp.http.empty == ""
expect resp.http.undef == ""
expect resp.http.emptylist == ""
}
client c1 -run
# looks like -*- perl -*-
varnishtest "Test transcode()"
server s1 {} -start
varnish v1 -vcl+backend {
import convert from "${vmod_topbuild}/src/.libs/libvmod_convert.so";
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.id2id
= convert.transcode(IDENTITY, IDENTITY, "Hello world");
set resp.http.hex2hex
= convert.transcode(HEX, HEX, "0123456789ABCDEF");
# set resp.http.hexlc2hexlc
# = convert.transcode(HEXLC, HEXLC, "0123456789abcdef");
set resp.http.b642b64
= convert.transcode(BASE64, BASE64,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
+ "ghijklmnopqrstuvwxyz0123456789+/");
set resp.http.b64url2b64url =
convert.transcode(BASE64URL, BASE64URL,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
+ "ghijklmnopqrstuvwxyz0123456789-_");
set resp.http.b64urlnopad2b64urlnopad =
convert.transcode(BASE64URLNOPAD, BASE64URLNOPAD,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
+ "ghijklmnopqrstuvwxyz0123456789-_");
}
} -start
client c1 {
txreq -url "/"
rxresp
expect resp.http.id2id == "Hello world"
expect resp.http.hex2hex == "0123456789ABCDEF"
# expect resp.http.hexlc2hexlc == "0123456789abcdef"
expect resp.http.b642b64 == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
expect resp.http.b64url2b64url == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
expect resp.http.b64urlnopad2b64urlnopad == "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
}
client c1 -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