Skip to content

Commit

Permalink
Add tests for null params for inclusion and exclusion fuctions
Browse files Browse the repository at this point in the history
  • Loading branch information
duffn committed Dec 16, 2024
1 parent 96b81b6 commit bdfdecb
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/vtc/null_params_exclusion.vtc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
varnishtest "Test querymodifier vmod for partial non-matches"
varnishtest "Test querymodifier vmod for null params exclusion"

server s1 {
rxreq
Expand Down
28 changes: 28 additions & 0 deletions src/vtc/null_params_exclusion_function.vtc
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/vtc/null_params_inclusion.vtc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
varnishtest "Test querymodifier vmod for partial non-matches"
varnishtest "Test querymodifier vmod for null params inclusion"

server s1 {
rxreq
Expand Down
32 changes: 32 additions & 0 deletions src/vtc/null_params_inclusion_function.vtc
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bdfdecb

Please sign in to comment.