Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates TestUtil.pm for unit tests #1340

Merged
merged 32 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6c19de9
Updates perform_testcase_testing() to support undelegated data plus t…
matsduf May 6, 2024
cbb0e5f
Adaption to updated TestUtil
matsduf May 6, 2024
8748e64
Corrects code errors
matsduf May 6, 2024
f4e6fdd
Corrects errors in the code
matsduf May 6, 2024
3dc5802
Corrects errors in one unit test
matsduf May 6, 2024
2454b53
Update t/TestUtil.pm
matsduf May 6, 2024
b029102
Editorial update from review comment
matsduf May 6, 2024
c19ead3
Adds some verification of "all tags" array
matsduf May 6, 2024
c6668a0
Clarification
matsduf May 6, 2024
d38dcf8
Adds documentation of the mechanism of undefined argument
matsduf May 6, 2024
c330a1d
Updates TestUtil.pm
matsduf May 7, 2024
9bc3e12
Adapts to updated TestUtils
matsduf May 7, 2024
dd0630d
Corrects NS name pattern
matsduf May 12, 2024
3987bd6
Adjusts error reporting
matsduf May 12, 2024
4263eba
Adapts to updated TestUtils
matsduf May 12, 2024
f46b5c6
Apply suggestions from code review
matsduf May 14, 2024
87dbe6c
Updates based on review comments
matsduf May 14, 2024
883c860
Update t/TestUtil.pm
matsduf May 15, 2024
5a114a6
Reorders the scenarios to be in same order as in the scenario specifi…
matsduf May 17, 2024
42c4cda
Adds five new scenarios
matsduf May 17, 2024
4936e86
Adds updated data
matsduf May 17, 2024
0367bb8
Reorders the scenarios to be in same order as in the scenario specifi…
matsduf May 18, 2024
c725b88
Adds two new scenarios
matsduf May 18, 2024
be9b4a7
Adds updated data
matsduf May 18, 2024
354471a
Editorial updates
matsduf May 21, 2024
ae82da2
Apply suggestions from code review
matsduf May 21, 2024
345c038
Editorial updates
matsduf May 21, 2024
ed80af8
Adds correct handling of empty tag arrays
matsduf May 21, 2024
f566274
Corrects and change logic: both arrays empty not permitted
matsduf May 22, 2024
d538a14
Apply suggestions from code review
matsduf May 22, 2024
7d11932
Editorial update
matsduf May 22, 2024
0bc6dcd
Apply suggestions from code review
matsduf May 22, 2024
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
174 changes: 99 additions & 75 deletions t/Test-consistency05.data

Large diffs are not rendered by default.

197 changes: 143 additions & 54 deletions t/Test-consistency05.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ BEGIN {

my $test_module = q{Consistency};
my $test_case = 'consistency05';
my @all_tags = qw(ADDRESSES_MATCH
IN_BAILIWICK_ADDR_MISMATCH
OUT_OF_BAILIWICK_ADDR_MISMATCH
EXTRA_ADDRESS_CHILD
CHILD_ZONE_LAME
CHILD_NS_FAILED
NO_RESPONSE);

# Common hint file (test-zone-data/COMMON/hintfile)
Zonemaster::Engine::Recursor->remove_fake_addresses( '.' );
Expand All @@ -28,97 +35,179 @@ Zonemaster::Engine::Recursor->add_fake_addresses( '.',
}
);

# Test scenarios
# Test zone scenarios
# - Documentation: L<TestUtil/perform_testcase_testing()>
# - Format: { SCENARIO_NAME => [ zone_name, [ MANDATORY_MESSAGE_TAGS ], [ FORBIDDEN_MESSAGE_TAGS ], testable ] }
# - Format: { SCENARIO_NAME => [
# testable,
# zone_name,
# [ MANDATORY_MESSAGE_TAGS ],
# [ FORBIDDEN_MESSAGE_TAGS ],
# [ UNDELEGATED_NS ],
# [ UNDELEGATED_DS ],
# ] }
#
# - One of MANDATORY_MESSAGE_TAGS and FORBIDDEN_MESSAGE_TAGS may be undefined.
# See documentation for the meaning of that.

