comparison referer.t @ 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 ba212f244288
children 290d539efcb4
comparison
equal deleted inserted replaced
326:a2c15637c9d5 327:dacd55fa2cde
19 ############################################################################### 19 ###############################################################################
20 20
21 select STDERR; $| = 1; 21 select STDERR; $| = 1;
22 select STDOUT; $| = 1; 22 select STDOUT; $| = 1;
23 23
24 my $t = Test::Nginx->new()->has(qw/http referer rewrite/)->plan(51); 24 my $t = Test::Nginx->new()->has(qw/http referer rewrite/)->plan(54);
25 25
26 $t->write_file_expand('nginx.conf', <<'EOF'); 26 $t->write_file_expand('nginx.conf', <<'EOF');
27 27
28 %%TEST_GLOBALS%% 28 %%TEST_GLOBALS%%
29 29
94 valid_referers blocked server_names; 94 valid_referers blocked server_names;
95 return 200 "value $invalid_referer"; 95 return 200 "value $invalid_referer";
96 } 96 }
97 location /wc { 97 location /wc {
98 valid_referers *.example.com *.example.org www.example.* example.*; 98 valid_referers *.example.com *.example.org www.example.* example.*;
99 return 200 "value $invalid_referer";
100 }
101 location /long {
102 valid_referers ~.*;
99 return 200 "value $invalid_referer"; 103 return 200 "value $invalid_referer";
100 } 104 }
101 location /wc2 { 105 location /wc2 {
102 valid_referers www.example.*/uri; 106 valid_referers www.example.*/uri;
103 return 200 "value $invalid_referer"; 107 return 200 "value $invalid_referer";
130 ok(!valid('/simple', 'foobar'), 'small'); 134 ok(!valid('/simple', 'foobar'), 'small');
131 ok(valid('/simple', 'http://www.example.org/' . 'a' x 256), 'long uri'); 135 ok(valid('/simple', 'http://www.example.org/' . 'a' x 256), 'long uri');
132 ok(!valid('/simple', 'http://www.example.' . 'a' x 256), 'long hostname'); 136 ok(!valid('/simple', 'http://www.example.' . 'a' x 256), 'long hostname');
133 ok(!valid('/wc', 'http://example.' . 'a' x 256), 'long hostname wildcard'); 137 ok(!valid('/wc', 'http://example.' . 'a' x 256), 'long hostname wildcard');
134 138
139 ok(valid('/long', 'http://' . 'a' x 255), 'long hostname 255');
140
141 TODO: {
142 local $TODO = 'not yet';
143
144 ok(valid('/long', 'http://' . 'a' x 256), 'long hostname 256');
145
146 }
147
148 ok(!valid('/long', 'http://' . 'a' x 257), 'long hostname 257');
149
135 ok(valid('/uri', 'http://www.example.org/uri'), 'uri'); 150 ok(valid('/uri', 'http://www.example.org/uri'), 'uri');
136 ok(valid('/uri', 'http://www.example.org/urii'), 'uri prefix'); 151 ok(valid('/uri', 'http://www.example.org/urii'), 'uri prefix');
137 ok(!valid('/uri', 'http://www.example.org/uRi'), 'uri case'); 152 ok(!valid('/uri', 'http://www.example.org/uRi'), 'uri case');
138 ok(valid('/uri', 'http://www.example.org:8080/urii'), 'uri port'); 153 ok(valid('/uri', 'http://www.example.org:8080/urii'), 'uri port');
139 ok(!valid('/uri', 'http://www.example.org/ur'), 'uri invalid len'); 154 ok(!valid('/uri', 'http://www.example.org/ur'), 'uri invalid len');