Mercurial > hg > nginx-tests
comparison ssi.t @ 367:0726521e42f3
Tests: added tests for escaped and unsafe URIs.
This covers problems in DAV, SSI, X-Accel-Redirect fixed in 1.5.9.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 25 Dec 2013 12:03:40 +0400 |
parents | 6a0d934950bc |
children | 4ac3588485f5 |
comparison
equal
deleted
inserted
replaced
366:77c301be6c2d | 367:0726521e42f3 |
---|---|
21 select STDERR; $| = 1; | 21 select STDERR; $| = 1; |
22 select STDOUT; $| = 1; | 22 select STDOUT; $| = 1; |
23 | 23 |
24 plan(skip_all => 'win32') if $^O eq 'MSWin32'; | 24 plan(skip_all => 'win32') if $^O eq 'MSWin32'; |
25 | 25 |
26 my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)->plan(18); | 26 my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)->plan(21); |
27 | 27 |
28 $t->write_file_expand('nginx.conf', <<'EOF'); | 28 $t->write_file_expand('nginx.conf', <<'EOF'); |
29 | 29 |
30 %%TEST_GLOBALS%% | 30 %%TEST_GLOBALS%% |
31 | 31 |
81 'X<!--#include virtual="/local/empty.html" -->X'); | 81 'X<!--#include virtual="/local/empty.html" -->X'); |
82 $t->write_file('test-empty3.html', | 82 $t->write_file('test-empty3.html', |
83 'X<!--#include virtual="/cache/empty.html" -->X'); | 83 'X<!--#include virtual="/cache/empty.html" -->X'); |
84 $t->write_file('empty.html', ''); | 84 $t->write_file('empty.html', ''); |
85 | 85 |
86 $t->write_file('unescape.html?', 'SEE-THIS'); | |
87 $t->write_file('unescape1.html', | |
88 'X<!--#include virtual="/tes%741.html?test=test" -->X'); | |
89 $t->write_file('unescape2.html', | |
90 'X<!--#include virtual="/unescape.html%3f" -->X'); | |
91 $t->write_file('unescape3.html', | |
92 'X<!--#include virtual="/test1.html%3ftest=test" -->X'); | |
93 | |
86 $t->run(); | 94 $t->run(); |
87 | 95 |
88 ############################################################################### | 96 ############################################################################### |
89 | 97 |
90 like(http_get('/test1.html'), qr/^X\(none\)X$/m, 'echo no argument'); | 98 like(http_get('/test1.html'), qr/^X\(none\)X$/m, 'echo no argument'); |
118 like(http_get('/test-empty1.html'), qr/HTTP/, 'empty with ssi'); | 126 like(http_get('/test-empty1.html'), qr/HTTP/, 'empty with ssi'); |
119 like(http_get('/test-empty2.html'), qr/HTTP/, 'empty without ssi'); | 127 like(http_get('/test-empty2.html'), qr/HTTP/, 'empty without ssi'); |
120 like(http_get('/test-empty3.html'), qr/HTTP/, 'empty with proxy'); | 128 like(http_get('/test-empty3.html'), qr/HTTP/, 'empty with proxy'); |
121 like(http_get('/test-empty3.html'), qr/HTTP/, 'empty with proxy cached'); | 129 like(http_get('/test-empty3.html'), qr/HTTP/, 'empty with proxy cached'); |
122 | 130 |
131 # handling of escaped URIs | |
132 | |
133 like(http_get('/unescape1.html'), qr/^XXtestXX$/m, 'escaped in path'); | |
134 | |
135 TODO: { | |
136 local $TODO = 'not yet' unless $t->has_version('1.5.9'); | |
137 | |
138 like(http_get('/unescape2.html'), qr/^XSEE-THISX$/m, | |
139 'escaped question in path'); | |
140 like(http_get('/unescape3.html'), qr/404 Not Found/, | |
141 'escaped query separator'); | |
142 | |
143 } | |
144 | |
123 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts'); | 145 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts'); |
124 | 146 |
125 ############################################################################### | 147 ############################################################################### |