# HG changeset patch # User Sergey Kandaurov # Date 1449676841 -10800 # Node ID eca9b1d190219b1bf3c9ba01c37b708351b768f4 # Parent d95c4b8e5517783f57976cbb1e336cb52c7a62e7 Tests: tests for host expansion to an explicit upstream. diff --git a/fastcgi.t b/fastcgi.t --- a/fastcgi.t +++ b/fastcgi.t @@ -25,7 +25,7 @@ eval { require FCGI; }; plan(skip_all => 'FCGI not installed') if $@; plan(skip_all => 'win32') if $^O eq 'MSWin32'; -my $t = Test::Nginx->new()->has(qw/http fastcgi/)->plan(6) +my $t = Test::Nginx->new()->has(qw/http fastcgi/)->plan(7) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -38,6 +38,10 @@ events { http { %%TEST_GLOBALS_HTTP%% + upstream u { + server 127.0.0.1:8081; + } + server { listen 127.0.0.1:8080; server_name localhost; @@ -70,6 +74,7 @@ unlike(http_head('/'), qr/SEE-THIS/, 'no like(http_get('/stderr'), qr/SEE-THIS/, 'large stderr handled'); like(http_get('/var?b=127.0.0.1:8081'), qr/SEE-THIS/, 'fastcgi with variables'); +like(http_get('/var?b=u'), qr/SEE-THIS/, 'fastcgi with variables to upstream'); ############################################################################### diff --git a/proxy.t b/proxy.t --- a/proxy.t +++ b/proxy.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(5); +my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(6); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -35,6 +35,10 @@ events { http { %%TEST_GLOBALS_HTTP%% + upstream u { + server 127.0.0.1:8081; + } + server { listen 127.0.0.1:8080; server_name localhost; @@ -65,6 +69,7 @@ like(http_get('/multi'), qr/AND-THIS/, ' unlike(http_head('/'), qr/SEE-THIS/, 'proxy head request'); like(http_get('/var?b=127.0.0.1:8081/'), qr/SEE-THIS/, 'proxy with variables'); +like(http_get('/var?b=u/'), qr/SEE-THIS/, 'proxy with variables to upstream'); my $s = http('', start => 1); diff --git a/scgi.t b/scgi.t --- a/scgi.t +++ b/scgi.t @@ -24,7 +24,7 @@ select STDOUT; $| = 1; eval { require SCGI; }; plan(skip_all => 'SCGI not installed') if $@; -my $t = Test::Nginx->new()->has(qw/http scgi/)->plan(6) +my $t = Test::Nginx->new()->has(qw/http scgi/)->plan(7) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -37,6 +37,10 @@ events { http { %%TEST_GLOBALS_HTTP%% + upstream u { + server 127.0.0.1:8081; + } + server { listen 127.0.0.1:8080; server_name localhost; @@ -74,6 +78,7 @@ like(http_get_headers('/headers'), qr/SE 'scgi request with many ignored headers'); like(http_get('/var?b=127.0.0.1:8081'), qr/SEE-THIS/, 'scgi with variables'); +like(http_get('/var?b=u'), qr/SEE-THIS/, 'scgi with variables to upstream'); ############################################################################### diff --git a/uwsgi.t b/uwsgi.t --- a/uwsgi.t +++ b/uwsgi.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http uwsgi/)->has_daemon('uwsgi')->plan(4) +my $t = Test::Nginx->new()->has(qw/http uwsgi/)->has_daemon('uwsgi')->plan(5) ->write_file_expand('nginx.conf', <<'EOF'); %%TEST_GLOBALS%% @@ -34,6 +34,10 @@ events { http { %%TEST_GLOBALS_HTTP%% + upstream u { + server 127.0.0.1:8081; + } + server { listen 127.0.0.1:8080; server_name localhost; @@ -87,6 +91,7 @@ like(http_get_headers('/headers'), qr/SE 'uwsgi request with many ignored headers'); like(http_get('/var?b=127.0.0.1:8081'), qr/SEE-THIS/, 'uwsgi with variables'); +like(http_get('/var?b=u'), qr/SEE-THIS/, 'uwsgi with variables to upstream'); ###############################################################################