# HG changeset patch # User Sergey Kandaurov # Date 1453892200 -10800 # Node ID 9623d353f06645b9a275e0860e4d38c952fbd1f1 # Parent 92e20c77c9160cf42b703cb159693a588325ae85 Tests: http resolver tests with format error response code. diff --git a/http_resolver.t b/http_resolver.t --- a/http_resolver.t +++ b/http_resolver.t @@ -91,7 +91,7 @@ EOF $t->run_daemon(\&dns_daemon, 8082, $t); $t->run_daemon(\&dns_daemon, 8089, $t); -$t->run()->plan(32); +$t->run()->plan(34); $t->waitforfile($t->testdir . '/8081'); $t->waitforfile($t->testdir . '/8082'); @@ -102,6 +102,7 @@ EOF # schedule resend test, which takes about 5 seconds to complete my $s = http_host_header('id.example.net', '/resend', start => 1); +my $fe = http_host_header('fe.example.net', '/resend', start => 1); like(http_host_header('a.example.net', '/'), qr/200 OK/, 'A'); @@ -229,6 +230,7 @@ like(http_host_header('cname_a_ttl2.exam like(http_host_header('example.net', '/invalid'), qr/502 Bad/, 'no resolver'); like(http_end($s), qr/200 OK/, 'resend after malformed response'); +like(http_end($fe), qr/200 OK/, 'resend after format error'); $s = http_get('/bad', start => 1); my $s2 = http_get('/bad', start => 1); @@ -236,6 +238,8 @@ my $s2 = http_get('/bad', start => 1); http_end($s); ok(http_end($s2), 'timeout handler on 2nd request'); +like(http_host_header('fe_id.example.net', '/'), qr/502 Bad/, 'format error'); + ############################################################################### sub http_host_header { @@ -264,6 +268,7 @@ sub reply_handler { my (@name, @rdata); use constant NOERROR => 0; + use constant FORMERR => 1; use constant SERVFAIL => 2; use constant NXDOMAIN => 3; @@ -297,6 +302,17 @@ sub reply_handler { push @rdata, rd_addr($ttl, '127.0.0.1'); } + } elsif ($name eq 'fe.example.net' && $type == A) { + if (++$state->{fecnt} > 1) { + $rcode = FORMERR; + } + + push @rdata, rd_addr($ttl, '127.0.0.1'); + + } elsif ($name eq 'fe_id.example.net' && $type == A) { + $id = 42; + $rcode = FORMERR; + } elsif ($name eq 'case.example.net' && $type == A) { if (++$state->{casecnt} > 1) { $rcode = SERVFAIL; @@ -466,6 +482,7 @@ sub dns_daemon { manycnt => 0, casecnt => 0, idcnt => 0, + fecnt => 0, ); # signal we are ready