Mercurial > hg > nginx-tests
annotate proxy_ssl_name.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | dbce8fb5f5f8 |
children |
rev | line source |
---|---|
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 # Tests for proxy to ssl backend, use of Server Name Indication |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 # (proxy_ssl_name, proxy_ssl_server_name directives). |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 ############################################################################### |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 use warnings; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use strict; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 use Test::More; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 BEGIN { use FindBin; chdir($FindBin::Bin); } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 use lib 'lib'; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 use Test::Nginx; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 ############################################################################### |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_ssl sni proxy/) |
1190
fcd65708672d
Tests: let tests pass on travis-ci VMs with disabled IPv6 loopback.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1172
diff
changeset
|
27 ->has_daemon('openssl') |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 ->write_file_expand('nginx.conf', <<'EOF'); |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 daemon off; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 events { |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 http { |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 upstream backend { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
41 server 127.0.0.1:8081; |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 upstream backend2 { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
45 server 127.0.0.1:8081; |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
49 listen 127.0.0.1:8080; |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 server_name localhost; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 # session reuse is off, as sessions are cached |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 # for a particular upstream, and resumed session |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 # will use server name previously negotiated |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 proxy_ssl_session_reuse off; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 location /1 { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
59 proxy_pass https://127.0.0.1:8081/; |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 proxy_ssl_name 1.example.com; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 proxy_ssl_server_name on; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 location /2 { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
65 proxy_pass https://127.0.0.1:8081/; |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 proxy_ssl_name 2.example.com; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 proxy_ssl_server_name on; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 location /off { |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 proxy_pass https://backend/; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 proxy_ssl_server_name off; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 location /default { |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 proxy_pass https://backend/; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 proxy_ssl_server_name on; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 location /default2 { |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 proxy_pass https://backend2/; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 proxy_ssl_server_name on; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 location /port { |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 proxy_pass https://backend/; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 proxy_ssl_server_name on; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 proxy_ssl_name backend:123; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 location /ip { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
93 proxy_pass https://127.0.0.1:8081/; |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 proxy_ssl_server_name on; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 |
1172
7e81d47faa07
Tests: enabled test with IPv6 in proxy_ssl_name.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
97 location /ip6 { |
7e81d47faa07
Tests: enabled test with IPv6 in proxy_ssl_name.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
98 proxy_pass https://[::1]:%%PORT_8081%%/; |
7e81d47faa07
Tests: enabled test with IPv6 in proxy_ssl_name.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
99 proxy_ssl_server_name on; |
7e81d47faa07
Tests: enabled test with IPv6 in proxy_ssl_name.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
100 } |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
104 listen 127.0.0.1:8081 ssl; |
1172
7e81d47faa07
Tests: enabled test with IPv6 in proxy_ssl_name.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
105 listen [::1]:%%PORT_8081%% ssl; |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 server_name 1.example.com; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 ssl_certificate localhost.crt; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 ssl_certificate_key localhost.key; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 add_header X-Name $ssl_server_name,; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 EOF |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 $t->write_file('openssl.conf', <<EOF); |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 [ req ] |
1488
dbce8fb5f5f8
Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1220
diff
changeset
|
119 default_bits = 2048 |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 encrypt_key = no |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 distinguished_name = req_distinguished_name |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 [ req_distinguished_name ] |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 EOF |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 my $d = $t->testdir(); |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 foreach my $name ('localhost') { |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 system('openssl req -x509 -new ' |
1220
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1190
diff
changeset
|
129 . "-config $d/openssl.conf -subj /commonName=$name/ " |
0af58b78df35
Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1190
diff
changeset
|
130 . "-out $d/$name.crt -keyout $d/$name.key " |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 . ">>$d/openssl.out 2>&1") == 0 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 or die "Can't create certificate for $name: $!\n"; |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 } |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 $t->write_file('index.html', ''); |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 |
1190
fcd65708672d
Tests: let tests pass on travis-ci VMs with disabled IPv6 loopback.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1172
diff
changeset
|
137 $t->try_run('no inet6 support')->plan(9); |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 ############################################################################### |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 like(http_get('/1'), qr/200 OK.*X-Name: 1.example.com,/ms, 'name 1'); |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 like(http_get('/2'), qr/200 OK.*X-Name: 2.example.com,/ms, 'name 2'); |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 like(http_get('/off'), qr/200 OK.*X-Name: ,/ms, 'no name'); |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 like(http_get('/default'), qr/200 OK.*X-Name: backend,/ms, 'default'); |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 like(http_get('/default2'), qr/200 OK.*X-Name: backend2,/ms, 'default2'); |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 like(http_get('/default'), qr/200 OK.*X-Name: backend,/ms, 'default again'); |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 like(http_get('/port'), qr/200 OK.*X-Name: backend,/ms, 'no port in name'); |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 like(http_get('/ip'), qr/200 OK.*X-Name: ,/ms, 'no ip'); |
1172
7e81d47faa07
Tests: enabled test with IPv6 in proxy_ssl_name.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
151 like(http_get('/ip6'), qr/200 OK.*X-Name: ,/ms, 'no ipv6'); |
393
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 |
3c9aeeb09ac8
Tests: proxy_ssl_name and proxy_ssl_verify tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 ############################################################################### |