1# Copyright (C) 2011-2014  Internet Systems Consortium, Inc. ("ISC")
2#
3# Permission to use, copy, modify, and/or distribute this software for any
4# purpose with or without fee is hereby granted, provided that the above
5# copyright notice and this permission notice appear in all copies.
6#
7# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
8# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
10# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
12# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13# PERFORMANCE OF THIS SOFTWARE.
14
15SYSTEMTESTTOP=..
16. $SYSTEMTESTTOP/conf.sh
17
18status=0
19n=1
20
21for db in zones/good*.db
22do
23	echo "I:checking $db ($n)"
24	ret=0
25	$CHECKZONE -i local example $db > test.out.$n 2>&1 || ret=1
26	n=`expr $n + 1`
27	if [ $ret != 0 ]; then echo "I:failed"; fi
28	status=`expr $status + $ret`
29done
30
31for db in zones/bad*.db
32do
33	echo "I:checking $db ($n)"
34	ret=0
35	$CHECKZONE -i local example $db > test.out.$n 2>&1 && ret=1
36	n=`expr $n + 1`
37	if [ $ret != 0 ]; then echo "I:failed"; fi
38	status=`expr $status + $ret`
39done
40
41echo "I:checking with journal file ($n)"
42ret=0
43$CHECKZONE -D -o test.orig.db test zones/test1.db > /dev/null 2>&1 || ret=1
44$CHECKZONE -D -o test.changed.db test zones/test2.db > /dev/null 2>&1 || ret=1
45../../makejournal test test.orig.db test.changed.db test.orig.db.jnl 2>&1 || ret=1
46jlines=`$JOURNALPRINT test.orig.db.jnl | wc -l`
47[ $jlines = 3 ] || ret=1
48$CHECKZONE -D -j -o test.out1.db test test.orig.db > /dev/null 2>&1 || ret=1
49cmp -s test.changed.db test.out1.db || ret=1
50mv -f test.orig.db.jnl test.journal
51$CHECKZONE -D -J test.journal -o test.out2.db test test.orig.db > /dev/null 2>&1 || ret=1
52cmp -s test.changed.db test.out2.db || ret=1
53n=`expr $n + 1`
54if [ $ret != 0 ]; then echo "I:failed"; fi
55status=`expr $status + $ret`
56
57echo "I:checking with spf warnings ($n)"
58ret=0
59$CHECKZONE example zones/spf.db > test.out1.$n 2>&1 || ret=1
60$CHECKZONE -T ignore example zones/spf.db > test.out2.$n 2>&1 || ret=1
61grep "'x.example' found type SPF" test.out1.$n > /dev/null && ret=1
62grep "'y.example' found type SPF" test.out1.$n > /dev/null || ret=1
63grep "'example' found type SPF" test.out1.$n > /dev/null && ret=1
64grep "'x.example' found type SPF" test.out2.$n > /dev/null && ret=1
65grep "'y.example' found type SPF" test.out2.$n > /dev/null && ret=1
66grep "'example' found type SPF" test.out2.$n > /dev/null && ret=1
67n=`expr $n + 1`
68if [ $ret != 0 ]; then echo "I:failed"; fi
69status=`expr $status + $ret`
70
71echo "I:checking with max ttl (text) ($n)"
72ret=0
73$CHECKZONE -l 300 example zones/good1.db > test.out1.$n 2>&1 && ret=1
74$CHECKZONE -l 600 example zones/good1.db > test.out2.$n 2>&1 || ret=1
75n=`expr $n + 1`
76if [ $ret != 0 ]; then echo "I:failed"; fi
77status=`expr $status + $ret`
78
79echo "I:checking with max ttl (raw) ($n)"
80ret=0
81$CHECKZONE -f raw -l 300 example good1.db.raw > test.out1.$n 2>&1 && ret=1
82$CHECKZONE -f raw -l 600 example good1.db.raw > test.out2.$n 2>&1 || ret=1
83n=`expr $n + 1`
84if [ $ret != 0 ]; then echo "I:failed"; fi
85status=`expr $status + $ret`
86
87echo "I:checking with max ttl (map) ($n)"
88ret=0
89$CHECKZONE -f map -l 300 example good1.db.map > test.out1.$n 2>&1 && ret=1
90$CHECKZONE -f map -l 600 example good1.db.map > test.out2.$n 2>&1 || ret=1
91n=`expr $n + 1`
92if [ $ret != 0 ]; then echo "I:failed"; fi
93status=`expr $status + $ret`
94
95echo "I:checking for no 'inherited owner' warning on '\$INCLUDE file' with no new \$ORIGIN ($n)"
96ret=0
97$CHECKZONE example zones/nowarn.inherited.owner.db > test.out1.$n 2>&1 || ret=1
98grep "inherited.owner" test.out1.$n > /dev/null && ret=1
99n=`expr $n + 1`
100if [ $ret != 0 ]; then echo "I:failed"; fi
101status=`expr $status + $ret`
102
103echo "I:checking for 'inherited owner' warning on '\$ORIGIN + \$INCLUDE file' ($n)"
104ret=0
105$CHECKZONE example zones/warn.inherit.origin.db > test.out1.$n 2>&1 || ret=1
106grep "inherited.owner" test.out1.$n > /dev/null || ret=1
107n=`expr $n + 1`
108if [ $ret != 0 ]; then echo "I:failed"; fi
109status=`expr $status + $ret`
110
111echo "I:checking for 'inherited owner' warning on '\$INCLUDE file origin' ($n)"
112ret=0
113$CHECKZONE example zones/warn.inherited.owner.db > test.out1.$n 2>&1 || ret=1
114grep "inherited.owner" test.out1.$n > /dev/null || ret=1
115n=`expr $n + 1`
116if [ $ret != 0 ]; then echo "I:failed"; fi
117status=`expr $status + $ret`
118
119echo "I:exit status: $status"
120exit $status
121