diff --git a/src/vtc/null_params_exclusion.vtc b/src/vtc/null_params_exclusion.vtc index f2ed001..d04a0ce 100644 --- a/src/vtc/null_params_exclusion.vtc +++ b/src/vtc/null_params_exclusion.vtc @@ -1,4 +1,4 @@ -varnishtest "Test querymodifier vmod for partial non-matches" +varnishtest "Test querymodifier vmod for null params exclusion" server s1 { rxreq diff --git a/src/vtc/null_params_exclusion_function.vtc b/src/vtc/null_params_exclusion_function.vtc new file mode 100644 index 0000000..bfe6f43 --- /dev/null +++ b/src/vtc/null_params_exclusion_function.vtc @@ -0,0 +1,28 @@ +varnishtest "Test querymodifier vmod for null params using the excludeparams function" + +server s1 { + rxreq + txresp -body "OK1" + expect req.url == "/feed/" +} -start + +varnish v1 -vcl+backend { + import std; + import querymodifier; + + sub vcl_recv { + std.syslog(180, "querymodifier before: " + req.url); + set req.url = querymodifier.excludeparams(url=req.url, params=""); + std.syslog(180, "querymodifier after: " + req.url); + } +} -start + +client c1 { + txreq -url "/feed/?id=1&d=2&another=3" + rxresp + expect resp.status == 200 +} -run + +varnish v1 -expect n_object == 1 +varnish v1 -expect cache_miss == 1 +varnish v1 -expect cache_hit == 0 diff --git a/src/vtc/null_params_inclusion.vtc b/src/vtc/null_params_inclusion.vtc index 0f6dc19..238a338 100644 --- a/src/vtc/null_params_inclusion.vtc +++ b/src/vtc/null_params_inclusion.vtc @@ -1,4 +1,4 @@ -varnishtest "Test querymodifier vmod for partial non-matches" +varnishtest "Test querymodifier vmod for null params inclusion" server s1 { rxreq diff --git a/src/vtc/null_params_inclusion_function.vtc b/src/vtc/null_params_inclusion_function.vtc new file mode 100644 index 0000000..37517b1 --- /dev/null +++ b/src/vtc/null_params_inclusion_function.vtc @@ -0,0 +1,32 @@ +varnishtest "Test querymodifier vmod for null params using the includeparams function" + +server s1 { + rxreq + txresp -body "OK1" + expect req.url == "/feed/" +} -start + +varnish v1 -vcl+backend { + import std; + import querymodifier; + + sub vcl_recv { + std.syslog(180, "querymodifier before: " + req.url); + set req.url = querymodifier.includeparams(url=req.url, params=""); + std.syslog(180, "querymodifier after: " + req.url); + } +} -start + +client c1 { + txreq -url "/feed/?id=1&d=2&another=3" + rxresp + expect resp.status == 200 + + txreq -url "/feed/" + rxresp + expect resp.status == 200 +} -run + +varnish v1 -expect n_object == 1 +varnish v1 -expect cache_miss == 1 +varnish v1 -expect cache_hit == 1