Skip to content

Commit

Permalink
Merge pull request #1192 from matsduf/fix-broken-unit-tests
Browse files Browse the repository at this point in the history
Fixes broken unit tests
  • Loading branch information
matsduf authored Dec 4, 2024
2 parents dfb8665 + f818cf1 commit c29b3bd
Show file tree
Hide file tree
Showing 6 changed files with 312 additions and 113 deletions.
1 change: 0 additions & 1 deletion t/TestUtil.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ sub restore_datafile {
die q{Stored data file missing} if not -r $datafile;
Zonemaster::Engine->preload_cache( $datafile );
Zonemaster::Engine->profile->set( q{no_network}, 1 );
diag "not recording";
} else {
diag "recording";
}
Expand Down
18 changes: 16 additions & 2 deletions t/idn.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ my $datafile = "$t_path/idn.data";
TestUtil::restore_datafile( $datafile );

my $tempdir = tempdir( CLEANUP => 1 );
my $config = Zonemaster::Backend::Config->parse( <<EOF );

my $configuration = <<"EOF";
[DB]
engine = $db_backend
Expand All @@ -46,10 +47,23 @@ database_file = $tempdir/zonemaster.sqlite
[LANGUAGE]
locale = en_US
EOF

if ( $ENV{ZONEMASTER_RECORD} ) {
$configuration .= <<"EOF";
[PUBLIC PROFILES]
test_profile=$t_path/test_profile_network_true.json
default=$t_path/test_profile_network_true.json
EOF
} else {
$configuration .= <<"EOF";
[PUBLIC PROFILES]
test_profile=$t_path/test_profile.json
test_profile=$t_path/test_profile_no_network.json
default=$t_path/test_profile_no_network.json
EOF
}

my $config = Zonemaster::Backend::Config->parse( $configuration );

my $db = TestUtil::init_db( $config );
my $agent = TestUtil::create_testagent( $config );
Expand Down
211 changes: 108 additions & 103 deletions t/test01.data

Large diffs are not rendered by default.

25 changes: 18 additions & 7 deletions t/test01.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ my $datafile = "$t_path/test01.data";
TestUtil::restore_datafile( $datafile );

my $tempdir = tempdir( CLEANUP => 1 );
my $config = Zonemaster::Backend::Config->parse( <<EOF );

my $configuration = <<"EOF";
[DB]
engine = $db_backend
Expand All @@ -46,10 +47,23 @@ database_file = $tempdir/zonemaster.sqlite
[LANGUAGE]
locale = en_US
EOF

if ( $ENV{ZONEMASTER_RECORD} ) {
$configuration .= <<"EOF";
[PUBLIC PROFILES]
test_profile=$t_path/test_profile_network_true.json
default=$t_path/test_profile_network_true.json
EOF
} else {
$configuration .= <<"EOF";
[PUBLIC PROFILES]
test_profile=$t_path/test_profile.json
test_profile=$t_path/test_profile_no_network.json
default=$t_path/test_profile_no_network.json
EOF
}

my $config = Zonemaster::Backend::Config->parse( $configuration );

my $rpcapi = TestUtil::create_rpcapi( $config );

