Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
455 changes: 285 additions & 170 deletions lib/Zonemaster/Engine/Test/Consistency.pm

Large diffs are not rendered by default.

36 changes: 25 additions & 11 deletions lib/Zonemaster/Engine/TestMethodsV2.pm
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ Glue Records are address records for In-Bailiwick name server names, if any. Als

Takes a L<Zonemaster::Engine::Zone> object.

Returns an arrayref of strings, or C<undef> if no parent zone was found.
Returns an arrayref of L<Zonemaster::Engine::Nameserver> objects, or C<undef> if no parent zone was found.

=back

Expand All @@ -567,11 +567,23 @@ Returns an arrayref of strings, or C<undef> if no parent zone was found.
sub get_del_ns_ips {
my ( $class, $zone ) = @_;

my $ns_ref = $class->get_del_ns_names_and_ips( $zone );
# FIXME: We really should just be outputting name server IPs here, as the
# specification says. Instead we output name server objects (but filtered
# on unique IP addresses) because these objects are required to perform
# queries.

return undef unless defined $ns_ref;
my $nameservers = $class->get_del_ns_names_and_ips( $zone );

return undef unless defined $nameservers;

my %ns_by_ip = ();
foreach my $ns ( @$nameservers ) {
next if ! $ns->isa('Zonemaster::Engine::Nameserver');
my $ip = $ns->address->short;
$ns_by_ip{$ip} = $ns unless exists $ns_by_ip{$ip};
}

return [ uniq sort map { $_->address->short } grep { $_->isa('Zonemaster::Engine::Nameserver') } @{ $ns_ref } ];
return [ sort values %ns_by_ip ];
}

=over
Expand Down Expand Up @@ -769,7 +781,7 @@ This Method will obtain the IP addresses of the name servers, as extracted from

Takes a L<Zonemaster::Engine::Zone> object.

Returns an arrayref of strings, or C<undef> if no parent zone was found.
Returns an arrayref of L<Zonemaster::Engine::Nameserver> objects, or C<undef> if no parent zone was found.

=back

