Mercurial > hg > nginx-tests
diff access_log.t @ 1385:5eb82b417fd6
Tests: access_log escape tests merged.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 10 Oct 2018 19:15:49 +0300 |
parents | 7df2265e61be |
children | 03cf423ea140 |
line wrap: on
line diff
--- a/access_log.t +++ b/access_log.t @@ -1,5 +1,6 @@ #!/usr/bin/perl +# (C) Sergey Kandaurov # (C) Nginx, Inc. # Tests for access_log. @@ -21,7 +22,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http rewrite gzip/)->plan(15) +my $t = Test::Nginx->new()->has(qw/http rewrite gzip/)->plan(18) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -38,6 +39,10 @@ http { log_format long "long line $uri:$status"; log_format binary $binary_remote_addr; + log_format default escape=default $arg_a$arg_b$arg_c; + log_format none escape=none $arg_a$arg_b$arg_c; + log_format json escape=json $arg_a$arg_b$arg_c; + server { listen 127.0.0.1:8080; server_name localhost; @@ -99,6 +104,12 @@ http { location /binary { access_log %%TESTDIR%%/binary.log binary; } + + location /escape { + access_log %%TESTDIR%%/test.log default; + access_log %%TESTDIR%%/none.log none; + access_log %%TESTDIR%%/json.log json; + } } } @@ -146,6 +157,8 @@ http_get('/varlog?logname=filename'); http_get('/binary'); +http_get('/escape?a="1 \\ ' . pack("n", 0x1b1c) . ' "&c=2'); + http_get('/cache?logname=lru'); http_get('/cache?logname=lru'); http_get('/cache?logname=once'); @@ -243,6 +256,15 @@ my $expected = join '', map { sprintf "\ is($t->read_file('binary.log'), "$expected\n", 'binary'); +# characters escaping + +is($t->read_file('test.log'), + '\x221 \x5C \x1B\x1C \x22-2' . "\n", 'escape - default'); +is($t->read_file('none.log'), + '"1 \\ ' . pack("n", 0x1b1c) . " \"2\n", 'escape - none'); +is($t->read_file('json.log'), + '\"1 \\\\ \u001B\u001C \"2' . "\n", 'escape - json'); + SKIP: { skip 'win32', 4 if $^O eq 'MSWin32';