# HG changeset patch # User Andrey Zelenkov # Date 1479725683 -10800 # Node ID cd4395a68fc66cd434eaee6cbff727481229af7f # Parent cbc8641a204ed12fd6f85e4bf3865fd2ecd1c717 Tests: proxy ssl test with handshake timeout (ticket #1126). diff --git a/proxy_ssl.t b/proxy_ssl.t --- 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 = '';