1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
# $Id: 05-rr-sshfp.t 264 2005-04-06 09:16:15Z olaf $
use Test::More;
use strict;
use Net::DNS;
use Net::DNS::RR::SSHFP;
BEGIN {
if ($Net::DNS::RR::SSHFP::HasBabble) {
plan tests => 15;
} else {
plan skip_all => 'Digest::BubbleBabble not installed.';
}
}
#------------------------------------------------------------------------------
# Canned data.
#------------------------------------------------------------------------------
my $name = "foo.example.com";
my $class = "IN";
my $ttl = 43200;
my %data = (
type => 'SSHFP',
algorithm => 2,
fptype => 1,
fingerprint => '5E66E766416A3A3A60CB150CB3F9C01C43953FB6',
);
#------------------------------------------------------------------------------
# Create the packet.
#------------------------------------------------------------------------------
my $packet = Net::DNS::Packet->new($name);
ok($packet, 'Packet created');
$packet->push('answer',
Net::DNS::RR->new(
name => $name,
ttl => $ttl,
%data,
)
);
#------------------------------------------------------------------------------
# Re-create the packet from data.
#------------------------------------------------------------------------------
my $data = $packet->data;
ok($data, 'Packet has data after pushes');
undef $packet;
$packet = Net::DNS::Packet->new(\$data);
ok($packet, 'Packet reconstructed from data');
my @answer = $packet->answer;
ok(@answer && @answer == 1, 'Packet returned correct answer section');
my $rr = $answer[0];
isa_ok($rr, 'Net::DNS::RR::SSHFP');
is($rr->name, $name, "name() correct");
is($rr->class, $class, "class() correct");
is($rr->ttl, $ttl, "ttl() correct");
foreach my $meth (keys %data) {
is($rr->$meth(), $data{$meth}, "$meth() correct");
}
my $rr2 = Net::DNS::RR->new($rr->string);
is($rr2->string, $rr->string, "Parsing from string works");
is ($rr->babble, $rr2->babble, "SSHFP - Same babble at both sides");
is ($rr->babble, "xilik-kanuk-kebek-povyf-pamus-rahob-sysoz-nibac-saben-hezur-kuxex", "SSHFP - Same matches input") ;
|