Mercurial > hg > nginx-tests
comparison autoindex.t @ 123:8aa0dd396a83
Tests: add more autoindex tests.
This includes todo tests for bugs with utf-8 handling and html escaping in
file names.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 31 Dec 2009 17:23:06 +0300 |
parents | 8ac1faaddd2c |
children | f10f077a3174 |
comparison
equal
deleted
inserted
replaced
122:01e86a067f05 | 123:8aa0dd396a83 |
---|---|
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 autoindex/)->plan(4) | 24 my $t = Test::Nginx->new()->has(qw/http autoindex/)->plan(15) |
25 ->write_file_expand('nginx.conf', <<'EOF'); | 25 ->write_file_expand('nginx.conf', <<'EOF'); |
26 | 26 |
27 %%TEST_GLOBALS%% | 27 %%TEST_GLOBALS%% |
28 | 28 |
29 master_process off; | 29 master_process off; |
40 server_name localhost; | 40 server_name localhost; |
41 | 41 |
42 location / { | 42 location / { |
43 autoindex on; | 43 autoindex on; |
44 } | 44 } |
45 location /utf8/ { | |
46 autoindex on; | |
47 charset utf-8; | |
48 } | |
45 } | 49 } |
46 } | 50 } |
47 | 51 |
48 EOF | 52 EOF |
49 | 53 |
53 symlink("$d/test-dir", "$d/test-dir-link"); | 57 symlink("$d/test-dir", "$d/test-dir-link"); |
54 | 58 |
55 $t->write_file('test-file', ''); | 59 $t->write_file('test-file', ''); |
56 symlink("$d/test-file", "$d/test-file-link"); | 60 symlink("$d/test-file", "$d/test-file-link"); |
57 | 61 |
62 $t->write_file('test-colon:blah', ''); | |
63 $t->write_file('test-long-' . ('0' x 50), ''); | |
64 $t->write_file('test-long-' . ('>' x 50), ''); | |
65 $t->write_file('test-escape-url-%', ''); | |
66 $t->write_file('test-escape-html-<>&', ''); | |
67 | |
68 mkdir($d . '/utf8'); | |
69 $t->write_file('utf8/test-utf8-' . ("\xd1\x84" x 3), ''); | |
70 $t->write_file('utf8/test-utf8-' . ("\xd1\x84" x 45), ''); | |
71 $t->write_file('utf8/test-utf8-<>&-' . "\xd1\x84", ''); | |
72 $t->write_file('utf8/test-utf8-<>&-' . ("\xd1\x84" x 45), ''); | |
73 $t->write_file('utf8/test-utf8-' . ("\xd1\x84" x 3) . '-' . ('>' x 45), ''); | |
74 | |
75 mkdir($d . '/test-dir-escape-<>&'); | |
76 | |
58 $t->run(); | 77 $t->run(); |
59 | 78 |
60 ############################################################################### | 79 ############################################################################### |
61 | 80 |
62 my $r = http_get('/'); | 81 my $r = http_get('/'); |
64 like($r, qr!href="test-file"!ms, 'file'); | 83 like($r, qr!href="test-file"!ms, 'file'); |
65 like($r, qr!href="test-file-link"!ms, 'symlink to file'); | 84 like($r, qr!href="test-file-link"!ms, 'symlink to file'); |
66 like($r, qr!href="test-dir/"!ms, 'directory'); | 85 like($r, qr!href="test-dir/"!ms, 'directory'); |
67 like($r, qr!href="test-dir-link/"!ms, 'symlink to directory'); | 86 like($r, qr!href="test-dir-link/"!ms, 'symlink to directory'); |
68 | 87 |
88 like($r, qr!href="./test-colon:blah"!ms, 'colon not scheme'); | |
89 like($r, qr!test-long-0{37}\.\.>!ms, 'long name'); | |
90 | |
91 like($r, qr!href="test-escape-url-%25"!ms, 'escaped url'); | |
92 | |
93 { | |
94 local $TODO = 'patches under review'; | |
95 | |
96 like($r, qr!test-escape-html-<>&!ms, 'escaped html'); | |
97 like($r, qr!test-long-(>){37}\.\.>!ms, 'long escaped html'); | |
98 | |
99 $r = http_get('/utf8/'); | |
100 | |
101 like($r, qr!test-utf8-(\xd1\x84){3}</a>!ms, 'utf8'); | |
102 like($r, qr!test-utf8-(\xd1\x84){37}\.\.!ms, 'utf8 long'); | |
103 like($r, qr!test-utf8-<>&-\xd1\x84</a>!ms, 'utf8 escaped'); | |
104 like($r, qr!test-utf8-<>&-(\xd1\x84){33}\.\.!ms, | |
105 'utf8 escaped long'); | |
106 like($r, qr!test-utf8-(\xd1\x84){3}-(>){33}\.\.!ms, 'utf8 long escaped'); | |
107 | |
108 like(http_get('/test-dir-escape-<>&/'), qr!test-dir-escape-<>&!ms, | |
109 'escaped title'); | |
110 | |
111 } | |
112 | |
69 ############################################################################### | 113 ############################################################################### |