Mercurial > hg > nginx-tests
comparison index.t @ 1528:f0a9f5fecc8f
Tests: various index module error cases.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 29 Oct 2019 20:37:58 +0300 |
parents | 261f01ee5364 |
children | ef7de70a9d3f |
comparison
equal
deleted
inserted
replaced
1527:7676944968c1 | 1528:f0a9f5fecc8f |
---|---|
20 ############################################################################### | 20 ############################################################################### |
21 | 21 |
22 select STDERR; $| = 1; | 22 select STDERR; $| = 1; |
23 select STDOUT; $| = 1; | 23 select STDOUT; $| = 1; |
24 | 24 |
25 my $t = Test::Nginx->new()->has(qw/http/)->plan(8) | 25 my $t = Test::Nginx->new()->has(qw/http/)->plan(14) |
26 ->write_file_expand('nginx.conf', <<'EOF'); | 26 ->write_file_expand('nginx.conf', <<'EOF'); |
27 | 27 |
28 %%TEST_GLOBALS%% | 28 %%TEST_GLOBALS%% |
29 | 29 |
30 daemon off; | 30 daemon off; |
75 } | 75 } |
76 | 76 |
77 location /var_redirect/ { | 77 location /var_redirect/ { |
78 index /$server_name.html; | 78 index /$server_name.html; |
79 } | 79 } |
80 | |
81 location /not_found/ { | |
82 error_log %%TESTDIR%%/log_not_found.log; | |
83 | |
84 location /not_found/off/ { | |
85 error_log %%TESTDIR%%/off.log; | |
86 log_not_found off; | |
87 } | |
88 } | |
80 } | 89 } |
81 } | 90 } |
82 | 91 |
83 EOF | 92 EOF |
84 | 93 |
85 $t->write_file('index.html', 'body'); | 94 $t->write_file('index.html', 'body'); |
86 $t->write_file('many.html', 'manybody'); | 95 $t->write_file('many.html', 'manybody'); |
87 $t->write_file('re.html', 'rebody'); | 96 $t->write_file('re.html', 'rebody'); |
88 $t->write_file('localhost.html', 'varbody'); | 97 $t->write_file('localhost.html', 'varbody'); |
98 | |
99 my $d = $t->testdir(); | |
100 mkdir("$d/forbidden"); | |
101 chmod(0000, "$d/forbidden"); | |
89 | 102 |
90 $t->run(); | 103 $t->run(); |
91 | 104 |
92 ############################################################################### | 105 ############################################################################### |
93 | 106 |
99 like(http_get('/var/'), qr/X-URI: \/var\/localhost.html.*varbody/ms, 'var'); | 112 like(http_get('/var/'), qr/X-URI: \/var\/localhost.html.*varbody/ms, 'var'); |
100 like(http_get('/va2/'), qr/X-URI: \/va2\/localhost.html.*varbody/ms, 'var 2'); | 113 like(http_get('/va2/'), qr/X-URI: \/va2\/localhost.html.*varbody/ms, 'var 2'); |
101 like(http_get('/var_redirect/'), qr/X-URI: \/localhost.html.*varbody/ms, | 114 like(http_get('/var_redirect/'), qr/X-URI: \/localhost.html.*varbody/ms, |
102 'var with redirect'); | 115 'var with redirect'); |
103 | 116 |
117 like(http_get('/not_found/'), qr/404 Not Found/, 'not found'); | |
118 like(http_get('/not_found/off/'), qr/404 Not Found/, 'not found log off'); | |
119 like(http_get('/forbidden/'), qr/403 Forbidden/, 'directory access denied'); | |
120 like(http_get('/index.html/'), qr/404 Not Found/, 'not a directory'); | |
121 | |
122 $t->stop(); | |
123 | |
124 like($t->read_file('log_not_found.log'), qr/error/, 'log_not_found'); | |
125 unlike($t->read_file('off.log'), qr/error/, 'log_not_found off'); | |
126 | |
104 ############################################################################### | 127 ############################################################################### |