# HG changeset patch # User Sergey Kandaurov # Date 1377788528 -14400 # Node ID dacd55fa2cde0e50880a60d118434f4acb97c829 # Parent a2c15637c9d5327b5ac78f16c90c4410e85a3a90 Tests: added edge case tests for long hostname in referer. diff --git a/referer.t b/referer.t --- a/referer.t +++ b/referer.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http referer rewrite/)->plan(51); +my $t = Test::Nginx->new()->has(qw/http referer rewrite/)->plan(54); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -98,6 +98,10 @@ http { valid_referers *.example.com *.example.org www.example.* example.*; return 200 "value $invalid_referer"; } + location /long { + valid_referers ~.*; + return 200 "value $invalid_referer"; + } location /wc2 { valid_referers www.example.*/uri; return 200 "value $invalid_referer"; @@ -132,6 +136,17 @@ ok(valid('/simple', 'http://www.example. ok(!valid('/simple', 'http://www.example.' . 'a' x 256), 'long hostname'); ok(!valid('/wc', 'http://example.' . 'a' x 256), 'long hostname wildcard'); +ok(valid('/long', 'http://' . 'a' x 255), 'long hostname 255'); + +TODO: { +local $TODO = 'not yet'; + +ok(valid('/long', 'http://' . 'a' x 256), 'long hostname 256'); + +} + +ok(!valid('/long', 'http://' . 'a' x 257), 'long hostname 257'); + ok(valid('/uri', 'http://www.example.org/uri'), 'uri'); ok(valid('/uri', 'http://www.example.org/urii'), 'uri prefix'); ok(!valid('/uri', 'http://www.example.org/uRi'), 'uri case');