Expand Down Expand Up @@ -181,7 +195,6 @@ subtest 'API calls' => sub {

my @ns_list = map { $_->{ns} } @{ $res->{ns_list} };
ok( grep( /d\.nic\.fr/, @ns_list ), 'Has "d.nic.fr" nameserver' );
ok( grep( /e\.ext\.nic\.fr/, @ns_list ), 'Has "e.ext.nic.fr" nameserver' );
ok( grep( /f\.ext\.nic\.fr/, @ns_list ), 'Has "f.ext.nic.fr" nameserver' );
ok( grep( /g\.ext\.nic\.fr/, @ns_list ), 'Has "g.ext.nic.fr" nameserver' );

Expand All @@ -190,16 +203,14 @@ subtest 'API calls' => sub {
ok( grep( /2001:678:c::1/, @ip_list ), 'Has "2001:678:c::1" ip' );
ok( grep( /194\.0\.36\.1/, @ip_list ), 'Has "194.0.36.1" ip' ); # g.ext.nic.fr
ok( grep( /2001:678:4c::1/, @ip_list ), 'Has "2001:678:4c::1" ip' );
ok( grep( /193\.176\.144\.22/, @ip_list ), 'Has "193.176.144.22" ip' ); # e.ext.nic.fr
ok( grep( /2a00:d78:0:102:193:176:144:22/, @ip_list ), 'Has "2a00:d78:0:102:193:176:144:22" ip' );
ok( grep( /194\.146\.106\.46/, @ip_list ), 'Has "194.146.106.46" ip' ); # f.ext.nic.fr
ok( grep( /2001:67c:1010:11::53/, @ip_list ), 'Has "2001:67c:1010:11::53" ip' );

my $ds_value = {
'algorithm' => 13,
'digest' => '1b3386864d30ccc8f4541b985bf2ca320e4f52c57c53353f6d29c9ad58a5671f',
'digest' => '1303e8da8fb60db500d5bea1ee5dc9a2bcc93dfe2fc43d346576658feccf5749', # must match case
'digtype' => 2,
'keytag' => 51508
'keytag' => 29133
};
is( scalar( @{ $res->{ds_list} } ), 1, 'Has only one DS set' );
is_deeply( $res->{ds_list}[0], $ds_value, 'Has correct DS values' );
Expand Down
85 changes: 85 additions & 0 deletions t/test_profile_network_true.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"no_network" : false,
"logfilter": {
"BASIC":{
"IPV6_DISABLED" : [
{
"when": {
"rrtype": [ "SOA", "NS" ]
},
"set": "INFO"
}
]
}
},
"test_cases": [
"address01",
"address02",
"address03",
"basic00",
"basic01",
"basic02",
"basic03",
"connectivity01",
"connectivity02",
"connectivity03",
"consistency01",
"consistency02",
"consistency03",
"consistency04",
"consistency05",
"consistency06",
"dnssec01",
"dnssec02",
"dnssec03",
"dnssec04",
"dnssec05",
"dnssec07",
"dnssec06",
"dnssec08",
"dnssec09",
"dnssec10",
"dnssec11",
"dnssec13",
"dnssec14",
"dnssec15",
"dnssec16",
"dnssec17",
"dnssec18",
"delegation01",
"delegation02",
"delegation03",
"delegation04",
"delegation05",
"delegation06",
"delegation07",
"nameserver01",
"nameserver02",
"nameserver04",
"nameserver05",
"nameserver06",
"nameserver07",
"nameserver10",
"nameserver11",
"nameserver12",
"nameserver13",
"syntax01",
"syntax02",
"syntax03",
"syntax04",
"syntax05",
"syntax06",
"syntax07",
"syntax08",
"zone01",
"zone02",
"zone03",
"zone04",
"zone05",
"zone06",
"zone07",
"zone08",
"zone09",
"zone10"
]
}
85 changes: 85 additions & 0 deletions t/test_profile_no_network.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"no_network" : true,
"logfilter": {
"BASIC":{
"IPV6_DISABLED" : [
{
"when": {
"rrtype": [ "SOA", "NS" ]
},
"set": "INFO"
}
]
}
},
"test_cases": [
"address01",
"address02",
"address03",
"basic00",
"basic01",
"basic02",
"basic03",
"connectivity01",
"connectivity02",
"connectivity03",
"consistency01",
"consistency02",
"consistency03",
"consistency04",
"consistency05",
"consistency06",
"dnssec01",
"dnssec02",
"dnssec03",
"dnssec04",
"dnssec05",
"dnssec07",
"dnssec06",
"dnssec08",
"dnssec09",
"dnssec10",
"dnssec11",
"dnssec13",
"dnssec14",
"dnssec15",
"dnssec16",
"dnssec17",
"dnssec18",
"delegation01",
"delegation02",
"delegation03",
"delegation04",
"delegation05",
"delegation06",
"delegation07",
"nameserver01",
"nameserver02",
"nameserver04",
"nameserver05",
"nameserver06",
"nameserver07",
"nameserver10",
"nameserver11",
"nameserver12",
"nameserver13",
"syntax01",
"syntax02",
"syntax03",
"syntax04",
"syntax05",
"syntax06",
"syntax07",
"syntax08",
"zone01",
"zone02",
"zone03",
"zone04",
"zone05",
"zone06",
"zone07",
"zone08",
"zone09",
"zone10"
]
}

0 comments on commit c29b3bd

Please sign in to comment.