Skip to content

Commit

Permalink
Merge pull request #1322 from mattias-p/1321-syntax04
Browse files Browse the repository at this point in the history
Make syntax04 take zone name instead of ns name
  • Loading branch information
mattias-p authored Apr 5, 2024
2 parents 089b058 + c53bbce commit 1858323
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
20 changes: 11 additions & 9 deletions lib/Zonemaster/Engine/Test/Syntax.pm
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,8 @@ sub all {

if ( any { $_->tag eq q{ONLY_ALLOWED_CHARS} } @results ) {

foreach my $local_nsname ( uniq map { $_ } @{ Zonemaster::Engine::TestMethods->method2( $zone ) },
@{ Zonemaster::Engine::TestMethods->method3( $zone ) } )
{
push @results, $class->syntax04( Zonemaster::Engine->zone( $local_nsname ) )
if Zonemaster::Engine::Util::should_run_test( q{syntax04} );
}
push @results, $class->syntax04( Zonemaster::Engine->zone( $zone ) )
if Zonemaster::Engine::Util::should_run_test( q{syntax04} );

push @results, $class->syntax05( $zone ) if Zonemaster::Engine::Util::should_run_test( q{syntax05} );

Expand Down Expand Up @@ -818,9 +814,15 @@ sub syntax04 {
local $Zonemaster::Engine::Logger::TEST_CASE_NAME = 'Syntax04';
push my @results, _emit_log( TEST_CASE_START => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } );

my $name = $zone->name;

push @results, _check_name_syntax( q{NAMESERVER}, $name );
foreach my $local_nsname (
uniq(
@{ Zonemaster::Engine::TestMethods->method2( $zone ) },
@{ Zonemaster::Engine::TestMethods->method3( $zone ) }
)
)
{
push @results, _check_name_syntax( q{NAMESERVER}, $zone->name );
}

return ( @results, _emit_log( TEST_CASE_END => { testcase => $Zonemaster::Engine::Logger::TEST_CASE_NAME } ) );
}
Expand Down
18 changes: 14 additions & 4 deletions t/Test-syntax.t
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,23 @@ zone_gives_not( q{syntax03}, $dn_idn_ok, q{DISCOURAGED_DOUBLE_DASH} );
zone_gives( q{syntax03}, $dn_ok, q{NO_DOUBLE_DASH} );
zone_gives( q{syntax03}, $dn_idn_ok, q{NO_DOUBLE_DASH} );

my $ns_double_dash = Zonemaster::Engine->zone( q{ns1.ns--nic.fr} );
zone_gives( q{syntax04}, $ns_double_dash, q{NAMESERVER_DISCOURAGED_DOUBLE_DASH} );
my $zone_double_dash = Zonemaster::Engine->zone( q{ns1.ns--nic.fr} );
zone_gives_not( q{syntax04}, $ns_ok, q{NAMESERVER_DISCOURAGED_DOUBLE_DASH} );
zone_gives_not( q{syntax04}, $zone_double_dash, q{NAMESERVER_DISCOURAGED_DOUBLE_DASH} );
SKIP: {
skip "need test zone", 1;
my $ns_num_tld; # TODO specify test zone
zone_gives( q{syntax04}, $ns_num_tld, q{NAMESERVER_NUMERIC_TLD} );
}

my $ns_num_tld = Zonemaster::Engine->zone( q{ns1.nic.47} );
zone_gives( q{syntax04}, $ns_num_tld, q{NAMESERVER_NUMERIC_TLD} );
my $zone_num_tld = Zonemaster::Engine->zone( q{ns1.nic.47} );
zone_gives_not( q{syntax04}, $ns_ok, q{NAMESERVER_NUMERIC_TLD} );
zone_gives_not( q{syntax04}, $zone_num_tld, q{NAMESERVER_NUMERIC_TLD} );
SKIP: {
skip "need test zone", 1;
my $ns_double_dash; # TODO specify test zone
zone_gives( q{syntax04}, $ns_double_dash, q{NAMESERVER_DISCOURAGED_DOUBLE_DASH} );
}

my %res;
my $zone;
Expand Down

0 comments on commit 1858323

Please sign in to comment.