Skip to content

Commit

Permalink
Merge pull request #3 from duffn/duffn/null-function-tests
Browse files Browse the repository at this point in the history
Add tests for null params for inclusion and exclusion fuctions
  • Loading branch information
duffn authored Dec 16, 2024
2 parents 96b81b6 + bdfdecb commit 981d427
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 981d427

Please sign in to comment.