diff -r ebada07bb701 -r 2e27cfdf85ea t/10-minimal.t --- a/t/10-minimal.t Tue Dec 30 12:24:43 2014 +0100 +++ b/t/10-minimal.t Tue Dec 30 14:40:45 2014 +0100 @@ -14,7 +14,10 @@ $tmp->flush; sub dig_serial { (split " ", `dig +short SOA @_`)[2] } -sub dig_ns { sort map { /(\S+?)\.?$/ } `dig +short NS @_` } + +sub dig_ns { + sort map { /(\S+?)\.?$/ } `dig +short NS @_`; +} # we require it, it's not a normal module require_ok 'blib/nagios/plugins/ius/check_dns-serial' @@ -31,23 +34,28 @@ for (qw(heise.de schlittermann.de google.com debian.org example.org)) { - subtest $_ => sub { + subtest $_ => sub { - # get_ns should return the NS from public dns servers - is_deeply [get_ns($_)], [dig_ns($_)] => "ns \@default"; - is_deeply [get_ns('@8.8.4.4', $_)], [dig_ns('@8.8.4.4', $_)] => "ns \@8.8.4.4"; - is get_serial('@8.8.8.8', $_), dig_serial('@8.8.8.8', $_) => 'serial'; - }; + throws_ok { ns($_, nameservers => [qw/8.8.8.8/], aa => 1) } + qr/no aa/ => 'not authoritive @8.8.8.8'; + is_deeply [ns($_)], [dig_ns($_)] => "ns \@default"; + is_deeply [ns($_, nameservers => [qw/8.8.4.4/])], + [dig_ns('@8.8.4.4', $_)] => "ns \@8.8.4.4"; + is serial($_, nameservers => [qw/8.8.8.8/]), + dig_serial('@8.8.8.8', $_) => 'serial'; + }; } # ns for some domain we're not the master for, should be refused -throws_ok { get_ns('@212.80.235.130', 'heise.de') } qr/^REFUSED/ => 'throws on refused query'; -throws_ok { get_ns('safasdfasdfrandomadsfefvddeas') } qr/^NXDOMAIN/ => 'throws on nx domain'; +throws_ok { ns('example.org', nameservers => [qw/f.nic.de a.nic.de b.nic.de/]) } +qr/^REFUSED/ => 'throws on refused query'; +throws_ok { ns('safasdfasdfrandomadsfefvddeas') } +qr/^NXDOMAIN/ => 'throws on nx domain'; -ok ns_ok('@212.80.235.130', 'schlittermann.de') => 'ns for schlittermann.de'; -throws_ok { ns_ok('@212.80.235.130', 'heise.de') } qr/differ/ => 'ns for heise.de'; - +ok ns_ok('schlittermann.de', '212.80.235.130') => 'ns_ok for schlittermann.de'; +throws_ok { ns_ok('heise.de', '212.80.235.130') } qr/no aa|differ|REFUSED/ => 'ns_ok for heise.de'; +throws_ok { ns_ok('heise.de', '8.8.8.8') } qr/no aa|differ|REFUSED/ => 'ns_ok for heise.de'; # serial