Commit 86d6a633 authored by Geoff Simmons's avatar Geoff Simmons

add tests for the extract() method to vcl_regex.vtc

parent f822f73c
......@@ -106,7 +106,7 @@ varnish v1 -vcl {
client c1 -run
# sub() function
# sub() method
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
......@@ -164,7 +164,7 @@ client c2 {
expect resp.http.regsuballsub == "barbazbar"
} -run
# suball() function
# suball() method
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
......@@ -213,3 +213,53 @@ varnish v1 -vcl {
}
client c2 -run
# extract() method
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new barbaz = re2.regex("(bar)baz");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.foo = "barbaz";
if (!barbaz.match(resp.http.foo)) {
set resp.status = 999;
}
if (resp.http.foo ~ "bar(baz)") {
set resp.http.tilde =
barbaz.extract(resp.http.foo, "\0\1",
"tildesub");
} else {
set resp.status = 999;
}
if (resp.http.foo !~ "bar(quux)") {
set resp.http.neg =
barbaz.extract(resp.http.foo, "\0\1", "negsub");
} else {
set resp.status = 999;
}
set resp.http.regsub
= regsub(resp.http.foo, "bar(baz)", "\1");
set resp.http.regsubsub = barbaz.extract(resp.http.foo, "\0\1",
"regsubx");
set resp.http.regsuball
= regsuball(resp.http.foo, "(.)", "x");
set resp.http.regsuballsub = barbaz.extract(resp.http.foo,
"\0\1",
"regsuballx");
}
}
client c2 -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