File: Test-delegation02.t

package info (click to toggle)
libzonemaster-perl 7.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 67,672 kB
  • sloc: perl: 16,806; makefile: 16
file content (170 lines) | stat: -rw-r--r-- 5,760 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
use strict;
use warnings;

use Test::More;
use File::Basename;
use File::Spec::Functions qw( rel2abs );
use lib dirname( rel2abs( $0 ) );

BEGIN {
    use_ok( q{Zonemaster::Engine} );
    use_ok( q{Zonemaster::Engine::Test::Delegation} );
    use_ok( q{TestUtil}, qw( perform_testcase_testing ) );
}

###########
# Delegation02 - https://github.com/zonemaster/zonemaster/blob/master/docs/public/specifications/test-zones/Delegation-TP/delegation02.md
my $test_module = 'Delegation';
my $test_case = 'delegation02';
my @all_tags = qw(
                  DEL_DISTINCT_NS_IP
                  CHILD_DISTINCT_NS_IP
                  DEL_NS_SAME_IP
                  CHILD_NS_SAME_IP
                 );

# Specific hint file (https://github.com/zonemaster/zonemaster/blob/master/test-zone-data/Delegation-TP/delegation02/hintfile.zone)
Zonemaster::Engine::Recursor->remove_fake_addresses( '.' );
Zonemaster::Engine::Recursor->add_fake_addresses( '.',
    { 'root-ns1.xa' => [ '127.16.2.27', 'fda1:b2:c3::127:16:2:27' ],
      'root-ns2.xa' => [ '127.16.2.28', 'fda1:b2:c3::127:16:2:28' ],
    }
);

# Test zone scenarios
# - Documentation: L<TestUtil/perform_testcase_testing()>
# - 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.

my %subtests = (
                'ALL-DISTINCT-1' =>
                [
                 1,
                 q(all-distinct-1.delegation02.xa),
                 [ qw( DEL_DISTINCT_NS_IP CHILD_DISTINCT_NS_IP ) ],
                 undef,
                 [],
                 [],
                ],
                'ALL-DISTINCT-2' =>
                [
                 1,
                 q(all-distinct-2.delegation02.xa),
                 [ qw( DEL_DISTINCT_NS_IP CHILD_DISTINCT_NS_IP ) ],
                 undef,
                 [],
                 [],
                ],
                'ALL-DISTINCT-3' =>
                [
                 1,
                 q(all-distinct-3.delegation02.xa),
                 [ qw( DEL_DISTINCT_NS_IP CHILD_DISTINCT_NS_IP ) ],
                 undef,
                 [],
                 [],
                ],
                'DEL-NON-DISTINCT' =>
                [
                 0,
                 q(del-non-distinct.delegation02.xa),
                 [ qw( DEL_NS_SAME_IP CHILD_DISTINCT_NS_IP ) ],
                 undef,
                 [],
                 [],
                ],
                'DEL-NON-DISTINCT-UND' =>
                [
                 1,
                 q(del-non-distinct.delegation02.xa),
                 [ qw( DEL_NS_SAME_IP CHILD_DISTINCT_NS_IP ) ],
                 undef,
                 [ qw(
                       ns1a.del-non-distinct-und.delegation02.xa/127.16.2.31
                       ns1a.del-non-distinct-und.delegation02.xa/fda1:b2:c3:0:127:16:2:31
                       ns1b.del-non-distinct-und.delegation02.xa/127.16.2.31
                       ns1b.del-non-distinct-und.delegation02.xa/fda1:b2:c3:0:127:16:2:31
                       )
                 ],
                 [],
                ],
                'CHILD-NON-DISTINCT' =>
                [
                 0,
                 q(child-non-distinct.delegation02.xa),
                 [ qw( DEL_DISTINCT_NS_IP CHILD_NS_SAME_IP ) ],
                 undef,
                 [],
                 [],
                ],
                'CHILD-NON-DISTINCT-UND' =>
                [
                 1,
                 q(child-non-distinct.delegation02.xa),
                 [ qw( DEL_DISTINCT_NS_IP CHILD_NS_SAME_IP ) ],
                 undef,
                 [ qw(
                       ns1a.child-non-distinct-und.delegation02.xa/127.16.2.31
                       ns1a.child-non-distinct-und.delegation02.xa/fda1:b2:c3:0:127:16:2:31
                       ns1b.child-non-distinct-und.delegation02.xa/127.16.2.32
                       ns1b.child-non-distinct-und.delegation02.xa/fda1:b2:c3:0:127:16:2:32
                       )
                 ],
                 [],
                ],
                'NON-DISTINCT-1' =>
                [
                 1,
                 q(non-distinct-1.delegation02.xa),
                 [ qw( DEL_NS_SAME_IP CHILD_NS_SAME_IP ) ],
                 undef,
                 [],
                 [],
                ],
                'NON-DISTINCT-2' =>
                [
                 1,
                 q(non-distinct-2.delegation02.xa),
                 [ qw( DEL_NS_SAME_IP CHILD_NS_SAME_IP ) ],
                 undef,
                 [],
                 [],
                ],
                'NON-DISTINCT-3' =>
                [
                 1,
                 q(non-distinct-3.delegation02.xa),
                 [ qw( DEL_NS_SAME_IP CHILD_NS_SAME_IP ) ],
                 undef,
                 [],
                 [],
                ],
               );
###########

my $datafile = 't/' . basename ($0, '.t') . '.data';

if ( not $ENV{ZONEMASTER_RECORD} ) {
    die q{Stored data file missing} if not -r $datafile;
    Zonemaster::Engine::Nameserver->restore( $datafile );
    Zonemaster::Engine::Profile->effective->set( q{no_network}, 1 );
}

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

perform_testcase_testing( $test_case, $test_module, \@all_tags, \%subtests, $ENV{ZONEMASTER_SINGLE_SCENARIO}, $ENV{ZONEMASTER_DISABLE_SCENARIO} );

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

done_testing;