1#!/bin/sh
2#
3# Copyright (C) 2014  Internet Systems Consortium, Inc. ("ISC")
4#
5# Permission to use, copy, modify, and/or distribute this software for any
6# purpose with or without fee is hereby granted, provided that the above
7# copyright notice and this permission notice appear in all copies.
8#
9# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15# PERFORMANCE OF THIS SOFTWARE.
16
17# Id: tests.sh,v 1.22 2012/02/09 23:47:18 tbox Exp
18
19SYSTEMTESTTOP=..
20. $SYSTEMTESTTOP/conf.sh
21
22status=0
23n=0
24
25getsit() {
26	awk '$2 == "SIT:" {
27		print $3;
28	}' < $1
29}
30
31havetc() {
32	grep 'flags:.* tc[^;]*;' $1 > /dev/null
33}
34
35for bad in bad*.conf
36do
37        ret=0
38        echo "I:checking that named-checkconf detects error in $bad"
39        $CHECKCONF $bad > /dev/null 2>&1
40        if [ $? != 1 ]; then echo "I:failed"; ret=1; fi
41        status=`expr $status + $ret`
42done
43
44n=`expr $n + 1`
45echo "I:checking SIT token returned to empty SIT option ($n)"
46ret=0
47$DIG +qr +sit version.bind txt ch @10.53.0.1 -p 5300 > dig.out.test$n
48grep SIT: dig.out.test$n > /dev/null || ret=1
49grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
50if [ $ret != 0 ]; then echo "I:failed"; fi
51status=`expr $status + $ret`
52
53n=`expr $n + 1`
54echo "I:checking response size without SIT ($n)"
55ret=0
56$DIG large.example txt @10.53.0.1 -p 5300 +ignore > dig.out.test$n
57havetc dig.out.test$n || ret=1
58if [ $ret != 0 ]; then echo "I:failed"; fi
59status=`expr $status + $ret`
60
61n=`expr $n + 1`
62echo "I:checking response size without valid SIT ($n)"
63ret=0
64$DIG +sit large.example txt @10.53.0.1 -p 5300 +ignore > dig.out.test$n
65havetc dig.out.test$n || ret=1
66grep "; SIT:.*(good)" dig.out.test$n > /dev/null || ret=1
67if [ $ret != 0 ]; then echo "I:failed"; fi
68status=`expr $status + $ret`
69
70n=`expr $n + 1`
71echo "I:checking response size with SIT ($n)"
72ret=0
73$DIG +sit large.example txt @10.53.0.1 -p 5300 > dig.out.test$n.l
74sit=`getsit dig.out.test$n.l`
75$DIG +qr +sit=$sit large.example txt @10.53.0.1 -p 5300 +ignore > dig.out.test$n
76havetc dig.out.test$n && ret=1
77grep "; SIT:.*(good)" dig.out.test$n > /dev/null || ret=1
78if [ $ret != 0 ]; then echo "I:failed"; fi
79status=`expr $status + $ret`
80
81n=`expr $n + 1`
82echo "I:checking response size with SIT recursive ($n)"
83ret=0
84$DIG +qr +sit=$sit large.xxx txt @10.53.0.1 -p 5300 +ignore > dig.out.test$n
85havetc dig.out.test$n && ret=1
86grep "; SIT:.*(good)" dig.out.test$n > /dev/null || ret=1
87if [ $ret != 0 ]; then echo "I:failed"; fi
88status=`expr $status + $ret`
89
90n=`expr $n + 1`
91echo "I:checking for SIT value in adb ($n)"
92ret=0
93$RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 dumpdb
94sleep 1
95grep "10.53.0.2.*\[sit=" ns1/named_dump.db > /dev/null|| ret=1
96if [ $ret != 0 ]; then echo "I:failed"; fi
97status=`expr $status + $ret`
98
99echo "I:exit status: $status"
100exit $status
101