Mercurial > hg > nginx-tests
annotate stream_geo.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | f3ba4c74de31 |
children |
rev | line source |
---|---|
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Sergey Kandaurov |
1013
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
5 # (C) Andrey Zelenkov |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # (C) Nginx, Inc. |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 # Tests for stream geo module. |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 ############################################################################### |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 use warnings; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use strict; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 use Test::More; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 use Test::Nginx::Stream qw/ stream /; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 ############################################################################### |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDERR; $| = 1; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 select STDOUT; $| = 1; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 my $t = Test::Nginx->new()->has(qw/stream stream_return stream_map stream_geo/); |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 $t->write_file_expand('nginx.conf', <<'EOF'); |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 %%TEST_GLOBALS%% |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 daemon off; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 events { |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 } |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 stream { |
1609
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1251
diff
changeset
|
40 %%TEST_GLOBALS_STREAM%% |
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1251
diff
changeset
|
41 |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 geo $geo { |
1012
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
43 127.0.0.0/8 loopback; |
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
44 192.0.2.0/24 test; |
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
45 0.0.0.0/0 world; |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 } |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
1013
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
48 geo $geo_include { |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
49 include geo.conf; |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
50 192.0.2.0/24 test; |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
51 0.0.0.0/0 world; |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
52 } |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
53 |
1014
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
54 geo $geo_delete { |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
55 127.0.0.0/8 loopback; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
56 192.0.2.0/24 test; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
57 0.0.0.0/0 world; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
58 delete 127.0.0.0/8; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
59 } |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
60 |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 geo $remote_addr $geo_from_addr { |
1012
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
62 127.0.0.0/8 loopback; |
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
63 192.0.2.0/24 test; |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 } |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 map $server_port $var { |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 %%PORT_8080%% "192.0.2.1"; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 %%PORT_8081%% "10.0.0.1"; |
1014
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
69 %%PORT_8085%% "10.11.2.1"; |
1015
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
70 %%PORT_8086%% "loopback"; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
71 %%PORT_8087%% "10.13.2.1"; |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 } |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 geo $var $geo_from_var { |
1012
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
75 default default; |
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
76 127.0.0.0/8 loopback; |
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
77 192.0.2.0/24 test; |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 } |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
1014
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
80 geo $var $geo_var_ranges { |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
81 ranges; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
82 default default; |
1015
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
83 127.0.0.0-127.0.0.1 loopback; |
1014
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
84 |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
85 # ranges with two /16 networks |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
86 # the latter network has greater two least octets |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
87 # (see 1301a58b5dac for details) |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
88 10.10.3.0-10.11.2.255 foo; |
1015
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
89 10.12.3.0-10.13.2.255 foo2; |
1014
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
90 delete 10.10.3.0-10.11.2.255; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
91 } |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
92 |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 geo $var $geo_world { |
1012
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
94 127.0.0.0/8 loopback; |
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
95 192.0.2.0/24 test; |
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
96 0.0.0.0/0 world; |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 } |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 geo $geo_ranges { |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 ranges; |
1012
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
101 default default; |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 127.0.0.0-127.255.255.255 loopback; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 192.0.2.0-192.0.2.255 test; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 } |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 |
1013
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
106 geo $geo_ranges_include { |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
107 ranges; |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
108 default default; |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
109 include geo-ranges.conf; |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
110 192.0.2.0-192.0.2.255 test; |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
111 } |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
112 |
1014
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
113 geo $geo_ranges_delete { |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
114 ranges; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
115 default default; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
116 127.0.0.0-127.0.0.255 test; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
117 127.0.0.1-127.0.0.1 loopback; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
118 delete 127.0.0.0-127.0.0.0; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
119 delete 127.0.0.2-127.0.0.255; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
120 delete 127.0.0.1-127.0.0.1; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
121 } |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
122 |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
123 # delete range with two /16 |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
124 geo $geo_ranges_delete_2 { |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
125 ranges; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
126 default default; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
127 127.0.0.0-127.1.0.0 loopback; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
128 delete 127.0.0.0-127.1.0.0; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
129 } |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
130 |
1015
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
131 geo $geo_before { |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
132 ranges; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
133 default default; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
134 127.0.0.1-127.0.0.255 loopback; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
135 127.0.0.0-127.0.0.0 test; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
136 } |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
137 |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
138 geo $geo_after { |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
139 ranges; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
140 default default; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
141 127.0.0.0-127.0.0.1 loopback; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
142 127.0.0.2-127.0.0.255 test; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
143 } |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
144 |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
145 geo $geo_insert { |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
146 ranges; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
147 default default; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
148 127.0.0.0-127.0.0.255 test; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
149 127.0.0.1-127.0.0.2 test2; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
150 127.0.0.1-127.0.0.1 loopback; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
151 } |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
152 |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
153 geo $geo_insert_before { |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
154 ranges; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
155 default default; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
156 127.0.0.0-127.0.0.255 test; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
157 127.0.0.0-127.0.0.1 loopback; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
158 } |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
159 |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
160 geo $geo_insert_after { |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
161 ranges; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
162 default default; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
163 127.0.0.0-127.0.0.255 test; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
164 127.0.0.1-127.0.0.255 loopback; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
165 } |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
166 |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 server { |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 listen 127.0.0.1:8080; |
1011
9b87810c75ca
Tests: simplified variables parsing in stream_geo.t.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
978
diff
changeset
|
169 return "geo:$geo |
1013
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
170 geo_include:$geo_include |
1014
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
171 geo_delete:$geo_delete |
1012
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
172 geo_ranges:$geo_ranges |
1013
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
173 geo_ranges_include:$geo_ranges_include |
1015
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
174 geo_before:$geo_before |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
175 geo_after:$geo_after |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
176 geo_insert:$geo_insert |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
177 geo_insert_before:$geo_insert_before |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
178 geo_insert_after:$geo_insert_after |
1011
9b87810c75ca
Tests: simplified variables parsing in stream_geo.t.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
978
diff
changeset
|
179 geo_from_addr:$geo_from_addr |
1012
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
180 geo_from_var:$geo_from_var"; |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 } |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 server { |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 listen 127.0.0.1:8081; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 return $geo_from_var; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 } |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 server { |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 listen 127.0.0.1:8082; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 return $geo_world; |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 } |
1014
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
192 |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
193 server { |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
194 listen 127.0.0.1:8083; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
195 return $geo_ranges_delete; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
196 } |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
197 |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
198 server { |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
199 listen 127.0.0.1:8084; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
200 return $geo_ranges_delete_2; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
201 } |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
202 |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
203 server { |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
204 listen 127.0.0.1:8085; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
205 return $geo_var_ranges; |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
206 } |
1015
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
207 |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
208 server { |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
209 listen 127.0.0.1:8086; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
210 return $geo_var_ranges; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
211 } |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
212 |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
213 server { |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
214 listen 127.0.0.1:8087; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
215 return $geo_var_ranges; |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
216 } |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
217 } |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
218 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
219 EOF |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
220 |
1013
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
221 $t->write_file('geo.conf', '127.0.0.0/8 loopback;'); |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
222 $t->write_file('geo-ranges.conf', '127.0.0.0-127.255.255.255 loopback;'); |
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
223 |
1251
766bcbb632ee
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1235
diff
changeset
|
224 $t->run()->plan(19); |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
225 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
226 ############################################################################### |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
227 |
1235
3fc6817cd84a
Tests: explicit peer port in stream tests now required.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1044
diff
changeset
|
228 my %data = stream('127.0.0.1:' . port(8080))->read() =~ /(\w+):(\w+)/g; |
1011
9b87810c75ca
Tests: simplified variables parsing in stream_geo.t.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
978
diff
changeset
|
229 is($data{geo}, 'loopback', 'geo'); |
1013
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
230 is($data{geo_include}, 'loopback', 'geo include'); |
1014
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
231 is($data{geo_delete}, 'world', 'geo delete'); |
1012
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
232 is($data{geo_ranges}, 'loopback', 'geo ranges'); |
1013
8f92d97cf40e
Tests: geo include tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1012
diff
changeset
|
233 is($data{geo_ranges_include}, 'loopback', 'geo ranges include'); |
1012
a0758fe11465
Tests: style and rearrangements in geo tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1011
diff
changeset
|
234 |
1014
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
235 is(stream('127.0.0.1:' . port(8083))->read(), 'default', 'geo ranges delete'); |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
236 is(stream('127.0.0.1:' . port(8084))->read(), 'default', 'geo ranges delete 2'); |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
237 |
1015
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
238 is($data{geo_before}, 'loopback', 'geo ranges add before'); |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
239 is($data{geo_after}, 'loopback', 'geo ranges add after'); |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
240 is($data{geo_insert}, 'loopback', 'geo ranges insert'); |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
241 is($data{geo_insert_before}, 'loopback', 'geo ranges insert before'); |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
242 is($data{geo_insert_after}, 'loopback', 'geo ranges insert after'); |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
243 |
1011
9b87810c75ca
Tests: simplified variables parsing in stream_geo.t.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
978
diff
changeset
|
244 is($data{geo_from_addr}, 'loopback', 'geo from addr'); |
9b87810c75ca
Tests: simplified variables parsing in stream_geo.t.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
978
diff
changeset
|
245 is($data{geo_from_var}, 'test', 'geo from var'); |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
246 |
1014
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
247 is(stream('127.0.0.1:' . port(8085))->read(), 'default', |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
248 'geo delete range from variable'); |
61fbb879446a
Tests: geo delete tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1013
diff
changeset
|
249 |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
250 is(stream('127.0.0.1:' . port(8081))->read(), 'default', 'geo default'); |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
251 is(stream('127.0.0.1:' . port(8082))->read(), 'world', 'geo world'); |
1015
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
252 is(stream('127.0.0.1:' . port(8086))->read(), 'default', 'geo ranges default'); |
1d205c07ef59
Tests: more geo ranges tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
1014
diff
changeset
|
253 is(stream('127.0.0.1:' . port(8087))->read(), 'foo2', 'geo ranges add'); |
978
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
254 |
04cb1849005a
Tests: basic tests for stream geo module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
255 ############################################################################### |