changeset 327:dacd55fa2cde

Tests: added edge case tests for long hostname in referer.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 29 Aug 2013 19:02:08 +0400
parents a2c15637c9d5
children 290d539efcb4
files referer.t
diffstat 1 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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');