From 06f5912eb51328ae5e1ae8b34c5d4bd46e97b135 Mon Sep 17 00:00:00 2001 From: "[Thomas Green]" Date: Thu, 21 Nov 2024 16:20:08 +0100 Subject: [PATCH] Update unit tests --- t/nameserver.t | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/t/nameserver.t b/t/nameserver.t index 965564ad1..1eed8ecdf 100644 --- a/t/nameserver.t +++ b/t/nameserver.t @@ -33,9 +33,8 @@ isa_ok( $p2, 'Zonemaster::Engine::Packet' ); my ( $soa ) = grep { $_->type eq 'SOA' } $p1->answer; is( scalar( $p1->answer ), 1, 'one answer RR present ' ); ok( $soa, 'it is a SOA RR' ); -is( lc( $soa->rname ), 'hostmaster.iis.se.', 'RNAME has expected format' ); +is( lc( $soa->rname ), 'hostmaster.nic.se.', 'RNAME has expected format' ); is( scalar( grep { $_->type eq 'SOA' or $_->type eq 'RRSIG' } $p2->answer ), 2, 'SOA and RRSIG RRs present' ); -ok( !$nsv6->dns->dnssec, 'dnssec flag still unset' ); ok( $p3 eq $p2, 'Same packet object returned' ); ok( $p3 ne $p4, 'Same packet object not returned from other server' ); ok( $p3 ne $p1, 'Same packet object not returned with other flag' ); @@ -142,12 +141,12 @@ subtest 'dnssec, edns_size and edns_details{do, size} flags behavior for queries my $ns = new_ok( 'Zonemaster::Engine::Nameserver' => [ { name => 'd.nic.fr', address => '194.0.9.1' } ] ); my $p = $ns->query( 'fr', 'SOA' ); - is( $ns->dns->dnssec, 0, 'dnssec flag is unset' ); + ok( !$ns->dns->dnssec, 'dnssec flag is unset' ); is( $ns->dns->edns_size, 0, 'edns_size flag is unset' ); ok( !$p->has_edns and !$p->do, 'non-EDNS response received on query with all default parameters' ); $p = $ns->query( 'fr', 'SOA', { "dnssec" => 0 } ); - is( $ns->dns->dnssec, 0, 'dnssec flag is unset' ); + ok( !$ns->dns->dnssec, 'dnssec flag is unset' ); is( $ns->dns->edns_size, 0, 'edns_size flag is unset' ); ok( !$p->has_edns and !$p->do, 'non-EDNS response received on query with dnssec unset' ); @@ -155,62 +154,62 @@ subtest 'dnssec, edns_size and edns_details{do, size} flags behavior for queries # each consecutive queries. $p = $ns->query( 'fr', 'SOA', { "dnssec" => 1 } ); - is( $ns->dns->dnssec, 1, 'dnssec flag is set' ); + ok( $ns->dns->dnssec, 'dnssec flag is set' ); is( $ns->dns->edns_size, $UDP_DNSSEC_QUERY_DEFAULT, 'edns_size uses default DNSSEC query value' ); ok( $p->has_edns and $p->do, 'DNSSEC response received on query with dnssec set' ); $p = $ns->query( 'fr', 'SOA', { "edns_size" => 1000 } ); - is( $ns->dns->dnssec, 0, 'dnssec flag is unset' ); + ok( !$ns->dns->dnssec, 'dnssec flag is unset' ); is( $ns->dns->edns_size, 1000, 'edns_size uses given value' ); ok( $p->has_edns and !$p->do, 'non-DNSSEC EDNS response received on query with edns_size set' ); $p = $ns->query( 'fr', 'SOA', { "dnssec" => 0, "edns_size" => 1001 } ); - is( $ns->dns->dnssec, 0, 'dnssec flag is unset' ); + ok( !$ns->dns->dnssec, 'dnssec flag is unset' ); is( $ns->dns->edns_size, 1001, 'edns_size uses given value instead of default for non-DNSSEC EDNS queries' ); ok( $p->has_edns and !$p->do, 'non-DNSSEC EDNS response received on query with dnssec unset and edns_size set' ); $p = $ns->query( 'fr', 'SOA', { "dnssec" => 1, "edns_size" => 1002 } ); - is( $ns->dns->dnssec, 1, 'dnssec flag is set' ); - is( $ns->dns->edns_size, 1002, 'edns_size uses given value instead of default for DNSSEC EDNS queries' ); + ok( $ns->dns->dnssec, 'dnssec flag is set' ); + is( $ns->dns->edns_size, 1002, 'edns_size uses given value instead of default for DNSSEC queries' ); ok( $p->has_edns and $p->do, 'DNSSEC response received on query with dnssec set and edns_size set' ); $p = $ns->query( 'fr', 'SOA', { "edns_details" => {} } ); - is( $ns->dns->dnssec, 0, 'dnssec flag is unset' ); + ok( !$ns->dns->dnssec, 'dnssec flag is unset' ); is( $ns->dns->edns_size, $UDP_EDNS_QUERY_DEFAULT, 'edns_size uses default EDNS query value for non-DNSSEC EDNS queries' ); ok( $p->has_edns and !$p->do, 'non-DNSSEC EDNS response received on query with edns_details set' ); $p = $ns->query( 'fr', 'SOA', { "edns_details" => { "do" => 1 } } ); - is( $ns->dns->dnssec, 1, 'dnssec flag is also set via edns_details{do}' ); + ok( $ns->dns->dnssec, 'dnssec flag is also set via edns_details{do}' ); is( $ns->dns->edns_size, $UDP_DNSSEC_QUERY_DEFAULT, 'edns_size also uses default DNSSEC query value when set with edns_details{do}' ); ok( $p->has_edns and $p->do, 'DNSSEC response received on query with edns_details{do} set' ); $p = $ns->query( 'fr', 'SOA', { "edns_details" => { "size" => 900 } } ); - is( $ns->dns->dnssec, 0, 'dnssec flag is unset' ); + ok( !$ns->dns->dnssec, 'dnssec flag is unset' ); is( $ns->dns->edns_size, 900, 'edns_size also uses given value when set with edns_details{size}' ); ok( $p->has_edns and !$p->do, 'non-DNSSEC EDNS response received on query with edns_details{size} set' ); $p = $ns->query( 'fr', 'SOA', { "edns_details" => { "size" => 0 } } ); - is( $ns->dns->dnssec, 0, 'dnssec flag is unset' ); + ok( !$ns->dns->dnssec, 'dnssec flag is unset' ); is( $ns->dns->edns_size, 0, 'edns_size also uses given value when set with edns_details{size}' ); ok( $p->has_edns and !$p->do, 'non-DNSSEC EDNS response received on query even with edns_details{size} set to 0' ); $p = $ns->query( 'fr', 'SOA', { "dnssec" => 1, "edns_details" => { "do" => 0 } } ); - is( $ns->dns->dnssec, 0, 'edns_details{do} takes precedence over dnssec for setting the dnssec flag' ); + ok( !$ns->dns->dnssec, 'edns_details{do} takes precedence over dnssec for (un)setting the dnssec flag' ); is( $ns->dns->edns_size, $UDP_EDNS_QUERY_DEFAULT, 'edns_size uses default EDNS query value when dnssec flag is unset by edns_details{do}' ); ok( $p->has_edns and !$p->do, 'non-DNSSEC EDNS response received on query with dnssec unset by edns_details{do}' ); $p = $ns->query( 'fr', 'SOA', { "edns_size" => 1003, "edns_details" => { "size" => 901 } } ); - is( $ns->dns->dnssec, 0, 'dnssec flag is unset' ); + ok( !$ns->dns->dnssec, 'dnssec flag is unset' ); is( $ns->dns->edns_size, 901, 'edns_details{size} takes precedence over edns_size for setting the edns_size flag' ); ok( $p->has_edns and !$p->do, 'non-DNSSEC EDNS response received on query with edns_size and edns_details{size} set' ); $p = $ns->query( 'fr', 'SOA', { "dnssec" => 1, "edns_size" => 1004, "edns_details" => { "size" => 0 } } ); - is( $ns->dns->dnssec, 1, 'dnssec flag is set' ); + ok( $ns->dns->dnssec, 'dnssec flag is set' ); is( $ns->dns->edns_size, 0, 'edns_size is unset' ); ok( $p->has_edns and $p->do, 'DNSSEC response received on query with dnssec set and even with edns_details{size} set to 0' ); $p = $ns->query( 'fr', 'SOA', { "dnssec" => 0, "edns_size" => 1005, "edns_details" => { "do" => 1, "size" => 0 } } ); - is( $ns->dns->dnssec, 1, 'dnssec flag is set' ); + ok( $ns->dns->dnssec, 'dnssec flag is set' ); is( $ns->dns->edns_size, 0, 'edns_size is unset' ); ok( $p->has_edns and $p->do, 'DNSSEC response received on query with dnssec set by edns_details{do} and even with edns_details{size} set to 0' );