summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandre <andre@openbsd.org>2014-05-02 14:50:26 +0000
committerandre <andre@openbsd.org>2014-05-02 14:50:26 +0000
commite39408f9a7f6eb44c89d2e02d47fb7ac58a9514e (patch)
tree79b2470fa9634b67cac8cf93e757f1c2819b52db
parentImproves this test to be more strict on the filter action test. Now it (diff)
downloadwireguard-openbsd-e39408f9a7f6eb44c89d2e02d47fb7ac58a9514e.tar.xz
wireguard-openbsd-e39408f9a7f6eb44c89d2e02d47fb7ac58a9514e.zip
Add regression tests to relayd to cover a few key types/actions combinations.
ok reyk
-rw-r--r--regress/usr.sbin/relayd/args-http-append.pl22
-rw-r--r--regress/usr.sbin/relayd/args-http-change.pl30
-rw-r--r--regress/usr.sbin/relayd/args-http-expect.pl22
-rw-r--r--regress/usr.sbin/relayd/args-http-filter-cookie.pl26
-rw-r--r--regress/usr.sbin/relayd/args-http-filter-url.pl31
-rw-r--r--regress/usr.sbin/relayd/args-http-hash.pl28
-rw-r--r--regress/usr.sbin/relayd/args-http-label.pl26
-rw-r--r--regress/usr.sbin/relayd/args-http-mark.pl21
-rw-r--r--regress/usr.sbin/relayd/args-http-remove.pl32
-rw-r--r--regress/usr.sbin/relayd/args-http-return.pl29
10 files changed, 267 insertions, 0 deletions
diff --git a/regress/usr.sbin/relayd/args-http-append.pl b/regress/usr.sbin/relayd/args-http-append.pl
new file mode 100644
index 00000000000..3086336d4b0
--- /dev/null
+++ b/regress/usr.sbin/relayd/args-http-append.pl
@@ -0,0 +1,22 @@
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => \&http_client,
+ len => 1,
+ loggrep => { "X-Server-Append: 127.0.0.1:.*" => 1 },
+ },
+ relayd => {
+ protocol => [ "http",
+ 'request header append "$REMOTE_ADDR:$REMOTE_PORT" to X-Client-Append',
+ 'response header append "$SERVER_ADDR:$SERVER_PORT" to X-Server-Append',
+ ],
+ },
+ server => {
+ func => \&http_server,
+ loggrep => { "X-Client-Append: 127.0.0.1:.*" => 1 },
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/relayd/args-http-change.pl b/regress/usr.sbin/relayd/args-http-change.pl
new file mode 100644
index 00000000000..941a2f62185
--- /dev/null
+++ b/regress/usr.sbin/relayd/args-http-change.pl
@@ -0,0 +1,30 @@
+use strict;
+use warnings;
+
+my %header = ("X-Test-Header" => "XOriginalValue");
+our %args = (
+ client => {
+ func => \&http_client,
+ nocheck => 1,
+ loggrep => {
+ qr/X-Test-Header: XChangedValue/ => 1,
+ qr/Host: foo.bar/ => 1,
+ }
+ },
+ relayd => {
+ protocol => [ "http",
+ 'request header change "Host" to "foobar.changed"',
+ 'response header change "X-Test-Header" to "XChangedValue"',
+ ],
+ },
+ server => {
+ func => \&http_server,
+ header => \%header,
+ loggrep => {
+ qr/X-Test-Header: XOriginalValue/ => 1,
+ qr/Host: foobar.changed/ => 1,
+ },
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/relayd/args-http-expect.pl b/regress/usr.sbin/relayd/args-http-expect.pl
new file mode 100644
index 00000000000..c9fb482894b
--- /dev/null
+++ b/regress/usr.sbin/relayd/args-http-expect.pl
@@ -0,0 +1,22 @@
+use strict;
+use warnings;
+
+my @lengths = (21);
+our %args = (
+ client => {
+ func => \&http_client,
+ lengths => \@lengths,
+ path => "query?foo=bar&ok=yes"
+ },
+ relayd => {
+ protocol => [ "http",
+ 'request query expect "bar" from "foo" log',
+ ],
+ },
+ server => {
+ func => \&http_server,
+ },
+ lengths => \@lengths,
+);
+
+1;
diff --git a/regress/usr.sbin/relayd/args-http-filter-cookie.pl b/regress/usr.sbin/relayd/args-http-filter-cookie.pl
new file mode 100644
index 00000000000..e53f4ca9233
--- /dev/null
+++ b/regress/usr.sbin/relayd/args-http-filter-cookie.pl
@@ -0,0 +1,26 @@
+# test http block
+
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => sub { eval { http_client(@_) }; warn $@ },
+ loggrep => qr/Client missing http 251 response/,
+ cookie => "med=thx; domain=.foo.bar; path=/; expires=Mon, 27-Oct-2014 04:11:56 GMT;",
+ path => "anypath",
+ nocheck => 1,
+ },
+ relayd => {
+ protocol => [ "http",
+ 'request cookie filter "thx" from "med" log',
+ ],
+ loggrep => qr/rejecting request, \[med: thx\]/,
+ },
+ server => {
+ noserver => 1,
+ nocheck => 1,
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/relayd/args-http-filter-url.pl b/regress/usr.sbin/relayd/args-http-filter-url.pl
new file mode 100644
index 00000000000..534be4c7597
--- /dev/null
+++ b/regress/usr.sbin/relayd/args-http-filter-url.pl
@@ -0,0 +1,31 @@
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => \&http_client,
+ path => "a/b/c/d/e/f/gindex.html",
+ loggrep => [
+ qr/403 Forbidden/,
+ qr/Server: OpenBSD relayd/,
+ qr/Connection: close/,
+ ],
+ httpnok => 1,
+ },
+ relayd => {
+ protocol => [ "http",
+ 'return error',
+ 'request url filter "foo.bar/a/b/" log',
+ ],
+ loggrep => {
+ qr/rejecting request \(403 Forbidden\)/ => 1,
+ qr/\[foo.bar\/a\/b\/:/ => 1,
+ },
+ },
+ server => {
+ noserver => 1,
+ nocheck => 1,
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/relayd/args-http-hash.pl b/regress/usr.sbin/relayd/args-http-hash.pl
new file mode 100644
index 00000000000..e14890ddefe
--- /dev/null
+++ b/regress/usr.sbin/relayd/args-http-hash.pl
@@ -0,0 +1,28 @@
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => \&http_client,
+ path => "query?foobar",
+ len => 21,
+ nocheck => 1,
+ },
+ relayd => {
+ table => 1,
+ protocol => [ "http",
+ 'path hash "/query" log',
+ ],
+ relay => 'forward to <table-$test> port $connectport',
+ loggrep => {
+ qr/done, \[\/query: foobar\]/ => 1,
+ qr/relay_handle_http: hash 0xfde460be/ => 1,
+ },
+ },
+ server => {
+ func => \&http_server,
+ nocheck => 1,
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/relayd/args-http-label.pl b/regress/usr.sbin/relayd/args-http-label.pl
new file mode 100644
index 00000000000..5185d73f529
--- /dev/null
+++ b/regress/usr.sbin/relayd/args-http-label.pl
@@ -0,0 +1,26 @@
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => \&http_client,
+ loggrep => qr/403 Forbidden/,
+ path => "query?foo=bar&ok=yes",
+ httpnok => 1,
+ },
+ relayd => {
+ protocol => [ "http",
+ 'return error',
+ 'label "expect_foobar_label"',
+ 'request query filter "bar" from "foo" log',
+ 'no label',
+ ],
+ loggrep => qr/.*403 Forbidden.*expect_foobar_label.*foo: bar/,
+ },
+ server => {
+ noserver => 1,
+ nocheck => 1,
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/relayd/args-http-mark.pl b/regress/usr.sbin/relayd/args-http-mark.pl
new file mode 100644
index 00000000000..a96d8927862
--- /dev/null
+++ b/regress/usr.sbin/relayd/args-http-mark.pl
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => \&http_client,
+ path => "foobar?path",
+ },
+ relayd => {
+ protocol => [ "http",
+ 'request path mark "*" from "/foobar" with 55',
+ 'request path change "path" to "foobarchangedpath" marked 55',
+ ],
+ loggrep => { ", 55,.*done" => 1 },
+ },
+ server => {
+ func => \&http_server,
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/relayd/args-http-remove.pl b/regress/usr.sbin/relayd/args-http-remove.pl
new file mode 100644
index 00000000000..e8a6cac4a4c
--- /dev/null
+++ b/regress/usr.sbin/relayd/args-http-remove.pl
@@ -0,0 +1,32 @@
+use strict;
+use warnings;
+
+my %header = (
+ "X-Header-Foo" => "foo",
+ "X-Header-Bar" => "bar",
+);
+our %args = (
+ client => {
+ func => \&http_client,
+ loggrep => {
+ "X-Header-Foo: foo" => 0,
+ "X-Header-Bar: bar" => 1,
+ },
+ },
+ relayd => {
+ protocol => [ "http",
+ 'response header remove X-Header-Foo log',
+ ],
+ loggrep => { qr/done, \[X-Header-Foo: foo\s*\]/ => 1 },
+ },
+ server => {
+ func => \&http_server,
+ header => \%header,
+ loggrep => {
+ "X-Header-Foo: foo" => 1,
+ "X-Header-Bar: bar" => 1,
+ },
+ },
+);
+
+1;
diff --git a/regress/usr.sbin/relayd/args-http-return.pl b/regress/usr.sbin/relayd/args-http-return.pl
new file mode 100644
index 00000000000..3d06bd7588d
--- /dev/null
+++ b/regress/usr.sbin/relayd/args-http-return.pl
@@ -0,0 +1,29 @@
+use strict;
+use warnings;
+
+our %args = (
+ client => {
+ func => \&http_client,
+ # XXX add more paths to match a case where it pass
+ path => "query?foo=bar&ok=yes",
+ nocheck => 1,
+ httpnok => 1,
+ },
+ relayd => {
+ protocol => [ "http",
+ 'return error',
+ 'label "expect_foobar_return_test"',
+ 'request query expect "baz" from "foo" log',
+ 'no label',
+ ],
+ loggrep => {
+ ' \(403 Forbidden\), \[expect_foobar_return_test, foo: bar\]' => 1
+ },
+ },
+ server => {
+ noserver => 1,
+ nocheck => 1,
+ },
+);
+
+1;