changeset 953:2bbab9bd73e5

Tests: added proxy_bind test with port.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 21 Jun 2016 18:38:32 +0300
parents e9064d691790
children b9692ec5a08b
files proxy_bind.t
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/proxy_bind.t
+++ b/proxy_bind.t
@@ -26,7 +26,7 @@ plan(skip_all => 'win32') if $^O eq 'MSW
 plan(skip_all => '127.0.0.2 local address required')
 	unless defined IO::Socket::INET->new( LocalAddr => '127.0.0.2' );
 
-my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(4)
+my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(5)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -63,6 +63,12 @@ http {
             proxy_bind  $arg_b;
             proxy_pass  http://127.0.0.1:%%PORT_1%%/;
         }
+
+        location /port {
+            proxy_bind  127.0.0.2:$remote_port;
+            proxy_pass  http://127.0.0.1:%%PORT_1%%/;
+            add_header  X-Client-Port $remote_port;
+        }
     }
 
     server {
@@ -71,6 +77,7 @@ http {
 
         location / {
             add_header   X-IP $remote_addr;
+            add_header   X-Port $remote_port;
         }
     }
 }
@@ -87,4 +94,11 @@ like(http_get('/inherit'), qr/X-IP: 127.
 like(http_get('/off'), qr/X-IP: 127.0.0.1/, 'bind off');
 like(http_get('/var?b=127.0.0.2'), qr/X-IP: 127.0.0.2/, 'bind var');
 
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.11.2');
+
+like(http_get('/port'), qr/Port: (\d+)(?!\d).*Port: \1/s, 'bind port');
+
+}
+
 ###############################################################################