xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/cds/tests.sh (revision 2718af68c3efc72c9769069b5c7f9ed36f6b9def)
1#!/bin/sh -e
2#
3# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4#
5# This Source Code Form is subject to the terms of the Mozilla Public
6# License, v. 2.0. If a copy of the MPL was not distributed with this
7# file, you can obtain one at https://mozilla.org/MPL/2.0/.
8#
9# See the COPYRIGHT file distributed with this work for additional
10# information regarding copyright ownership.
11
12SYSTEMTESTTOP=..
13. $SYSTEMTESTTOP/conf.sh
14
15status=0
16n=0
17fail() {
18	echo_i "failed"
19	status=`expr $status + 1`
20}
21
22runcmd() {
23        "$@" 1> out.$n 2> err.$n
24	echo $?
25}
26
27testcase() {
28	n=`expr $n + 1`
29	echo_i "$name ($n)"
30	expect=$1
31	shift
32	result=`runcmd "$@"`
33	check_stdout
34	check_stderr
35	if [ "$expect" -ne "$result" ]; then
36                echo_d "exit status does not match $expect"
37		fail
38	fi
39        unset name err out
40}
41
42check_stderr() {
43	if [ -n "${err:=}" ]; then
44		egrep "$err" err.$n >/dev/null && return 0
45	else
46		[ -s err.$n ] || return 0
47	fi
48	echo_d "stderr did not match '$err'"
49	cat err.$n | cat_d
50	fail
51}
52
53check_stdout() {
54	$DIFF out.$n "${out:-empty}" >/dev/null && return
55	echo_d "stdout did not match '$out'"
56	(	echo "wanted"
57		cat "$out"
58		echo "got"
59		cat out.$n
60	) | cat_d
61	fail
62}
63
64Z=cds.test
65
66name='usage'
67err='Usage'
68testcase 1 $CDS
69
70name='need a DS file'
71err='DS pathname'
72testcase 1 $CDS $Z
73
74name='name of dsset in directory'
75err="./dsset-$Z.: file not found"
76testcase 1 $CDS -d . $Z
77
78name='load a file'
79err='could not find DS records'
80testcase 1 $CDS -d empty $Z
81
82name='load DS records'
83err='path to file containing child data must be specified'
84testcase 1 $CDS -d DS.1 $Z
85
86name='missing DNSKEY'
87err='could not find signed DNSKEY RRset'
88testcase 1 $CDS -f db.null -d DS.1 $Z
89
90name='sigs too old'
91err='could not validate child DNSKEY RRset'
92testcase 1 $CDS -f sig.null -d DS.1 $Z
93
94name='sigs too old, verbosely'
95err='skip RRSIG by key [0-9]+: too old'
96testcase 1 $CDS -v1 -f sig.null -d DS.1 $Z
97
98name='old sigs are allowed'
99err='found RRSIG by key'
100out=DS.1
101testcase 0 $CDS -v1 -s -7200 -f sig.null -d DS.1 $Z
102
103name='no CDS/CDNSKEY records'
104out=DS.1
105testcase 0 $CDS -s -7200 -f sig.null -d DS.1 $Z
106
107name='no child records, verbosely'
108err='has neither CDS nor CDNSKEY records'
109out=DS.1
110testcase 0 $CDS -v1 -s -7200 -f sig.null -d DS.1 $Z
111
112name='unsigned CDS'
113err='missing RRSIG CDS records'
114testcase 1 $CDS -f brk.unsigned-cds -d DS.1 $Z
115
116name='correct signature inception time'
117$CDS -v3 -s -7200 -f sig.cds.1 -d DS.1 $Z 1>xout 2>xerr
118testcase 0 $PERL checktime.pl 3600 xerr
119
120name='in-place reads modification time'
121testcase 0 $CDS -f sig.cds.1 -i.bak -d DS.inplace $Z
122
123name='in-place output correct modification time'
124testcase 0 $PERL checkmtime.pl 3600 DS.inplace
125
126name='in-place backup correct modification time'
127testcase 0 $PERL checkmtime.pl 7200 DS.inplace.bak
128
129name='in-place correct output'
130testcase 0 $DIFF DS.1 DS.inplace
131
132name='in-place backup unmodified'
133testcase 0 $DIFF DS.1 DS.inplace.bak
134
135name='one mangled DS'
136err='found RRSIG by key'
137out=DS.1
138testcase 0 $CDS -v1 -s -7200 -f sig.cds.1 -d DS.broke1 $Z
139
140name='other mangled DS'
141err='found RRSIG by key'
142out=DS.1
143testcase 0 $CDS -v1 -s -7200 -f sig.cds.1 -d DS.broke2 $Z
144
145name='both mangled DS'
146err='could not validate child DNSKEY RRset'
147testcase 1 $CDS -v1 -s -7200 -f sig.cds.1 -d DS.broke12 $Z
148
149name='mangle RRSIG CDS by ZSK'
150err='found RRSIG by key'
151out=DS.1
152testcase 0 $CDS -v1 -s -7200 -f brk.rrsig.cds.zsk -d DS.1 $Z
153
154name='mangle RRSIG CDS by KSK'
155err='could not validate child CDS RRset'
156testcase 1 $CDS -v1 -s -7200 -f brk.rrsig.cds.ksk -d DS.1 $Z
157
158name='mangle CDS 1'
159err='could not validate child DNSKEY RRset with new DS records'
160testcase 1 $CDS -s -7200 -f sig.cds-mangled -d DS.1 $Z
161
162name='inconsistent digests'
163err='do not cover each key with the same set of digest types'
164testcase 1 $CDS -s -7200 -f sig.bad-digests -d DS.1 $Z
165
166name='inconsistent algorithms'
167err='missing signature for algorithm'
168testcase 1 $CDS -s -7200 -f sig.bad-algos -d DS.1 $Z
169
170name='add DS records'
171out=DS.both
172$CDS -s -7200 -f sig.cds.both -d DS.1 $Z >DS.out
173# sort to allow for numerical vs lexical order of key tags
174testcase 0 sort DS.out
175
176name='update add'
177out=UP.add2
178testcase 0 $CDS -u -s -7200 -f sig.cds.both -d DS.1 $Z
179
180name='remove DS records'
181out=DS.2
182testcase 0 $CDS -s -7200 -f sig.cds.2 -d DS.both $Z
183
184name='update del'
185out=UP.del1
186testcase 0 $CDS -u -s -7200 -f sig.cds.2 -d DS.both $Z
187
188name='swap DS records'
189out=DS.2
190testcase 0 $CDS -s -7200 -f sig.cds.2 -d DS.1 $Z
191
192name='update swap'
193out=UP.swap
194testcase 0 $CDS -u -s -7200 -f sig.cds.2 -d DS.1 $Z
195
196name='TTL from -T'
197out=DS.ttl2
198testcase 0 $CDS -T 3600 -s -7200 -f sig.cds.2 -d DS.1 $Z
199
200name='update TTL from -T'
201out=UP.swapttl
202testcase 0 $CDS -u -T 3600 -s -7200 -f sig.cds.2 -d DS.1 $Z
203
204name='update TTL from dsset'
205out=UP.swapttl
206testcase 0 $CDS -u -s -7200 -f sig.cds.2 -d DS.ttl1 $Z
207
208name='TTL from -T overrides dsset'
209out=DS.ttlong2
210testcase 0 $CDS -T 7200 -s -7200 -f sig.cds.2 -d DS.ttl1 $Z
211
212name='stable DS record order (changes)'
213out=DS.1
214testcase 0 $CDS -s -7200 -f sig.cds.rev1 -d DS.2 $Z
215
216name='CDNSKEY default algorithm'
217out=DS.2-2
218testcase 0 $CDS -s -7200 -f sig.cdnskey.2 -d DS.1 $Z
219
220name='CDNSKEY SHA1'
221out=DS.2-1
222testcase 0 $CDS -a SHA1 -s -7200 -f sig.cdnskey.2 -d DS.1 $Z
223
224name='CDNSKEY two algorithms'
225out=DS.2
226testcase 0 $CDS -a SHA1 -a SHA256 -s -7200 -f sig.cdnskey.2 -d DS.1 $Z
227
228name='CDNSKEY two algorithms, reversed'
229out=DS.2
230testcase 0 $CDS -a SHA256 -a SHA1 -s -7200 -f sig.cdnskey.2 -d DS.1 $Z
231
232name='CDNSKEY and CDS'
233out=DS.2
234testcase 0 $CDS -s -7200 -f sig.cds.cdnskey.2 -d DS.1 $Z
235
236name='prefer CDNSKEY'
237out=DS.2-2
238testcase 0 $CDS -D -s -7200 -f sig.cds.cdnskey.2 -d DS.1 $Z
239
240echo_i "exit status: $status"
241[ $status -eq 0 ] || exit 1
242