Expand All @@ -778,16 +790,18 @@ Returns an arrayref of strings, or C<undef> if no parent zone was found.
sub get_zone_ns_ips {
my ( $class, $zone ) = @_;

my $ns_ref = $class->get_zone_ns_names_and_ips( $zone );
my $nameservers = $class->get_zone_ns_names_and_ips( $zone );

return undef unless defined $ns_ref;
return undef unless defined $nameservers;

my @ns_ips;
foreach my $ns ( @{ $ns_ref } ) {
push @ns_ips, $ns->address->short if $ns->isa('Zonemaster::Engine::Nameserver');
my %ns_by_ip = ();
foreach my $ns ( @$nameservers ) {
next if ! $ns->isa('Zonemaster::Engine::Nameserver');
my $ip = $ns->address->short;
$ns_by_ip{$ip} = $ns unless exists $ns_by_ip{$ip};
}

return [ uniq sort @ns_ips ];
return [ sort values %ns_by_ip ];
}


Expand Down
18 changes: 12 additions & 6 deletions share/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,18 @@
"TEST_CASE_START" : "DEBUG"
},
"CONSISTENCY" : {
"ADDRESSES_MATCH" : "INFO",
"CHILD_NS_FAILED" : "DEBUG",
"CHILD_ZONE_LAME" : "ERROR",
"EXTRA_ADDRESS_CHILD" : "NOTICE",
"IN_BAILIWICK_ADDR_MISMATCH" : "ERROR",
"CS05_CHILD_ZONE_LAME": "CRITICAL",
"CS05_DELEGATION": "INFO",
"CS05_EXTRA_ADDR_CHILD": "NOTICE",
"CS05_NO_MISMATCH_GLUE_ZONE": "INFO",
"CS05_ID_ADDR_MISMATCH": "ERROR",
"CS05_ID_ADDR_MISSING": "NOTICE",
"CS05_INCONSISTENT_DELEGATION": "WARNING",
"CS05_MISSING_GLUE_FOR_NS": "WARNING",
"CS05_MISSING_GLUE_FOR_NS_UNDEL": "WARNING",
"CS05_MISSING_GLUE_FOR_ROOT_NS": "WARNING",
"CS05_NO_NS_ADDR_CHILD": "CRITICAL",
"CS05_OOD_ADDR_MISMATCH": "WARNING",
"IPV4_DISABLED" : "DEBUG",
"IPV6_DISABLED" : "DEBUG",
"MULTIPLE_NS_SET" : "NOTICE",
Expand All @@ -146,7 +153,6 @@
"ONE_SOA_RNAME" : "INFO",
"ONE_SOA_SERIAL" : "INFO",
"ONE_SOA_TIME_PARAMETER_SET" : "INFO",
"OUT_OF_BAILIWICK_ADDR_MISMATCH" : "ERROR",
"SOA_RNAME" : "INFO",
"SOA_SERIAL" : "INFO",
"SOA_SERIAL_VARIATION" : "NOTICE",
Expand Down
49 changes: 0 additions & 49 deletions t/Test-consistency.t
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ ok( $res{NS_SET}, q{NS set details} );
ok( $res{ONE_SOA_SERIAL}, q{One SOA serial} );
ok( $res{ONE_SOA_RNAME}, q{One SOA rname} );
ok( $res{ONE_SOA_TIME_PARAMETER_SET}, q{One SOA time parameters set} );
ok( $res{ADDRESSES_MATCH}, q{Addresses IP match} );

if ( $ENV{ZONEMASTER_RECORD} ) {
Zonemaster::Engine::Nameserver->save( $datafile );
Expand All @@ -87,54 +86,6 @@ ok( ( any { $_->tag eq 'NO_NETWORK' } @res ), 'IPv6 and IPv4 disabled' );
ok( ( none { $_->tag eq 'IPV6_DISABLED' } @res ), 'No network' );
ok( ( none { $_->tag eq 'IPV4_DISABLED' } @res ), 'No network' );

#Zonemaster::Engine::Profile->effective->set( q{net.ipv4}, 1 );
#Zonemaster::Engine::Profile->effective->set( q{net.ipv6}, 0 );
#@res = Zonemaster::Engine->test_method( 'Consistency', 'consistency01', Zonemaster::Engine->zone( q{afnic.fr} ) );
#ok( ( any { $_->tag eq 'IPV6_DISABLED' } @res ), 'IPv6 disabled' );
#ok( ( none { $_->tag eq 'IPV4_DISABLED' } @res ), 'IPv4 not disabled' );
#@res = Zonemaster::Engine->test_method( 'Consistency', 'consistency02', Zonemaster::Engine->zone( q{afnic.fr} ) );
#ok( ( any { $_->tag eq 'IPV6_DISABLED' } @res ), 'IPv6 disabled' );
#ok( ( none { $_->tag eq 'IPV4_DISABLED' } @res ), 'IPv4 not disabled' );
#@res = Zonemaster::Engine->test_method( 'Consistency', 'consistency03', Zonemaster::Engine->zone( q{afnic.fr} ) );
#ok( ( any { $_->tag eq 'IPV6_DISABLED' } @res ), 'IPv6 disabled' );
#ok( ( none { $_->tag eq 'IPV4_DISABLED' } @res ), 'IPv4 not disabled' );
#@res = Zonemaster::Engine->test_method( 'Consistency', 'consistency04', Zonemaster::Engine->zone( q{afnic.fr} ) );
#ok( ( any { $_->tag eq 'IPV6_DISABLED' } @res ), 'IPv6 disabled' );
#ok( ( none { $_->tag eq 'IPV4_DISABLED' } @res ), 'IPv4 not disabled' );
#
#if ( Zonemaster::Engine::Util::supports_ipv6() ) {
#
# Zonemaster::Engine::Profile->effective->set( q{net.ipv4}, 0 );
# Zonemaster::Engine::Profile->effective->set( q{net.ipv6}, 1 );
# @res = Zonemaster::Engine->test_method( 'Consistency', 'consistency01', Zonemaster::Engine->zone( q{afnic.fr} ) );
# ok( ( none { $_->tag eq 'IPV6_DISABLED' } @res ), 'IPv6 not disabled' );
# ok( ( any { $_->tag eq 'IPV4_DISABLED' } @res ), 'IPv4 disabled' );
# @res = Zonemaster::Engine->test_method( 'Consistency', 'consistency02', Zonemaster::Engine->zone( q{afnic.fr} ) );
# ok( ( none { $_->tag eq 'IPV6_DISABLED' } @res ), 'IPv6 not disabled' );
# ok( ( any { $_->tag eq 'IPV4_DISABLED' } @res ), 'IPv4 disabled' );
# @res = Zonemaster::Engine->test_method( 'Consistency', 'consistency03', Zonemaster::Engine->zone( q{afnic.fr} ) );
# ok( ( none { $_->tag eq 'IPV6_DISABLED' } @res ), 'IPv6 not disabled' );
# ok( ( any { $_->tag eq 'IPV4_DISABLED' } @res ), 'IPv4 disabled' );
# @res = Zonemaster::Engine->test_method( 'Consistency', 'consistency04', Zonemaster::Engine->zone( q{afnic.fr} ) );
# ok( ( none { $_->tag eq 'IPV6_DISABLED' } @res ), 'IPv6 not disabled' );
# ok( ( any { $_->tag eq 'IPV4_DISABLED' } @res ), 'IPv4 disabled' );
#
# Zonemaster::Engine::Profile->effective->set( q{net.ipv4}, 1 );
# Zonemaster::Engine::Profile->effective->set( q{net.ipv6}, 1 );
# @res = Zonemaster::Engine->test_method( 'Consistency', 'consistency01', Zonemaster::Engine->zone( q{afnic.fr} ) );
# ok( ( none { $_->tag eq 'IPV6_DISABLED' } @res ), 'IPv6 not disabled' );
# ok( ( none { $_->tag eq 'IPV4_DISABLED' } @res ), 'IPv4 not disabled' );
# @res = Zonemaster::Engine->test_method( 'Consistency', 'consistency02', Zonemaster::Engine->zone( q{afnic.fr} ) );
# ok( ( none { $_->tag eq 'IPV6_DISABLED' } @res ), 'IPv6 not disabled' );
# ok( ( none { $_->tag eq 'IPV4_DISABLED' } @res ), 'IPv4 not disabled' );
# @res = Zonemaster::Engine->test_method( 'Consistency', 'consistency03', Zonemaster::Engine->zone( q{afnic.fr} ) );
# ok( ( none { $_->tag eq 'IPV6_DISABLED' } @res ), 'IPv6 not disabled' );
# ok( ( none { $_->tag eq 'IPV4_DISABLED' } @res ), 'IPv4 not disabled' );
# @res = Zonemaster::Engine->test_method( 'Consistency', 'consistency04', Zonemaster::Engine->zone( q{afnic.fr} ) );
# ok( ( none { $_->tag eq 'IPV6_DISABLED' } @res ), 'IPv6 not disabled' );
# ok( ( none { $_->tag eq 'IPV4_DISABLED' } @res ), 'IPv4 not disabled' );
#
#}

Zonemaster::Engine::Profile->effective->set( q{no_network}, 1 );

Expand Down
Binary file modified t/Test-consistency05.data
Binary file not shown.
Loading
Loading