# HG changeset patch # User Sergey Kandaurov # Date 1572370678 -10800 # Node ID f0a9f5fecc8f42b96ed6d369b992f5a63dcb52e0 # Parent 7676944968c1007e1e2145155b0937ce43ce0a99 Tests: various index module error cases. diff --git a/index.t b/index.t --- 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'); + ###############################################################################