Mercurial > hg > nginx-tests
changeset 1528:f0a9f5fecc8f
Tests: various index module error cases.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 29 Oct 2019 20:37:58 +0300 |
parents | 7676944968c1 |
children | ef7de70a9d3f |
files | index.t |
diffstat | 1 files changed, 24 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/index.t +++ b/index.t @@ -22,7 +22,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http/)->plan(8) +my $t = Test::Nginx->new()->has(qw/http/)->plan(14) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -77,6 +77,15 @@ http { location /var_redirect/ { index /$server_name.html; } + + location /not_found/ { + error_log %%TESTDIR%%/log_not_found.log; + + location /not_found/off/ { + error_log %%TESTDIR%%/off.log; + log_not_found off; + } + } } } @@ -87,6 +96,10 @@ EOF $t->write_file('re.html', 'rebody'); $t->write_file('localhost.html', 'varbody'); +my $d = $t->testdir(); +mkdir("$d/forbidden"); +chmod(0000, "$d/forbidden"); + $t->run(); ############################################################################### @@ -101,4 +114,14 @@ like(http_get('/va2/'), qr/X-URI: \/va2\ like(http_get('/var_redirect/'), qr/X-URI: \/localhost.html.*varbody/ms, 'var with redirect'); +like(http_get('/not_found/'), qr/404 Not Found/, 'not found'); +like(http_get('/not_found/off/'), qr/404 Not Found/, 'not found log off'); +like(http_get('/forbidden/'), qr/403 Forbidden/, 'directory access denied'); +like(http_get('/index.html/'), qr/404 Not Found/, 'not a directory'); + +$t->stop(); + +like($t->read_file('log_not_found.log'), qr/error/, 'log_not_found'); +unlike($t->read_file('off.log'), qr/error/, 'log_not_found off'); + ###############################################################################