Mercurial > hg > nginx-tests
annotate map_complex.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 | 766bcbb632ee |
children |
rev | line source |
---|---|
927
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for map module with complex value. |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http map rewrite/); |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF'); |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 map $args $x { |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 var foo:$y; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 var2 $y:foo; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 default foo:$y; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 } |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
928 | 45 map $args $y { |
927
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 default bar; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 same baz; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 } |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
51 listen 127.0.0.1:8080; |
927
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 server_name localhost; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 location / { |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 add_header X-Foo $x; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 return 204; |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 } |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 } |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 } |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 EOF |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
1251
766bcbb632ee
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
63 $t->run()->plan(3); |
927
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 ############################################################################### |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 like(http_get('/?var'), qr/foo:bar/, 'map cv'); |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 like(http_get('/?var2'), qr/bar:foo/, 'map cv 2'); |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 like(http_get('/?same'), qr/foo:baz/, 'map cv key'); |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
6afbb809983b
Tests: map module basic tests with complex value.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 ############################################################################### |