[PATCH 2 of 2] Access log: Support for disabling escaping [Tests]

Johannes Baiter Johannes.Baiter at bsb-muenchen.de
Thu Feb 22 16:08:12 UTC 2018


These are the tests for the new "none" escaping option for the "escape"
parameter in the "log_format" directory.

# HG changeset patch
# User Johannes Baiter <johannes.baiter at bsb-muenchen.de>
# Date 1519314253 -3600
#      Thu Feb 22 16:44:13 2018 +0100
# Node ID 17a622c0d6becdfc60ee24ee80c92d324941208a
# Parent  5ac4aae1a740d165d01b44e8f61c12ee8de967f0
Tests: Update access log escaping tests for 'none' escaping

diff -r 5ac4aae1a740 -r 17a622c0d6be access_log_escape.t
--- a/access_log_escape.t	Wed Feb 21 20:32:07 2018 +0300
+++ b/access_log_escape.t	Thu Feb 22 16:44:13 2018 +0100
@@ -22,7 +22,7 @@
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http/)->plan(2)
+my $t = Test::Nginx->new()->has(qw/http/)->plan(3)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -35,6 +35,7 @@
 http {
     %%TEST_GLOBALS_HTTP%%
 
+    log_format none     escape=none     $arg_a$arg_b$arg_c;
     log_format json     escape=json     $arg_a$arg_b$arg_c;
     log_format default  escape=default  $arg_a$arg_b$arg_c;
 
@@ -42,6 +43,7 @@
         listen       127.0.0.1:8080;
         server_name  localhost;
 
+        access_log %%TESTDIR%%/none.log none;
         access_log %%TESTDIR%%/json.log json;
         access_log %%TESTDIR%%/test.log default;
     }
@@ -57,6 +59,7 @@
 
 $t->stop();
 
+is($t->read_file('none.log'), '"1 \\ ' . pack("n", 0x1b1c) . ' "2' .
"\n", 'none');
 is($t->read_file('json.log'), '\"1 \\\\ \u001B\u001C \"2' . "\n",
'json');
 is($t->read_file('test.log'), '\x221 \x5C \x1B\x1C \x22-2' . "\n",
'default');
 
diff -r 5ac4aae1a740 -r 17a622c0d6be stream_access_log_escape.t
--- a/stream_access_log_escape.t	Wed Feb 21 20:32:07 2018 +0300
+++ b/stream_access_log_escape.t	Thu Feb 22 16:44:13 2018 +0100
@@ -40,6 +40,7 @@
         default "foo";
     }
 
+    log_format none     escape=none     $a$b$upstream_addr;
     log_format json     escape=json     $a$b$upstream_addr;
     log_format default  escape=default  $a$b$upstream_addr;
 
@@ -47,6 +48,7 @@
         listen       127.0.0.1:8080;
         return       ok;
 
+        access_log %%TESTDIR%%/none.log none;
         access_log %%TESTDIR%%/json.log json;
         access_log %%TESTDIR%%/test.log default;
     }
@@ -54,7 +56,7 @@
 
 EOF
 
-$t->run()->plan(2);
+$t->run()->plan(3);
 

###############################################################################
 
@@ -62,6 +64,7 @@
 
 $t->stop();
 
+is($t->read_file('none.log'), '" \\ "foo' . "\n", 'none');
 is($t->read_file('json.log'), '\" \\\\ \"foo' . "\n", 'json');
 is($t->read_file('test.log'), '\x22 \x5C \x22foo-' . "\n",
'default');
 



More information about the nginx-devel mailing list