comparison mail_resolver.t @ 809:ded6b7648d6e

Tests: added mail resolver test for CNAME and PTR records combined.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 17 Dec 2015 16:55:49 +0300
parents ffdd33c64193
children b87c6acf0e4b
comparison
equal deleted inserted replaced
808:f02dac68d584 809:ded6b7648d6e
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:8086; 82 resolver 127.0.0.1:8086;
83 } 83 }
84
85 server {
86 listen 127.0.0.1:8032;
87 protocol smtp;
88 resolver 127.0.0.1:8087;
89 }
90
84 } 91 }
85 92
86 http { 93 http {
87 %%TEST_GLOBALS_HTTP%% 94 %%TEST_GLOBALS_HTTP%%
88 95
105 } 112 }
106 } 113 }
107 114
108 EOF 115 EOF
109 116
110 for (8081 .. 8086) { 117 for (8081 .. 8087) {
111 $t->run_daemon(\&dns_daemon, $_, $t); 118 $t->run_daemon(\&dns_daemon, $_, $t);
112 } 119 }
113 $t->run(); 120 $t->run();
114 121
115 for (8081 .. 8086) { 122 for (8081 .. 8087) {
116 $t->waitforfile($t->testdir . "/$_"); 123 $t->waitforfile($t->testdir . "/$_");
117 } 124 }
118 125
119 $t->plan(7); 126 $t->plan(8);
120 127
121 ############################################################################### 128 ###############################################################################
122 129
123 # PTR 130 # PTR
124 131
191 $s->read(); 198 $s->read();
192 $s->send('MAIL FROM:<test@example.com> SIZE=100'); 199 $s->send('MAIL FROM:<test@example.com> SIZE=100');
193 $s->read(); 200 $s->read();
194 201
195 $s->send('RCPT TO:<test@example.com>'); 202 $s->send('RCPT TO:<test@example.com>');
196 $s->ok('PTR with CNAME'); 203 $s->ok('CNAME');
197 204
198 $s->send('QUIT'); 205 $s->send('QUIT');
199 $s->read(); 206 $s->read();
200 207
201 } 208 }
230 $s->send('MAIL FROM:<test@example.com> SIZE=100'); 237 $s->send('MAIL FROM:<test@example.com> SIZE=100');
231 $s->read(); 238 $s->read();
232 239
233 $s->send('RCPT TO:<test@example.com>'); 240 $s->send('RCPT TO:<test@example.com>');
234 $s->check(qr/TEMPUNAVAIL/, 'PTR type'); 241 $s->check(qr/TEMPUNAVAIL/, 'PTR type');
242
243 $s->send('QUIT');
244 $s->read();
245
246 }
247
248 # CNAME and PTR in one answer section
249
250 TODO: {
251 local $TODO = 'not yet';
252
253 $s = Test::Nginx::SMTP->new(PeerAddr => "127.0.0.1:8032");
254 $s->read();
255 $s->send('EHLO example.com');
256 $s->read();
257 $s->send('MAIL FROM:<test@example.com> SIZE=100');
258 $s->read();
259
260 $s->send('RCPT TO:<test@example.com>');
261 $s->ok('CNAME with PTR');
235 262
236 $s->send('QUIT'); 263 $s->send('QUIT');
237 $s->read(); 264 $s->read();
238 265
239 } 266 }
304 PTR, IN, $ttl, 15, ('a', 'example', 'net')); 331 PTR, IN, $ttl, 15, ('a', 'example', 'net'));
305 332
306 } elsif ($port == 8086) { 333 } elsif ($port == 8086) {
307 push @rdata, rd_name(DNAME, $ttl, 'a.example.net'); 334 push @rdata, rd_name(DNAME, $ttl, 'a.example.net');
308 335
336 } elsif ($port == 8087) {
337 # PTR answered with CNAME+PTR
338
339 push @rdata, rd_name(CNAME, $ttl,
340 '1.1.0.0.127.in-addr.arpa');
341 push @rdata, pack("n3N n(C/a*)3 x", 0xc034,
342 PTR, IN, $ttl, 15, ('a', 'example', 'net'));
309 } 343 }
310 344
311 } elsif ($name eq '1.1.0.0.127.in-addr.arpa' && $type == PTR) { 345 } elsif ($name eq '1.1.0.0.127.in-addr.arpa' && $type == PTR) {
312 push @rdata, rd_name(PTR, $ttl, 'a.example.net'); 346 push @rdata, rd_name(PTR, $ttl, 'a.example.net');
313 } 347 }