Commit 9bce45cc authored by Geoff Simmons's avatar Geoff Simmons

add tests for the literal, never_nl, dot_nl and case_sensitive options

parent edced643
# looks like -*- vcl -*-
varnishtest "literal, never_nl, dot_nl and case_sensitive options"
# Tests from re2 testing/parse_test.cc and testing/re2_test.cc
varnish v1 -vcl {
import re2 from "${vmod_topbuild}/src/.libs/libvmod_re2.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new literal = re2.regex("(|)^$.[*+?]{5,10},\\", literal=true);
new never1 = re2.regex("(.*)", never_nl=true);
new never2 = re2.regex("(?s)(abc.*def)", never_nl=true);
new never3 = re2.regex({"(abc(.|
)def)"},
never_nl=true);
new never4 = re2.regex("(abc[^x]*def)", never_nl=true);
new dot1 = re2.regex(".", dot_nl=true);
new dot2 = re2.regex("(?-s).", dot_nl=true);
new dot3 = re2.regex(".", dot_nl=true, never_nl=true);
new case = re2.regex("(?i)([wand]{5})", case_sensitive=true);
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
if (literal.match("(|)^$.[*+?]{5,10},\\")) {
set resp.http.literal = "match";
}
if (never1.match({"abc
def
ghi
"} )) {
set resp.http.never1 = "match";
set resp.http.never11 = never1.backref(1);
}
if (never2.match({"abc
def
"} )) {
set resp.http.never2 = "match";
}
if (never3.match({"abc
def
"} )) {
set resp.http.never3 = "match";
}
if (never4.match({"abc
def
"} )) {
set resp.http.never4 = "match";
}
if (never4.match({"abczzzdef
def
"} )) {
set resp.http.never5 = "match";
set resp.http.never51 = never4.backref(1);
}
if (dot1.match({"
"} )) {
set resp.http.dot1 = "match";
}
if (dot2.match({"
"} )) {
set resp.http.dot2 = "match";
}
if (dot3.match({"
"} )) {
set resp.http.dot3 = "match";
}
if (case.match("A fish named *Wanda*")) {
set resp.http.case = "match";
set resp.http.case1 = case.backref(1);
}
}
} -start
client c1 {
txreq
rxresp
expect resp.http.literal == "match"
expect resp.http.never1 == "match"
expect resp.http.never11 == "abc"
expect resp.http.never2 == <undef>
expect resp.http.never3 == <undef>
expect resp.http.never4 == <undef>
expect resp.http.never5 == "match"
expect resp.http.never51 == "abczzzdef"
expect resp.http.dot1 == "match"
expect resp.http.dot2 == <undef>
expect resp.http.dot3 == <undef>
expect resp.http.case == "match"
expect resp.http.case1 == "Wanda"
} -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