Mercurial > hg > nginx-tests
comparison mail_resolver.t @ 1237:e4974af3fb12
Tests: adjusted udp ports to match allocated ports range.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Wed, 13 Sep 2017 19:04:25 +0300 |
parents | 26884729e06b |
children | 1356e7374c57 |
comparison
equal
deleted
inserted
replaced
1236:93f749c1d5c5 | 1237:e4974af3fb12 |
---|---|
44 resolver_timeout 2s; | 44 resolver_timeout 2s; |
45 | 45 |
46 server { | 46 server { |
47 listen 127.0.0.1:8025; | 47 listen 127.0.0.1:8025; |
48 protocol smtp; | 48 protocol smtp; |
49 resolver 127.0.0.1:%%PORT_8081_UDP%% | 49 resolver 127.0.0.1:%%PORT_8981_UDP%% |
50 127.0.0.1:%%PORT_8082_UDP%% | 50 127.0.0.1:%%PORT_8982_UDP%% |
51 127.0.0.1:%%PORT_8083_UDP%%; | 51 127.0.0.1:%%PORT_8983_UDP%%; |
52 } | 52 } |
53 | 53 |
54 server { | 54 server { |
55 listen 127.0.0.1:8027; | 55 listen 127.0.0.1:8027; |
56 protocol smtp; | 56 protocol smtp; |
57 resolver 127.0.0.1:%%PORT_8082_UDP%%; | 57 resolver 127.0.0.1:%%PORT_8982_UDP%%; |
58 } | 58 } |
59 | 59 |
60 server { | 60 server { |
61 listen 127.0.0.1:8028; | 61 listen 127.0.0.1:8028; |
62 protocol smtp; | 62 protocol smtp; |
63 resolver 127.0.0.1:%%PORT_8083_UDP%%; | 63 resolver 127.0.0.1:%%PORT_8983_UDP%%; |
64 resolver_timeout 1s; | 64 resolver_timeout 1s; |
65 } | 65 } |
66 | 66 |
67 server { | 67 server { |
68 listen 127.0.0.1:8029; | 68 listen 127.0.0.1:8029; |
69 protocol smtp; | 69 protocol smtp; |
70 resolver 127.0.0.1:%%PORT_8084_UDP%%; | 70 resolver 127.0.0.1:%%PORT_8984_UDP%%; |
71 } | 71 } |
72 | 72 |
73 server { | 73 server { |
74 listen 127.0.0.1:8030; | 74 listen 127.0.0.1:8030; |
75 protocol smtp; | 75 protocol smtp; |
76 resolver 127.0.0.1:%%PORT_8085_UDP%%; | 76 resolver 127.0.0.1:%%PORT_8985_UDP%%; |
77 } | 77 } |
78 | 78 |
79 server { | 79 server { |
80 listen 127.0.0.1:8031; | 80 listen 127.0.0.1:8031; |
81 protocol smtp; | 81 protocol smtp; |
82 resolver 127.0.0.1:%%PORT_8086_UDP%%; | 82 resolver 127.0.0.1:%%PORT_8986_UDP%%; |
83 resolver_timeout 1s; | 83 resolver_timeout 1s; |
84 } | 84 } |
85 | 85 |
86 server { | 86 server { |
87 listen 127.0.0.1:8032; | 87 listen 127.0.0.1:8032; |
88 protocol smtp; | 88 protocol smtp; |
89 resolver 127.0.0.1:%%PORT_8087_UDP%%; | 89 resolver 127.0.0.1:%%PORT_8987_UDP%%; |
90 } | 90 } |
91 | 91 |
92 } | 92 } |
93 | 93 |
94 http { | 94 http { |
114 } | 114 } |
115 | 115 |
116 EOF | 116 EOF |
117 | 117 |
118 $t->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon); | 118 $t->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon); |
119 $t->run_daemon(\&dns_daemon, port($_), $t) foreach (8081 .. 8087); | 119 $t->run_daemon(\&dns_daemon, port($_), $t) foreach (8981 .. 8987); |
120 | 120 |
121 $t->run(); | 121 $t->run(); |
122 | 122 |
123 $t->waitforsocket('127.0.0.1:' . port(8026)); | 123 $t->waitforsocket('127.0.0.1:' . port(8026)); |
124 $t->waitforfile($t->testdir . '/' . port($_)) foreach (8081 .. 8087); | 124 $t->waitforfile($t->testdir . '/' . port($_)) foreach (8981 .. 8987); |
125 | 125 |
126 ############################################################################### | 126 ############################################################################### |
127 | 127 |
128 # PTR | 128 # PTR |
129 | 129 |
138 $s->ok('PTR'); | 138 $s->ok('PTR'); |
139 | 139 |
140 $s->send('QUIT'); | 140 $s->send('QUIT'); |
141 $s->read(); | 141 $s->read(); |
142 | 142 |
143 # Cached PTR prevents from querying bad ns on port 8083 | 143 # Cached PTR prevents from querying bad ns on port 8983 |
144 | 144 |
145 $s = Test::Nginx::SMTP->new(); | 145 $s = Test::Nginx::SMTP->new(); |
146 $s->read(); | 146 $s->read(); |
147 $s->send('EHLO example.com'); | 147 $s->send('EHLO example.com'); |
148 $s->read(); | 148 $s->read(); |
287 my $name = join('.', @name); | 287 my $name = join('.', @name); |
288 if ($name eq 'a.example.net' && $type == A) { | 288 if ($name eq 'a.example.net' && $type == A) { |
289 push @rdata, rd_addr($ttl, '127.0.0.1'); | 289 push @rdata, rd_addr($ttl, '127.0.0.1'); |
290 | 290 |
291 } elsif ($name eq '1.0.0.127.in-addr.arpa' && $type == PTR) { | 291 } elsif ($name eq '1.0.0.127.in-addr.arpa' && $type == PTR) { |
292 if ($port == port(8081)) { | 292 if ($port == port(8981)) { |
293 push @rdata, rd_name(PTR, $ttl, 'a.example.net'); | 293 push @rdata, rd_name(PTR, $ttl, 'a.example.net'); |
294 | 294 |
295 } elsif ($port == port(8082)) { | 295 } elsif ($port == port(8982)) { |
296 $rcode = SERVFAIL; | 296 $rcode = SERVFAIL; |
297 | 297 |
298 } elsif ($port == port(8083)) { | 298 } elsif ($port == port(8983)) { |
299 # zero length RDATA | 299 # zero length RDATA |
300 | 300 |
301 push @rdata, pack("n3N n", 0xc00c, PTR, IN, $ttl, 0); | 301 push @rdata, pack("n3N n", 0xc00c, PTR, IN, $ttl, 0); |
302 | 302 |
303 } elsif ($port == port(8084)) { | 303 } elsif ($port == port(8984)) { |
304 # PTR answered with CNAME | 304 # PTR answered with CNAME |
305 | 305 |
306 push @rdata, rd_name(CNAME, $ttl, | 306 push @rdata, rd_name(CNAME, $ttl, |
307 '1.1.0.0.127.in-addr.arpa'); | 307 '1.1.0.0.127.in-addr.arpa'); |
308 | 308 |
309 } elsif ($port == port(8085)) { | 309 } elsif ($port == port(8985)) { |
310 # uncompressed answer | 310 # uncompressed answer |
311 | 311 |
312 push @rdata, pack("(C/a*)6x n2N n(C/a*)3x", | 312 push @rdata, pack("(C/a*)6x n2N n(C/a*)3x", |
313 ('1', '0', '0', '127', 'in-addr', 'arpa'), | 313 ('1', '0', '0', '127', 'in-addr', 'arpa'), |
314 PTR, IN, $ttl, 15, ('a', 'example', 'net')); | 314 PTR, IN, $ttl, 15, ('a', 'example', 'net')); |
315 | 315 |
316 } elsif ($port == port(8086)) { | 316 } elsif ($port == port(8986)) { |
317 push @rdata, rd_name(DNAME, $ttl, 'a.example.net'); | 317 push @rdata, rd_name(DNAME, $ttl, 'a.example.net'); |
318 | 318 |
319 } elsif ($port == port(8087)) { | 319 } elsif ($port == port(8987)) { |
320 # PTR answered with CNAME+PTR | 320 # PTR answered with CNAME+PTR |
321 | 321 |
322 push @rdata, rd_name(CNAME, $ttl, | 322 push @rdata, rd_name(CNAME, $ttl, |
323 '1.1.0.0.127.in-addr.arpa'); | 323 '1.1.0.0.127.in-addr.arpa'); |
324 push @rdata, pack("n3N n(C/a*)3 x", 0xc034, | 324 push @rdata, pack("n3N n(C/a*)3 x", 0xc034, |