annotate stream_access_log_none.t @ 1571:1b4ceab9cb1c

Tests: fixed ssl_certificate.t with LibreSSL client. Net::SSLeay::connect() that manages TLS handshake could return unexpected error when receiving server alert, as seen in server certificate tests if it could not been selected. Typically, it returns the expected error -1, but with certain libssl implementations it can be 0, as explained below. The error is propagated from libssl's SSL_connect(), which is usually -1. In modern OpenSSL versions, it is the default error code used in the state machine returned when something went wrong with parsing TLS message header. In versions up to OpenSSL 1.0.2, with SSLv23_method() used by default, -1 is the only error code in the ssl_connect() method implementation which is used as well if receiving alert while parsing ServerHello. BoringSSL also seems to return -1. But it is not so with LibreSSL that returns zero. Previously, tests failed with client built with LibreSSL with SSLv3 removed. Here, the error is propagated directly from ssl_read_bytes() method, which is always implemented as ssl3_read_bytes() in all TLS methods. It could be also seen with OpenSSL up to 1.0.2 with non-default methods explicitly set.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 29 May 2020 23:10:20 +0300
parents 97c8280de681
children f3ba4c74de31
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1296
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Stream tests for access_log with escape parameter.
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 ###############################################################################
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDERR; $| = 1;
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDOUT; $| = 1;
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
1381
97c8280de681 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1296
diff changeset
25 my $t = Test::Nginx->new()->has(qw/stream stream_map stream_return/)->plan(1)
1296
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 ->write_file_expand('nginx.conf', <<'EOF');
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 %%TEST_GLOBALS%%
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 daemon off;
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 events {
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 }
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 stream {
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 map $pid $a {
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 default '" \ "';
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 }
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39 map $pid $b {
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 default "foo";
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 }
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 log_format none escape=none $a$b$upstream_addr;
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 server {
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 listen 127.0.0.1:8080;
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 return ok;
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 access_log %%TESTDIR%%/none.log none;
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 }
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 }
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 EOF
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54
1381
97c8280de681 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1296
diff changeset
55 $t->run();
1296
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 ###############################################################################
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 http_get('/');
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 $t->stop();
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 is($t->read_file('none.log'), '" \\ "foo' . "\n", 'none');
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64
5d75938b2622 Tests: basic access_log tests with log_format 'escape=none'.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 ###############################################################################