# HG changeset patch # User Heiko Schlittermann # Date 1464732989 -7200 # Node ID 7c5787eaccb5312d62df3a9955334112ce295820 # Parent 936efccc64e6c81ffb6f797468f4a6e259619e89 Add t/00-basic.t diff -r 936efccc64e6 -r 7c5787eaccb5 lib/Nagios/Check/DNS/check_tlsa_record.pm --- a/lib/Nagios/Check/DNS/check_tlsa_record.pm Tue May 31 23:45:16 2016 +0200 +++ b/lib/Nagios/Check/DNS/check_tlsa_record.pm Wed Jun 01 00:16:29 2016 +0200 @@ -3,7 +3,6 @@ use strict; use warnings; use feature qw(say switch); -use base 'Exporter'; use if $ENV{DEBUG} => 'Smart::Comments'; use Carp; @@ -12,7 +11,6 @@ use File::Temp; our $VERSION = '0.1'; -our @EXPORT_OK = qw(dig_tlsa); #@TODO use only fh of tempfile instead of filename my $tempfile = File::Temp->new( @@ -31,7 +29,7 @@ sub dig_tlsa { #@TODO - #dig tlsa _443._tcp.torproject.org +short + #dig tlsa _443._tcp.torproject.org +short #wildcard.torproject.org. #3 1 1 578582E6B4569A4627AEF5DFE876EEC0539388E605DB170217838B10 D2A58DA5 # until it's fixed test 7 returns ok on test on crit tlsa status diff -r 936efccc64e6 -r 7c5787eaccb5 t/00-basic.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/t/00-basic.t Wed Jun 01 00:16:29 2016 +0200 @@ -0,0 +1,24 @@ +use Test::More qw(no_plan); +use Test::Exception; + +use_ok 'Nagios::Check::DNS::check_tlsa_record'; +can_ok 'Nagios::Check::DNS::check_tlsa_record', qw(dig_tlsa); + +# The above package doesn't use the Exporter currently, for shortcut +# reasons we import the relevant subs into *this* module +*dig_tlsa = \&Nagios::Check::DNS::check_tlsa_record::dig_tlsa; + +# API conformance +subtest 'API' => sub { + can_ok 'Nagios::Check::DNS::check_tlsa_record', qw(dig_tlsa); + dies_ok { dig_tlsa('example.org') } 'API: dig_tlsa() missing port'; +}; + +# get and compare the TLSA records via dig_tlsa with `dig …` +subtest 'Data' => sub { + foreach (['ssl.schlittermann.de' => 443], ['mx1.mailbox.org.de' => 25],) { + my ($domain, $port) = @$_; + is dig_tlsa($domain, $port), + `dig +short tlsa _$port._tcp.$domain` => "TLSA $domain:$port"; + } +};