annotate proxy_ssl.t @ 1585:bff287fbf347

Tests: added proxy_cookie_domain/path tests with "off" parameter.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 23 Jul 2020 12:17:39 +0300
parents 5a55da6aed13
children ebc6e5afe597
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Nginx, Inc.
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5 # Tests for proxy to ssl backend.
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7 ###############################################################################
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9 use warnings;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use strict;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12 use Test::More;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16 use lib 'lib';
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use Test::Nginx;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19 ###############################################################################
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 select STDERR; $| = 1;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDOUT; $| = 1;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
24 eval { require IO::Socket::SSL; };
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
25 plan(skip_all => 'IO::Socket::SSL not installed') if $@;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
26
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27 my $t = Test::Nginx->new()->has(qw/http proxy http_ssl/)->has_daemon('openssl')
1523
5a55da6aed13 Tests: extended proxy_ssl.t for more ngx_ssl_recv_chain() cases.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1488
diff changeset
28 ->plan(8)->write_file_expand('nginx.conf', <<'EOF');
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 %%TEST_GLOBALS%%
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 daemon off;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 events {
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 http {
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 %%TEST_GLOBALS_HTTP%%
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
41 listen 127.0.0.1:8081 ssl;
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 ssl_certificate_key localhost.key;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 ssl_certificate localhost.crt;
437
8b4a6b8691eb Tests: set ssl_session_cache.
Sergey Kandaurov <pluknet@nginx.com>
parents: 435
diff changeset
45 ssl_session_cache builtin;
435
a7d04159e52b Tests: completed proxy_ssl_session_reuse tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 311
diff changeset
46
a7d04159e52b Tests: completed proxy_ssl_session_reuse tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 311
diff changeset
47 location / {
a7d04159e52b Tests: completed proxy_ssl_session_reuse tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 311
diff changeset
48 add_header X-Session $ssl_session_reused;
a7d04159e52b Tests: completed proxy_ssl_session_reuse tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 311
diff changeset
49 }
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
53 listen 127.0.0.1:8080;
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 server_name localhost;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 location /ssl_reuse {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
57 proxy_pass https://127.0.0.1:8081/;
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 proxy_ssl_session_reuse on;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 location /ssl {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
62 proxy_pass https://127.0.0.1:8081/;
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 proxy_ssl_session_reuse off;
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 }
732
984bfe661cce Tests: stream and http proxy_connect_timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 437
diff changeset
65
984bfe661cce Tests: stream and http proxy_connect_timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 437
diff changeset
66 location /timeout {
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
67 proxy_pass https://127.0.0.1:8082;
1264
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
68 proxy_connect_timeout 3s;
732
984bfe661cce Tests: stream and http proxy_connect_timeout tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 437
diff changeset
69 }
1080
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
70
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
71 location /timeout_h {
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
72 proxy_pass https://127.0.0.1:8083;
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
73 proxy_connect_timeout 1s;
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
74 }
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76 }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 EOF
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 $t->write_file('openssl.conf', <<EOF);
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 [ req ]
1488
dbce8fb5f5f8 Tests: align with OpenSSL security level 2.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1264
diff changeset
82 default_bits = 2048
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 encrypt_key = no
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84 distinguished_name = req_distinguished_name
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 [ req_distinguished_name ]
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 EOF
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87
1523
5a55da6aed13 Tests: extended proxy_ssl.t for more ngx_ssl_recv_chain() cases.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1488
diff changeset
88 $t->write_file('big.html', 'xxxxxxxxxx' x 72000);
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89 $t->write_file('index.html', '');
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
91 my $d = $t->testdir();
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 foreach my $name ('localhost') {
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94 system('openssl req -x509 -new '
1220
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1197
diff changeset
95 . "-config $d/openssl.conf -subj /CN=$name/ "
0af58b78df35 Tests: removed single quotes from system() calls.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1197
diff changeset
96 . "-out $d/$name.crt -keyout $d/$name.key "
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97 . ">>$d/openssl.out 2>&1") == 0
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
98 or die "Can't create certificate for $name: $!\n";
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99 }
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
101 $t->run_daemon(\&http_daemon, port(8082));
1080
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
102 $t->run_daemon(\&http_daemon, port(8083));
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103 $t->run();
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
104 $t->waitforsocket('127.0.0.1:' . port(8082));
1080
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
105 $t->waitforsocket('127.0.0.1:' . port(8083));
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107 ###############################################################################
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108
435
a7d04159e52b Tests: completed proxy_ssl_session_reuse tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 311
diff changeset
109 like(http_get('/ssl'), qr/200 OK.*X-Session: \./s, 'ssl');
a7d04159e52b Tests: completed proxy_ssl_session_reuse tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 311
diff changeset
110 like(http_get('/ssl'), qr/200 OK.*X-Session: \./s, 'ssl 2');
1196
68c8f2778c50 Tests: consistent proxy ssl test names.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
111 like(http_get('/ssl_reuse'), qr/200 OK.*X-Session: \./s, 'ssl session new');
68c8f2778c50 Tests: consistent proxy ssl test names.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1116
diff changeset
112 like(http_get('/ssl_reuse'), qr/200 OK.*X-Session: r/s, 'ssl session reused');
1197
155573499f20 Tests: more ssl session tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1196
diff changeset
113 like(http_get('/ssl_reuse'), qr/200 OK.*X-Session: r/s, 'ssl session reused 2');
1264
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
114
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
115 SKIP: {
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
116 skip 'long test', 1 unless $ENV{TEST_NGINX_UNSAFE};
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
117
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
118 like(http_get('/timeout'), qr/200 OK/, 'proxy connect timeout');
1264
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
119
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
120 }
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
121
1080
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
122 like(http_get('/timeout_h'), qr/504 Gateway/, 'proxy handshake timeout');
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
123
1523
5a55da6aed13 Tests: extended proxy_ssl.t for more ngx_ssl_recv_chain() cases.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1488
diff changeset
124 is(length(Test::Nginx::http_content(http_get('/ssl/big.html'))), 720000,
5a55da6aed13 Tests: extended proxy_ssl.t for more ngx_ssl_recv_chain() cases.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1488
diff changeset
125 'big length');
5a55da6aed13 Tests: extended proxy_ssl.t for more ngx_ssl_recv_chain() cases.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1488
diff changeset
126
311
ad164c14058a Tests: basic proxy tests to ssl backend.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127 ###############################################################################
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
128
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
129 sub http_daemon {
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
130 my ($port) = @_;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
131 my $server = IO::Socket::INET->new(
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
132 Proto => 'tcp',
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
133 LocalHost => '127.0.0.1:' . $port,
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
134 Listen => 5,
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
135 Reuse => 1
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
136 )
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
137 or die "Can't create listening socket: $!\n";
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
138
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
139 local $SIG{PIPE} = 'IGNORE';
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
140
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
141 while (my $client = $server->accept()) {
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
142 $client->autoflush(1);
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
143
1080
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
144 if ($port == port(8083)) {
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
145 sleep 3;
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
146
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
147 close $client;
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
148 next;
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
149 }
cd4395a68fc6 Tests: proxy ssl test with handshake timeout (ticket #1126).
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1079
diff changeset
150
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
151 my $headers = '';
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
152 my $uri = '';
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
153
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
154 # would fail on waitforsocket
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
155
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
156 eval {
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
157 IO::Socket::SSL->start_SSL($client,
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
158 SSL_server => 1,
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
159 SSL_cert_file => "$d/localhost.crt",
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
160 SSL_key_file => "$d/localhost.key",
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
161 SSL_error_trap => sub { die $_[1] }
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
162 );
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
163 };
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
164 next if $@;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
165
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
166 while (<$client>) {
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
167 $headers .= $_;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
168 last if (/^\x0d?\x0a?$/);
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
169 }
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
170
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
171 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
172 next if $uri eq '';
1084
ce3d15edbf05 Tests: whitespace fix.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1080
diff changeset
173
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
174 if ($uri eq '/timeout') {
1264
eb727c5ccef6 Tests: adjust proxy_ssl.t connect timeout test and mark it unsafe.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1251
diff changeset
175 sleep 4;
1079
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
176
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
177 print $client <<EOF;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
178 HTTP/1.1 200 OK
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
179 Connection: close
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
180
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
181 EOF
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
182 }
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
183
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
184 close $client;
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
185 }
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
186 }
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
187
cbc8641a204e Tests: fixed "proxy connect timeout" http tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
188 ###############################################################################