annotate access_log_escape.t @ 1260:eadd24ccfda1

Tests: postponed startup in certain ssl certificate tests on win32. At least, some win32 hosts exhibit a round-off error or some such in the notBefore field of the certificate generated before starting nginx, such that it can be set to the value one second ahead of the current time. This manifests in spurious test failures due to certificate verify error with a failure reason "certificate is not yet valid".
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 12 Dec 2017 12:53:53 +0300
parents 766bcbb632ee
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1097
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for access_log with escape parameter.
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 ###############################################################################
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDERR; $| = 1;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDOUT; $| = 1;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25 my $t = Test::Nginx->new()->has(qw/http/)->plan(2)
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 ->write_file_expand('nginx.conf', <<'EOF');
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 %%TEST_GLOBALS%%
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 daemon off;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 events {
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 }
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 http {
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 %%TEST_GLOBALS_HTTP%%
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 log_format json escape=json $arg_a$arg_b$arg_c;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39 log_format default escape=default $arg_a$arg_b$arg_c;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 server {
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 listen 127.0.0.1:8080;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 server_name localhost;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 access_log %%TESTDIR%%/json.log json;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 access_log %%TESTDIR%%/test.log default;
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 }
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 }
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 EOF
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 $t->run();
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 ###############################################################################
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 http_get('/?a="1 \\ ' . pack("n", 0x1b1c) . ' "&c=2');
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 $t->stop();
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 is($t->read_file('json.log'), '\"1 \\\\ \u001B\u001C \"2' . "\n", 'json');
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 is($t->read_file('test.log'), '\x221 \x5C \x1B\x1C \x22-2' . "\n", 'default');
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62
a5f9c878c3ab Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 ###############################################################################