Mercurial > hg > nginx-tests
comparison stream_geo_unix.t @ 1418:f3422a4fe349
Tests: simple geo module tests with unix socket address.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Sun, 16 Dec 2018 13:06:22 +0300 |
parents | |
children | 144c6ce732e4 |
comparison
equal
deleted
inserted
replaced
1417:ea796652fcdc | 1418:f3422a4fe349 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for stream geo module with unix socket. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 use Test::Nginx::Stream qw/ stream /; | |
20 | |
21 ############################################################################### | |
22 | |
23 select STDERR; $| = 1; | |
24 select STDOUT; $| = 1; | |
25 | |
26 my $t = Test::Nginx->new()->has(qw/stream stream_geo stream_return unix/) | |
27 ->plan(4); | |
28 | |
29 $t->write_file_expand('nginx.conf', <<'EOF'); | |
30 | |
31 %%TEST_GLOBALS%% | |
32 | |
33 daemon off; | |
34 | |
35 events { | |
36 } | |
37 | |
38 stream { | |
39 geo $geo { | |
40 default default; | |
41 255.255.255.255 none; | |
42 } | |
43 | |
44 geo $remote_addr $geora { | |
45 default default; | |
46 255.255.255.255 none; | |
47 } | |
48 | |
49 geo $geor { | |
50 ranges; | |
51 0.0.0.0-255.255.255.254 test; | |
52 default none; | |
53 } | |
54 | |
55 geo $remote_addr $georra { | |
56 ranges; | |
57 0.0.0.0-255.255.255.254 test; | |
58 default none; | |
59 } | |
60 | |
61 server { | |
62 listen unix:%%TESTDIR%%/unix.sock; | |
63 return "geo:$geo geora:$geora geor:$geor georra:$georra"; | |
64 } | |
65 | |
66 server { | |
67 listen 127.0.0.1:8080; | |
68 proxy_pass unix:%%TESTDIR%%/unix.sock; | |
69 } | |
70 } | |
71 | |
72 EOF | |
73 | |
74 $t->write_file('index.html', ''); | |
75 $t->run(); | |
76 | |
77 ############################################################################### | |
78 | |
79 my %data = stream('127.0.0.1:' . port(8080))->read() =~ /(\w+):(\w+)/g; | |
80 | |
81 TODO: { | |
82 local $TODO = 'not yet' unless $t->has_version('1.15.8'); | |
83 | |
84 is($data{geo}, 'none', 'geo unix'); | |
85 is($data{geor}, 'none', 'geo unix ranges'); | |
86 | |
87 } | |
88 | |
89 is($data{geora}, 'none', 'geo unix remote addr'); | |
90 is($data{georra}, 'none', 'geo unix ranges remote addr'); | |
91 | |
92 ############################################################################### |