| 1 |
use Test::More tests => 8; |
| 2 |
|
| 3 |
use FindBin qw/$Bin/; |
| 4 |
|
| 5 |
use DNS::LDNS ':all'; |
| 6 |
|
| 7 |
BEGIN { use_ok('DNS::LDNS') }; |
| 8 |
|
| 9 |
my $key = new DNS::LDNS::Key(filename => "$Bin/testdata/key.private"); |
| 10 |
ok($key, 'Created new key object from file'); |
| 11 |
is($key->algorithm, 7, 'Algorithm is NSEC3RSASHA1'); |
| 12 |
my $now = time; |
| 13 |
$key->set_inception($now); |
| 14 |
$key->set_expiration($now + 10000); |
| 15 |
is($key->inception, $now, 'Inception time'); |
| 16 |
is($key->expiration, $now + 10000, 'Expiration time'); |
| 17 |
like($key->to_rr->to_string, qr|3600\s+IN\s+DNSKEY\s+256\s+3\s+7\s+AwEAAfg/ghOkk|, 'Got rr representation of key'); |
| 18 |
|
| 19 |
my $klist = new DNS::LDNS::KeyList; |
| 20 |
$klist->push($key); |
| 21 |
is($klist->count, 1, 'Keylist has one key'); |
| 22 |
is($$key, ${$klist->key(0)}, 'Key in keylist is the one we pushed'); |
| 23 |
# FIXME: pop is buggy in ldns 1.6.12, uncomment when this starts working |
| 24 |
# is($klist->pop(), $$key, 'Pop key from list'); |
| 25 |
# is($klist->count, 0, 'No keys left in list'); |