comparison stream_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 # Stream 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/stream stream_map stream_return/)
26 ->write_file_expand('nginx.conf', <<'EOF');
27
28 %%TEST_GLOBALS%%
29
30 daemon off;
31
32 events {
33 }
34
35 stream {
36 map $pid $a {
37 default '" \ "';
38 }
39 map $pid $b {
40 default "foo";
41 }
42
43 log_format json escape=json $a$b$upstream_addr;
44 log_format default escape=default $a$b$upstream_addr;
45
46 server {
47 listen 127.0.0.1:8080;
48 return ok;
49
50 access_log %%TESTDIR%%/json.log json;
51 access_log %%TESTDIR%%/test.log default;
52 }
53 }
54
55 EOF
56
57 $t->try_run('no stream map')->plan(2);
58
59 ###############################################################################
60
61 http_get('/');
62
63 $t->stop();
64
65 TODO: {
66 local $TODO = 'not yet' unless $t->has_version('1.11.8');
67
68 is($t->read_file('json.log'), '\" \\\\ \"foo' . "\n", 'json');
69 is($t->read_file('test.log'), '\x22 \x5C \x22foo-' . "\n", 'default');
70
71 }
72
73 ###############################################################################