"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "t/05-TSIG.t" between
Net-DNS-1.23.tar.gz and Net-DNS-1.23_01.tar.gz

About: Net::DNS is a DNS resolver implemented in Perl. Development version.

05-TSIG.t  (Net-DNS-1.23):05-TSIG.t  (Net-DNS-1.23_01)
# $Id: 05-TSIG.t 1749 2019-07-21 09:15:55Z willem $ -*-perl-*- # $Id: 05-TSIG.t 1779 2020-05-11 09:11:17Z willem $ -*-perl-*-
# #
use strict; use strict;
use Test::More; use Test::More;
use Net::DNS; use Net::DNS;
my @prerequisite = qw( my @prerequisite = qw(
Digest::HMAC Digest::HMAC
Digest::MD5 Digest::MD5
Digest::SHA Digest::SHA
skipping to change at line 73 skipping to change at line 73
my $null = new Net::DNS::RR("$name NULL")->encode; my $null = new Net::DNS::RR("$name NULL")->encode;
my $empty = new Net::DNS::RR("$name $type")->encode; my $empty = new Net::DNS::RR("$name $type")->encode;
my $buffer = $empty; ## Note: TSIG RR gets destroyed by decode r my $buffer = $empty; ## Note: TSIG RR gets destroyed by decode r
my $rxbin = decode Net::DNS::RR( \$buffer )->encode; my $rxbin = decode Net::DNS::RR( \$buffer )->encode;
my $packet = Net::DNS::Packet->new( $name, 'TKEY', 'IN' ); my $packet = Net::DNS::Packet->new( $name, 'TKEY', 'IN' );
$packet->header->id(1234); # fix packet id $packet->header->id(1234); # fix packet id
$packet->header->rd(1); $packet->header->rd(1);
my $encoded = $buffer = $rr->encode( 0, {}, $packet ); my $encoded = $buffer = $rr->encode( 0, {}, $packet );
my $decoded = decode Net::DNS::RR( \$buffer ); my $decoded = decode Net::DNS::RR( \$buffer );
my $hex1 = unpack 'H*', $encoded; my $hex1 = unpack 'H*', $encoded;
my $hex2 = unpack 'H*', $decoded->encode; my $hex2 = unpack 'H*', $decoded->encode;
my $hex3 = unpack 'H*', substr( $encoded, length $null ); my $hex3 = unpack 'H*', substr( $encoded, length $null );
is( $hex2, $hex1, 'encode/decode transparent' ); is( $hex2, $hex1, 'encode/decode transparent' );
is( $hex3, $wire, 'encoded RDATA matches example' ); is( $hex3, $wire, 'encoded RDATA matches example' );
is( length($empty), length($null), 'encoded RDATA can be empty' ); is( length($empty), length($null), 'encoded RDATA can be empty' );
is( length($rxbin), length($null), 'decoded RDATA can be empty' ); is( length($rxbin), length($null), 'decoded RDATA can be empty' );
my @wire = unpack 'C*', $encoded; my $wireformat = pack 'a* x', $encoded;
my $wireformat = pack 'C*', @wire, 0;
eval { decode Net::DNS::RR( \$wireformat ); }; eval { decode Net::DNS::RR( \$wireformat ); };
my ($exception) = split /\n/, "$@\n"; my ($exception) = split /\n/, "$@\n";
ok( $exception, "misplaced SIG RR\t[$exception]" ); ok( $exception, "misplaced $type RR\t[$exception]" );
} }
{ {
my $rr = new Net::DNS::RR( type => 'TSIG', key => '' ); my $rr = new Net::DNS::RR( type => 'TSIG', key => '' );
ok( !$rr->verify(), 'verify fails on empty TSIG' ); ok( !$rr->verify(), 'verify fails on empty TSIG' );
ok( $rr->vrfyerrstr(), 'vrfyerrstr() reports failure' ); ok( $rr->vrfyerrstr(), 'vrfyerrstr() reports failure' );
ok( !$rr->other(), 'other undefined' ); ok( !$rr->other(), 'other undefined' );
ok( $rr->time_signed(), 'time_signed() defined' ); ok( $rr->time_signed(), 'time_signed() defined' );
my $key = eval { $rr->key(); }; my $key = eval { $rr->key(); };
my ($exception) = split /\n/, "$@\n"; my ($exception) = split /\n/, "$@\n";
ok( $exception, "write-only key attribute\t[$exception]" ); ok( $exception, "key attribute write-only\t[$exception]" );
} }
{ {
my $mac = 'kpRyejY4uxwT9I74FYv8nQ=='; my $mac = 'kpRyejY4uxwT9I74FYv8nQ==';
foreach my $method (qw(mac request_mac prior_mac)) { foreach my $method (qw(mac request_mac prior_mac)) {
my $rr = new Net::DNS::RR( type => 'TSIG', $method => $mac ); my $rr = new Net::DNS::RR( type => 'TSIG', $method => $mac );
is( $rr->$method(), $mac, "correct $method" ); is( $rr->$method(), $mac, "correct $method" );
} }
} }
 End of changes. 5 change blocks. 
8 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)