comparison proxy_ssl.t @ 1080:cd4395a68fc6

Tests: proxy ssl test with handshake timeout (ticket #1126).
author Andrey Zelenkov <zelenkov@nginx.com>
date Mon, 21 Nov 2016 13:54:43 +0300
parents cbc8641a204e
children ce3d15edbf05
comparison
equal deleted inserted replaced
1079:cbc8641a204e 1080:cd4395a68fc6
23 23
24 eval { require IO::Socket::SSL; }; 24 eval { require IO::Socket::SSL; };
25 plan(skip_all => 'IO::Socket::SSL not installed') if $@; 25 plan(skip_all => 'IO::Socket::SSL not installed') if $@;
26 26
27 my $t = Test::Nginx->new()->has(qw/http proxy http_ssl/)->has_daemon('openssl') 27 my $t = Test::Nginx->new()->has(qw/http proxy http_ssl/)->has_daemon('openssl')
28 ->plan(5)->write_file_expand('nginx.conf', <<'EOF'); 28 ->plan(6)->write_file_expand('nginx.conf', <<'EOF');
29 29
30 %%TEST_GLOBALS%% 30 %%TEST_GLOBALS%%
31 31
32 daemon off; 32 daemon off;
33 33
65 65
66 location /timeout { 66 location /timeout {
67 proxy_pass https://127.0.0.1:8082; 67 proxy_pass https://127.0.0.1:8082;
68 proxy_connect_timeout 2s; 68 proxy_connect_timeout 2s;
69 } 69 }
70
71 location /timeout_h {
72 proxy_pass https://127.0.0.1:8083;
73 proxy_connect_timeout 1s;
74 }
70 } 75 }
71 } 76 }
72 77
73 EOF 78 EOF
74 79
91 . ">>$d/openssl.out 2>&1") == 0 96 . ">>$d/openssl.out 2>&1") == 0
92 or die "Can't create certificate for $name: $!\n"; 97 or die "Can't create certificate for $name: $!\n";
93 } 98 }
94 99
95 $t->run_daemon(\&http_daemon, port(8082)); 100 $t->run_daemon(\&http_daemon, port(8082));
101 $t->run_daemon(\&http_daemon, port(8083));
96 $t->run(); 102 $t->run();
97 $t->waitforsocket('127.0.0.1:' . port(8082)); 103 $t->waitforsocket('127.0.0.1:' . port(8082));
104 $t->waitforsocket('127.0.0.1:' . port(8083));
98 105
99 ############################################################################### 106 ###############################################################################
100 107
101 like(http_get('/ssl'), qr/200 OK.*X-Session: \./s, 'ssl'); 108 like(http_get('/ssl'), qr/200 OK.*X-Session: \./s, 'ssl');
102 like(http_get('/ssl'), qr/200 OK.*X-Session: \./s, 'ssl 2'); 109 like(http_get('/ssl'), qr/200 OK.*X-Session: \./s, 'ssl 2');
103 like(http_get('/ssl_reuse'), qr/200 OK.*X-Session: \./s, 'ssl reuse session'); 110 like(http_get('/ssl_reuse'), qr/200 OK.*X-Session: \./s, 'ssl reuse session');
104 like(http_get('/ssl_reuse'), qr/200 OK.*X-Session: r/s, 'ssl reuse session 2'); 111 like(http_get('/ssl_reuse'), qr/200 OK.*X-Session: r/s, 'ssl reuse session 2');
105 like(http_get('/timeout'), qr/200 OK/, 'proxy connect timeout'); 112 like(http_get('/timeout'), qr/200 OK/, 'proxy connect timeout');
113
114 TODO: {
115 local $TODO = 'not yet' unless $t->has_version('1.11.6');
116
117 like(http_get('/timeout_h'), qr/504 Gateway/, 'proxy handshake timeout');
118
119 }
106 120
107 ############################################################################### 121 ###############################################################################
108 122
109 sub http_daemon { 123 sub http_daemon {
110 my ($port) = @_; 124 my ($port) = @_;
118 132
119 local $SIG{PIPE} = 'IGNORE'; 133 local $SIG{PIPE} = 'IGNORE';
120 134
121 while (my $client = $server->accept()) { 135 while (my $client = $server->accept()) {
122 $client->autoflush(1); 136 $client->autoflush(1);
137
138 if ($port == port(8083)) {
139 sleep 3;
140
141 close $client;
142 next;
143 }
123 144
124 my $headers = ''; 145 my $headers = '';
125 my $uri = ''; 146 my $uri = '';
126 147
127 # would fail on waitforsocket 148 # would fail on waitforsocket