Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-re2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-re2
Commits
7cc8686d
Commit
7cc8686d
authored
Mar 28, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for suball() to vcl_regex.vtc
parent
a0bda08d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
25 deletions
+105
-25
vcl_regex.vtc
src/tests/vcl_regex.vtc
+105
-25
No files found.
src/tests/vcl_regex.vtc
View file @
7cc8686d
...
...
@@ -2,7 +2,7 @@
varnishtest "backrefs not affected by standard VCL regex code"
varnish v1 -vcl
+backend
{
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
...
...
@@ -23,8 +23,6 @@ varnish v1 -vcl+backend {
if (resp.http.foo ~ "bar(baz)") {
set resp.http.tilde0 = barbaz.backref(0, "tilde0");
set resp.http.tilde1 = barbaz.backref(1, "tilde1");
set resp.http.tildesub =
barbaz.sub(resp.http.foo, "\0\1", "tildesub");
} else {
set resp.status = 999;
}
...
...
@@ -32,8 +30,6 @@ varnish v1 -vcl+backend {
if (resp.http.foo !~ "bar(quux)") {
set resp.http.neg0 = barbaz.backref(0, "neg0");
set resp.http.neg1 = barbaz.backref(1, "neg1");
set resp.http.negsub =
barbaz.sub(resp.http.foo, "\0\1", "negsub");
} else {
set resp.status = 999;
}
...
...
@@ -42,17 +38,12 @@ varnish v1 -vcl+backend {
= regsub(resp.http.foo, "bar(baz)", "\1");
set resp.http.regsub0 = barbaz.backref(0, "regsub0");
set resp.http.regsub1 = barbaz.backref(1, "regsub1");
set resp.http.regsubsub = barbaz.sub(resp.http.foo, "\0\1",
"regsubsub");
set resp.http.regsuball
= regsuball(resp.http.foo, "(.)", "x");
set resp.http.regsuball0 = barbaz.backref(0, "regsuball0");
set resp.http.regsuball1 = barbaz.backref(1, "regsuball1");
set resp.http.regsuballsub = barbaz.sub(resp.http.foo, "\0\1",
"regsuballsub");
}
} -start
client c1 {
...
...
@@ -61,23 +52,19 @@ client c1 {
expect resp.status == 200
expect resp.http.tilde0 == "barbaz"
expect resp.http.tilde1 == "bar"
expect resp.http.tildesub == "barbazbar"
expect resp.http.neg0 == "barbaz"
expect resp.http.neg1 == "bar"
expect resp.http.negsub == "barbazbar"
expect resp.http.regsub == "baz"
expect resp.http.regsub0 == "barbaz"
expect resp.http.regsub1 == "bar"
expect resp.http.regsubsub == "barbazbar"
expect resp.http.regsuball == "xxxxxx"
expect resp.http.regsuball0 == "barbaz"
expect resp.http.regsuball1 == "bar"
expect resp.http.regsuballsub == "barbazbar"
} -run
#
Function interface
#
match() function
varnish v1 -vcl
+backend
{
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
...
...
@@ -115,21 +102,114 @@ varnish v1 -vcl+backend {
set resp.http.regsuball0 = re2.backref(0, "regsuball0");
set resp.http.regsuball1 = re2.backref(1, "regsuball1");
}
}
client c1 -run
# sub() function
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.sub(resp.http.foo, "\0\1", "tildesub");
} else {
set resp.status = 999;
}
if (resp.http.foo !~ "bar(quux)") {
set resp.http.neg =
barbaz.sub(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.sub(resp.http.foo, "\0\1",
"regsubsub");
set resp.http.regsuball
= regsuball(resp.http.foo, "(.)", "x");
set resp.http.regsuballsub = barbaz.sub(resp.http.foo, "\0\1",
"regsuballsub");
}
}
client c
1
{
client c
2
{
txreq
rxresp
expect resp.status == 200
expect resp.http.tilde0 == "barbaz"
expect resp.http.tilde1 == "bar"
expect resp.http.neg0 == "barbaz"
expect resp.http.neg1 == "bar"
expect resp.http.tilde == "barbazbar"
expect resp.http.neg == "barbazbar"
expect resp.http.regsub == "baz"
expect resp.http.regsub0 == "barbaz"
expect resp.http.regsub1 == "bar"
expect resp.http.regsubsub == "barbazbar"
expect resp.http.regsuball == "xxxxxx"
expect resp.http.regsuball0 == "barbaz"
expect resp.http.regsuball1 == "bar"
expect resp.http.regsuballsub == "barbazbar"
} -run
# suball() function
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.suball(resp.http.foo, "\0\1",
"tildesub");
} else {
set resp.status = 999;
}
if (resp.http.foo !~ "bar(quux)") {
set resp.http.neg =
barbaz.suball(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.suball(resp.http.foo, "\0\1",
"regsubsub");
set resp.http.regsuball
= regsuball(resp.http.foo, "(.)", "x");
set resp.http.regsuballsub = barbaz.suball(resp.http.foo,
"\0\1",
"regsuballsub");
}
}
client c2 -run
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment