changeset 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 cca0bff99733
files proxy_ssl.t
diffstat 1 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/proxy_ssl.t
+++ b/proxy_ssl.t
@@ -25,7 +25,7 @@ eval { require IO::Socket::SSL; };
 plan(skip_all => 'IO::Socket::SSL not installed') if $@;
 
 my $t = Test::Nginx->new()->has(qw/http proxy http_ssl/)->has_daemon('openssl')
-	->plan(5)->write_file_expand('nginx.conf', <<'EOF');
+	->plan(6)->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
 
@@ -67,6 +67,11 @@ http {
             proxy_pass https://127.0.0.1:8082;
             proxy_connect_timeout 2s;
         }
+
+        location /timeout_h {
+            proxy_pass https://127.0.0.1:8083;
+            proxy_connect_timeout 1s;
+        }
     }
 }
 
@@ -93,8 +98,10 @@ foreach my $name ('localhost') {
 }
 
 $t->run_daemon(\&http_daemon, port(8082));
+$t->run_daemon(\&http_daemon, port(8083));
 $t->run();
 $t->waitforsocket('127.0.0.1:' . port(8082));
+$t->waitforsocket('127.0.0.1:' . port(8083));
 
 ###############################################################################
 
@@ -104,6 +111,13 @@ like(http_get('/ssl_reuse'), qr/200 OK.*
 like(http_get('/ssl_reuse'), qr/200 OK.*X-Session: r/s, 'ssl reuse session 2');
 like(http_get('/timeout'), qr/200 OK/, 'proxy connect timeout');
 
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.11.6');
+
+like(http_get('/timeout_h'), qr/504 Gateway/, 'proxy handshake timeout');
+
+}
+
 ###############################################################################
 
 sub http_daemon {
@@ -121,6 +135,13 @@ sub http_daemon {
 	while (my $client = $server->accept()) {
 		$client->autoflush(1);
 
+		if ($port == port(8083)) {
+			sleep 3;
+
+			close $client;
+			next;
+		}
+
 		my $headers = '';
 		my $uri = '';