annotate proxy_bind_transparent.t @ 915:1ffb16747167

Tests: proxy_bind transparent tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Sat, 23 Apr 2016 11:03:54 +0300
parents
children 6af0421615ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
915
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for http proxy_bind transparent.
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 ###############################################################################
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDERR; $| = 1;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDOUT; $| = 1;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25 plan(skip_all => 'win32') if $^O eq 'MSWin32';
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 plan(skip_all => '127.0.0.2 local address required')
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27 unless defined IO::Socket::INET->new( LocalAddr => '127.0.0.2' );
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 my $t = Test::Nginx->new()->has(qw/http proxy/)
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 ->write_file_expand('nginx.conf', <<'EOF');
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 %%TEST_GLOBALS%%
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 daemon off;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 events {
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 }
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39 http {
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 %%TEST_GLOBALS_HTTP%%
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 server {
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 listen 127.0.0.1:8080;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 server_name localhost;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 location / {
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 proxy_bind 127.0.0.2 transparent;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 proxy_pass http://127.0.0.1:8081/;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 }
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 }
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 server {
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 listen 127.0.0.1:8081;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 server_name localhost;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 location / {
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 add_header X-IP $remote_addr;
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 }
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 }
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 }
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 EOF
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 $t->write_file('index.html', '');
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 $t->try_run('no proxy_bind transparent')->plan(1);
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 ###############################################################################
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 like(http_get('/'), qr/X-IP: 127.0.0.2/, 'transparent');
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70
1ffb16747167 Tests: proxy_bind transparent tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 ###############################################################################