# Scenarios CHILD-ZONE-LAME-1 and IB-ADDR-MISMATCH-3 cannot be tested due to a bug in the implementation. See
# https://github.com/zonemaster/zonemaster-engine/issues/1301
#

# Scenario IB-ADDR-MISMATCH-4 cannot be tested, see
# https://github.com/zonemaster/zonemaster-engine/issues/1349


my %subtests = (
'ADDRESSES-MATCH-1' => [
1,
q(addresses-match-1.consistency05.xa),
[ qw(ADDRESSES_MATCH) ],
undef,
[],
[]
],
'ADDRESSES-MATCH-2' => [
1,
q(addresses-match-2.consistency05.xa),
[ qw(ADDRESSES_MATCH) ],
undef,
[],
[]
],
'ADDRESSES-MATCH-3' => [
1,
q(addresses-match-3.consistency05.xa),
[ qw(ADDRESSES_MATCH CHILD_NS_FAILED) ],
undef,
[],
[]
],
'ADDRESSES-MATCH-4' => [
1,
q(addresses-match-4.consistency05.xa),
[ qw(ADDRESSES_MATCH CHILD_NS_FAILED) ],
[ qw(IN_BAILIWICK_ADDR_MISMATCH OUT_OF_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD CHILD_ZONE_LAME NO_RESPONSE) ],
undef,
[],
[]
],
'ADDRESSES-MATCH-5' => [
1,
q(addresses-match-5.consistency05.xa),
[ qw(ADDRESSES_MATCH NO_RESPONSE) ],
undef,
[],
[]
],
'CHILD-ZONE-LAME-1' => [
q(child-zone-lame-1.consistency05.xa),
[ qw(CHILD_ZONE_LAME NO_RESPONSE) ],
[ qw(IN_BAILIWICK_ADDR_MISMATCH OUT_OF_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD CHILD_NS_FAILED ADDRESSES_MATCH) ],
0,
'ADDRESSES-MATCH-6' => [
1,
q(child.addresses-match-6.consistency05.xa),
[ qw(ADDRESSES_MATCH) ],
undef,
[],
[]
],
'ADDRESSES-MATCH-1' => [
q(addresses-match-1.consistency05.xa),
'ADDRESSES-MATCH-7' => [
1,
q(addresses-match-7.consistency05.xa),
[ qw(ADDRESSES_MATCH) ],
[ qw(IN_BAILIWICK_ADDR_MISMATCH OUT_OF_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD CHILD_ZONE_LAME CHILD_NS_FAILED NO_RESPONSE) ],
undef,
[],
[]
],
'ADDR-MATCH-DEL-UNDEL-1' => [
1,
q(addr-match-del-undel-1.consistency05.xa),
[ qw(ADDRESSES_MATCH) ],
undef,
[ qw(ns3.addr-match-del-undel-1.consistency05.xa/127.14.5.33 ns3.addr-match-del-undel-1.consistency05.xa/fda1:b2:c3:0:127:14:5:33 ns4.addr-match-del-undel-1.consistency05.xa/127.14.5.34 ns4.addr-match-del-undel-1.consistency05.xa/fda1:b2:c3:0:127:14:5:34) ],
[]
],
'IB-ADDR-MISMATCH-2' => [
q(ib-addr-mismatch-2.consistency05.xa),
[ qw(IN_BAILIWICK_ADDR_MISMATCH) ],
[ qw(OUT_OF_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD CHILD_ZONE_LAME CHILD_NS_FAILED NO_RESPONSE ADDRESSES_MATCH) ],
'ADDR-MATCH-DEL-UNDEL-2' => [
1,
q(addr-match-del-undel-2.consistency05.xa),
[ qw(ADDRESSES_MATCH) ],
undef,
[ qw(ns3.addr-match-del-undel-2.consistency05.xb ns4.addr-match-del-undel-2.consistency05.xb) ],
[]
],
'ADDRESSES-MATCH-5' => [
q(addresses-match-5.consistency05.xa),
[ qw(ADDRESSES_MATCH NO_RESPONSE) ],
[ qw(IN_BAILIWICK_ADDR_MISMATCH OUT_OF_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD CHILD_ZONE_LAME CHILD_NS_FAILED) ],
'ADDR-MATCH-NO-DEL-UNDEL-1' => [
1,
q(addr-match-no-del-undel-1.consistency05.xa),
[ qw(ADDRESSES_MATCH) ],
undef,
[ qw(ns1.addr-match-no-del-undel-1.consistency05.xa/127.14.5.31 ns1.addr-match-no-del-undel-1.consistency05.xa/fda1:b2:c3:0:127:14:5:31 ns2.addr-match-no-del-undel-1.consistency05.xa/127.14.5.32 ns2.addr-match-no-del-undel-1.consistency05.xa/fda1:b2:c3:0:127:14:5:32) ],
[]
],
'IB-ADDR-MISMATCH-1' => [
q(ib-addr-mismatch-1.consistency05.xa),
[ qw(IN_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD) ],
[ qw(OUT_OF_BAILIWICK_ADDR_MISMATCH CHILD_ZONE_LAME CHILD_NS_FAILED NO_RESPONSE ADDRESSES_MATCH) ],
'ADDR-MATCH-NO-DEL-UNDEL-2' => [
1,
q(addr-match-no-del-undel-2.consistency05.xa),
[ qw(ADDRESSES_MATCH) ],
undef,
[ qw(ns3.addr-match-no-del-undel-2.consistency05.xb ns4.addr-match-no-del-undel-2.consistency05.xb) ],
[]
],
'CHILD-ZONE-LAME-1' => [
0,
q(child-zone-lame-1.consistency05.xa),
[ qw(CHILD_ZONE_LAME NO_RESPONSE) ],
undef,
[],
[]
],
'CHILD-ZONE-LAME-2' => [
1,
q(child-zone-lame-2.consistency05.xa),
[ qw(CHILD_ZONE_LAME CHILD_NS_FAILED) ],
[ qw(IN_BAILIWICK_ADDR_MISMATCH OUT_OF_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD ADDRESSES_MATCH NO_RESPONSE) ],
1,
undef,
[],
[]
],
'ADDRESSES-MATCH-6' => [
q(child.addresses-match-6.consistency05.xa),
[ qw(ADDRESSES_MATCH) ],
[ qw(IN_BAILIWICK_ADDR_MISMATCH OUT_OF_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD CHILD_ZONE_LAME CHILD_NS_FAILED NO_RESPONSE) ],
'IB-ADDR-MISMATCH-1' => [
1,
q(ib-addr-mismatch-1.consistency05.xa),
[ qw(IN_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD) ],
undef,
[],
[]
],
'ADDRESSES-MATCH-2' => [
q(addresses-match-2.consistency05.xa),
[ qw(ADDRESSES_MATCH) ],
[ qw(IN_BAILIWICK_ADDR_MISMATCH OUT_OF_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD CHILD_ZONE_LAME CHILD_NS_FAILED NO_RESPONSE) ],
'IB-ADDR-MISMATCH-2' => [
1,
q(ib-addr-mismatch-2.consistency05.xa),
[ qw(IN_BAILIWICK_ADDR_MISMATCH) ],
undef,
[],
[]
],
'IB-ADDR-MISMATCH-3' => [
0,
q(ib-addr-mismatch-3.consistency05.xa),
[ qw(IN_BAILIWICK_ADDR_MISMATCH NO_RESPONSE) ],
[ qw(OUT_OF_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD CHILD_ZONE_LAME CHILD_NS_FAILED NO_RESPONSE ADDRESSES_MATCH) ],
0,
],
'ADDRESSES-MATCH-7' => [
q(addresses-match-7.consistency05.xa),
[ qw(ADDRESSES_MATCH) ],
[ qw(IN_BAILIWICK_ADDR_MISMATCH OUT_OF_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD CHILD_ZONE_LAME CHILD_NS_FAILED NO_RESPONSE) ],
1,
undef,
[],
[]
],
'EXTRA-ADDRESS-CHILD' => [
q(extra-address-child.consistency05.xa),
[ qw(EXTRA_ADDRESS_CHILD) ],
[ qw(IN_BAILIWICK_ADDR_MISMATCH OUT_OF_BAILIWICK_ADDR_MISMATCH CHILD_ZONE_LAME CHILD_NS_FAILED NO_RESPONSE ADDRESSES_MATCH) ],
1,
'IB-ADDR-MISMATCH-4' => [
0,
q(ib-addr-mismatch-4.consistency05.xa),
[ qw(IN_BAILIWICK_ADDR_MISMATCH) ],
undef,
[],
[]
],
'OOB-ADDR-MISMATCH' => [
1,
q(child.oob-addr-mismatch.consistency05.xa),
[ qw(OUT_OF_BAILIWICK_ADDR_MISMATCH) ],
[ qw(IN_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD CHILD_ZONE_LAME CHILD_NS_FAILED NO_RESPONSE ADDRESSES_MATCH) ],
1,
undef,
[],
[]
],
'ADDRESSES-MATCH-3' => [
q(addresses-match-3.consistency05.xa),
[ qw(ADDRESSES_MATCH CHILD_NS_FAILED) ],
[ qw(IN_BAILIWICK_ADDR_MISMATCH OUT_OF_BAILIWICK_ADDR_MISMATCH EXTRA_ADDRESS_CHILD CHILD_ZONE_LAME NO_RESPONSE) ],
'EXTRA-ADDRESS-CHILD' => [
1,
q(extra-address-child.consistency05.xa),
[ qw(EXTRA_ADDRESS_CHILD) ],
undef,
[],
[]
],
);

Expand All @@ -134,7 +223,7 @@ if ( not $ENV{ZONEMASTER_RECORD} ) {

Zonemaster::Engine::Profile->effective->merge( Zonemaster::Engine::Profile->from_json( qq({ "test_cases": [ "$test_case" ] }) ) );

perform_testcase_testing( $test_case, $test_module, %subtests );
perform_testcase_testing( $test_case, $test_module, \@all_tags, %subtests );

if ( $ENV{ZONEMASTER_RECORD} ) {
Zonemaster::Engine::Nameserver->save( $datafile );
Expand Down
76 changes: 46 additions & 30 deletions t/Test-consistency06.data

Large diffs are not rendered by default.

97 changes: 70 additions & 27 deletions t/Test-consistency06.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ BEGIN {

my $test_module = q{Consistency};
my $test_case = 'consistency06';
my @all_tags = qw(ONE_SOA_MNAME
NO_RESPONSE
NO_RESPONSE_SOA_QUERY
MULTIPLE_SOA_MNAMES);

# Common hint file (test-zone-data/COMMON/hintfile)
Zonemaster::Engine::Recursor->remove_fake_addresses( '.' );
Expand All @@ -28,57 +32,96 @@ Zonemaster::Engine::Recursor->add_fake_addresses( '.',
}
);

# Test scenarios
# Test zone scenarios
# - Documentation: L<TestUtil/perform_testcase_testing()>
# - Format: { SCENARIO_NAME => [ zone_name, [ MANDATORY_MESSAGE_TAGS ], [ FORBIDDEN_MESSAGE_TAGS ], testable ] }
# - Format: { SCENARIO_NAME => [
# testable,
# zone_name,
# [ MANDATORY_MESSAGE_TAGS ],
# [ FORBIDDEN_MESSAGE_TAGS ],
# [ UNDELEGATED_NS ],
# [ UNDELEGATED_DS ],
# ] }
#
# - One of MANDATORY_MESSAGE_TAGS and FORBIDDEN_MESSAGE_TAGS may be undefined.
# See documentation for the meaning of that.

# Scenarios ONE-SOA-MNAME-4 and NO-RESPONSE cannot be tested due to a bug in the implementation. See
# https://github.com/zonemaster/zonemaster-engine/issues/1300
#

###########
my %subtests = (
'ONE-SOA-MNAME-2' => [
q(one-soa-mname-2.consistency06.xa),
[ qw(ONE_SOA_MNAME NO_RESPONSE) ],
[ qw(NO_RESPONSE_SOA_QUERY MULTIPLE_SOA_MNAMES) ],
1,
],
'ONE-SOA-MNAME-1' => [
1,
q(one-soa-mname-1.consistency06.xa),
[ qw(ONE_SOA_MNAME) ],
[ qw(NO_RESPONSE NO_RESPONSE_SOA_QUERY MULTIPLE_SOA_MNAMES) ],
1,
],
'NO-RESPONSE' => [
q(no-response.consistency06.xa),
[ qw(NO_RESPONSE) ],
[ qw(NO_RESPONSE_SOA_QUERY MULTIPLE_SOA_MNAMES ONE_SOA_MNAME) ],
0,
undef,
[],
[]
],
'MULTIPLE-SOA-MNAMES-1' => [
q(multiple-soa-mnames-1.consistency06.xa),
[ qw(MULTIPLE_SOA_MNAMES) ],
[ qw(NO_RESPONSE NO_RESPONSE_SOA_QUERY ONE_SOA_MNAME) ],
'ONE-SOA-MNAME-2' => [
1,
q(one-soa-mname-2.consistency06.xa),
[ qw(ONE_SOA_MNAME NO_RESPONSE) ],
undef,
[],
[]
],
'ONE-SOA-MNAME-3' => [
1,
q(one-soa-mname-3.consistency06.xa),
[ qw(ONE_SOA_MNAME NO_RESPONSE_SOA_QUERY) ],
[ qw(NO_RESPONSE MULTIPLE_SOA_MNAMES) ],
1,
undef,
[],
[]
],
'ONE-SOA-MNAME-4' => [
0,
q(one-soa-mname-4.consistency06.xa),
[ qw(ONE_SOA_MNAME NO_RESPONSE) ],
[ qw(NO_RESPONSE_SOA_QUERY MULTIPLE_SOA_MNAMES) ],
0,
undef,
[],
[]
],
'MULTIPLE-SOA-MNAMES-1' => [
1,
q(multiple-soa-mnames-1.consistency06.xa),
[ qw(MULTIPLE_SOA_MNAMES) ],
undef,
[],
[]
],
'MULTIPLE-SOA-MNAMES-2' => [
1,
q(multiple-soa-mnames-2.consistency06.xa),
[ qw(MULTIPLE_SOA_MNAMES NO_RESPONSE) ],
[ qw(NO_RESPONSE_SOA_QUERY ONE_SOA_MNAME) ],
undef,
[],
[]
],
'MULT-SOA-MNAMES-NO-DEL-UNDEL-1' => [
1,
q(mult-soa-mnames-no-del-undel-1.consistency06.xa),
[ qw(MULTIPLE_SOA_MNAMES) ],
undef,
[ qw(ns1.mult-soa-mnames-no-del-undel-1.consistency06.xa/127.14.6.31 ns1.mult-soa-mnames-no-del-undel-1.consistency06.xa/fda1:b2:c3:0:127:14:6:31 ns2.mult-soa-mnames-no-del-undel-1.consistency06.xa/127.14.6.32 ns2.mult-soa-mnames-no-del-undel-1.consistency06.xa/fda1:b2:c3:0:127:14:6:32) ],
[]
],
'MULT-SOA-MNAMES-NO-DEL-UNDEL-2' => [
0,
q(mult-soa-mnames-no-del-undel-2.consistency06.xa),
[ qw(MULTIPLE_SOA_MNAMES) ],
undef,
[ qw(ns3.mult-soa-mnames-no-del-undel-2.consistency06.xb ns3.mult-soa-mnames-no-del-undel-2.consistency06.xb) ],
[]
],
'NO-RESPONSE' => [
0,
q(no-response.consistency06.xa),
[ qw(NO_RESPONSE) ],
undef,
[],
[]
],
);

Expand All @@ -92,7 +135,7 @@ if ( not $ENV{ZONEMASTER_RECORD} ) {

Zonemaster::Engine::Profile->effective->merge( Zonemaster::Engine::Profile->from_json( qq({ "test_cases": [ "$test_case" ] }) ) );

perform_testcase_testing( $test_case, $test_module, %subtests );
perform_testcase_testing( $test_case, $test_module, \@all_tags, %subtests );

if ( $ENV{ZONEMASTER_RECORD} ) {
Zonemaster::Engine::Nameserver->save( $datafile );
Expand Down
Loading
Loading