t/00-basic.t
changeset 19 7c5787eaccb5
child 20 2c6f22539c7f
equal deleted inserted replaced
18:936efccc64e6 19:7c5787eaccb5
       
     1 use Test::More qw(no_plan);
       
     2 use Test::Exception;
       
     3 
       
     4 use_ok 'Nagios::Check::DNS::check_tlsa_record';
       
     5 can_ok 'Nagios::Check::DNS::check_tlsa_record', qw(dig_tlsa);
       
     6 
       
     7 # The above package doesn't use the Exporter currently, for shortcut
       
     8 # reasons we import the relevant subs into *this* module
       
     9 *dig_tlsa = \&Nagios::Check::DNS::check_tlsa_record::dig_tlsa;
       
    10 
       
    11 # API conformance
       
    12 subtest 'API' => sub {
       
    13     can_ok 'Nagios::Check::DNS::check_tlsa_record', qw(dig_tlsa);
       
    14     dies_ok { dig_tlsa('example.org') } 'API: dig_tlsa() missing port';
       
    15 };
       
    16 
       
    17 # get and compare the TLSA records via dig_tlsa with `dig …`
       
    18 subtest 'Data' => sub {
       
    19     foreach (['ssl.schlittermann.de' => 443], ['mx1.mailbox.org.de' => 25],) {
       
    20         my ($domain, $port) = @$_;
       
    21         is dig_tlsa($domain, $port),
       
    22           `dig +short tlsa _$port._tcp.$domain` => "TLSA $domain:$port";
       
    23     }
       
    24 };