Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-pcre2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
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-pcre2
Commits
699924dc
Commit
699924dc
authored
Mar 19, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a test for match options
parent
c8aed294
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
203 additions
and
0 deletions
+203
-0
match_opts.vtc
src/tests/match_opts.vtc
+203
-0
No files found.
src/tests/match_opts.vtc
0 → 100644
View file @
699924dc
# looks like -*- vcl -*-
varnishtest "match options"
# tests mostly from pcre2 testinput2
# offset_limit tested in compile_opts.vtc
# XXX
# - match_limit test results differ for jit or non-jit
# - recursion_limit is only relevant without jit
# - dfa matching, jit fast path, partial matching and start_offset not
# implemented yet
# - option to decide whether to save options in PRIV_CALL?
# - no_utf_check tests depend on whether utf is enabled
# - no_jit depends on whether jit is enabled
# len
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r = pcre2.regex("abc");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.r1 = r.match("defabc");
set resp.http.r2 = r.match("defabc", len=3);
}
} -start
client c1 -repeat 2 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.r1 == "true"
expect resp.http.r2 == "false"
} -run
# anchored
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1 = pcre2.regex("abc");
new r2 = pcre2.regex("\Biss\B");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.r1-1 = r1.match("defabc");
set resp.http.r1-2 = r1.match("defabc", anchored=true);
set resp.http.r2-1 = r2.match("Mississippi");
set resp.http.r2-2 = r2.match("Mississippi", anchored=true);
}
}
client c1 -repeat 2 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.r1-1 == "true"
expect resp.http.r1-2 == "false"
expect resp.http.r2-1 == "true"
expect resp.http.r2-2 == "false"
} -run
# notbol
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r = pcre2.regex("^X");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.r1 = r.match("XABC");
set resp.http.r2 = r.match("XABC", notbol=true);
}
}
client c1 -repeat 2 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.r1 == "true"
expect resp.http.r2 == "false"
} -run
# noteol
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r = pcre2.regex("a$");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.r1 = r.match("a");
set resp.http.r2 = r.match({"a
"});
set resp.http.r3 = r.match("a", noteol=true);
set resp.http.r4 = r.match(noteol=true, subject={"a
"});
}
}
client c1 -repeat 2 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.r1 == "true"
expect resp.http.r2 == "true"
expect resp.http.r3 == "false"
expect resp.http.r4 == "false"
} -run
# notempty
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r1 = pcre2.regex("a?b?");
new r2 = pcre2.regex("|-");
new r3 = pcre2.regex("(?>(*ACCEPT)b)c");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.r1-1 = r1.match("");
set resp.http.r1-2 = r1.match("", notempty=true);
set resp.http.r2-1 = r2.match("");
set resp.http.r2-2 = r2.match("", notempty=true);
set resp.http.r3-1 = r3.match("");
set resp.http.r3-2 = r3.match("c", notempty=true);
}
}
client c1 -repeat 2 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.r1-1 == "true"
expect resp.http.r1-2 == "false"
expect resp.http.r2-1 == "true"
expect resp.http.r2-2 == "false"
expect resp.http.r3-1 == "true"
expect resp.http.r3-2 == "false"
} -run
# notempty_atstart
varnish v1 -vcl {
import pcre2 from "${vmod_topbuild}/src/.libs/libvmod_pcre2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new r = pcre2.regex("^a?b?");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.r1 = r.match("xyz");
set resp.http.r2 = r.match("xyz", notempty_atstart=true);
set resp.http.r3 = r.match("xyzabc");
set resp.http.r4 = r.match("xyzabc", notempty_atstart=true);
}
}
client c1 -repeat 2 {
txreq
rxresp
expect resp.status == "200"
expect resp.http.r1 == "true"
expect resp.http.r2 == "false"
expect resp.http.r3 == "true"
expect resp.http.r4 == "false"
} -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