comparison proxy_xar.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 77c301be6c2d
children 847ea345becb
comparison
equal deleted inserted replaced
366:77c301be6c2d 367:0726521e42f3
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 proxy rewrite/)->plan(8); 24 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(14);
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
82 like($r, qr/^Cache-Control: no-cache/m, 'Cache-Control preserved'); 82 like($r, qr/^Cache-Control: no-cache/m, 'Cache-Control preserved');
83 like($r, qr/^Expires: fake/m, 'Expires preserved'); 83 like($r, qr/^Expires: fake/m, 'Expires preserved');
84 like($r, qr/^Accept-Ranges: parrots/m, 'Accept-Ranges preserved'); 84 like($r, qr/^Accept-Ranges: parrots/m, 'Accept-Ranges preserved');
85 unlike($r, qr/^Something/m, 'other headers stripped'); 85 unlike($r, qr/^Something/m, 'other headers stripped');
86 86
87 TODO: {
88 local $TODO = 'escaped characters' unless $t->has_version('1.5.9');
89
90 like(http_get('/proxy?xar=/foo?bar'), qr/200 OK.*xar: \/foo\?bar/s,
91 'X-Accel-Redirect value unchanged');
92 unlike(http_get('/proxy?xar=..'), qr/200 OK/,
93 'X-Accel-Redirect unsafe dotdot');
94 unlike(http_get('/proxy?xar=../foo'), qr/200 OK/,
95 'X-Accel-Redirect unsafe dotdotsep');
96 unlike(http_get('/proxy?xar=/foo/..'), qr/200 OK/,
97 'X-Accel-Redirect unsafe sepdotdot');
98 unlike(http_get('/proxy?xar=/foo/.%2e'), qr/200 OK/,
99 'X-Accel-Redirect unsafe unescaped');
100 like(http_get('/proxy?xar=/foo%20bar'), qr/uri: \/foo bar/,
101 'X-Accel-Redirect unescaped');
102
103 }
104
87 ############################################################################### 105 ###############################################################################