Mercurial > hg > nginx-tests
comparison access_log_escape.t @ 1097:a5f9c878c3ab
Tests: basic access_log escape tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 16 Dec 2016 17:06:40 +0300 |
parents | |
children | 766bcbb632ee |
comparison
equal
deleted
inserted
replaced
1096:2978c5212045 | 1097:a5f9c878c3ab |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for access_log with escape parameter. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
25 my $t = Test::Nginx->new()->has(qw/http/)->plan(2) | |
26 ->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
30 daemon off; | |
31 | |
32 events { | |
33 } | |
34 | |
35 http { | |
36 %%TEST_GLOBALS_HTTP%% | |
37 | |
38 log_format json escape=json $arg_a$arg_b$arg_c; | |
39 log_format default escape=default $arg_a$arg_b$arg_c; | |
40 | |
41 server { | |
42 listen 127.0.0.1:8080; | |
43 server_name localhost; | |
44 | |
45 access_log %%TESTDIR%%/json.log json; | |
46 access_log %%TESTDIR%%/test.log default; | |
47 } | |
48 } | |
49 | |
50 EOF | |
51 | |
52 $t->run(); | |
53 | |
54 ############################################################################### | |
55 | |
56 http_get('/?a="1 \\ ' . pack("n", 0x1b1c) . ' "&c=2'); | |
57 | |
58 $t->stop(); | |
59 | |
60 TODO: { | |
61 local $TODO = 'not yet' unless $t->has_version('1.11.8'); | |
62 | |
63 is($t->read_file('json.log'), '\"1 \\\\ \u001B\u001C \"2' . "\n", 'json'); | |
64 is($t->read_file('test.log'), '\x221 \x5C \x1B\x1C \x22-2' . "\n", 'default'); | |
65 | |
66 } | |
67 | |
68 ############################################################################### |