tests.sh revision 1.1.1.2.4.1
1#!/bin/sh
2# tests for TSIG-GSS updates
3
4SYSTEMTESTTOP=..
5. $SYSTEMTESTTOP/conf.sh
6
7status=0
8
9DIGOPTS="@10.53.0.1 -p 5300"
10
11test_update() {
12    host="$1"
13    type="$2"
14    cmd="$3"
15    digout="$4"
16    should_fail="$5"
17
18    cat <<EOF > ns1/update.txt
19server 10.53.0.1 5300
20update add $host $cmd
21send
22EOF
23
24    echo "I:testing update for $host $type $cmd $comment"
25    $NSUPDATE -k ns1/ddns.key ns1/update.txt > /dev/null 2>&1 || {
26	[ "$should_fail" ] || \
27             echo "I:update failed for $host $type $cmd"
28	return 1
29    }
30
31    out=`$DIG $DIGOPTS -t $type -q $host | egrep "^$host"`
32    lines=`echo "$out" | grep "$digout" | wc -l`
33    [ $lines -eq 1 ] || {
34	[ "$should_fail" ] || \
35            echo "I:dig output incorrect for $host $type $cmd: $out"
36	return 1
37    }
38    return 0
39}
40
41ret=0
42
43test_update testdc1.example.nil. A "86400 A 10.53.0.10" "10.53.0.10" || ret=1
44status=`expr $status + $ret`
45
46test_update testdc2.example.nil. A "86400 A 10.53.0.11" "10.53.0.11" || ret=1
47status=`expr $status + $ret`
48
49test_update testdc3.example.nil. A "86400 A 10.53.0.10" "10.53.0.10" || ret=1
50status=`expr $status + $ret`
51
52test_update deny.example.nil. TXT "86400 TXT helloworld" "helloworld" should_fail && ret=1
53status=`expr $status + $ret`
54
55echo "I:testing passing client info into DLZ driver"
56ret=0
57out=`$DIG $DIGOPTS +short -t txt -q source-addr.example.nil`
58addr=`eval echo $out | cut -f1 -d'#'`
59[ "$addr" = "10.53.0.1" ] || ret=1
60[ "$ret" -eq 0 ] || echo "I:failed"
61status=`expr $status + $ret`
62
63echo "I:testing DLZ driver is cleaned up on reload"
64$RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 reload 2>&1 | sed 's/^/I:ns1 /'
65for i in 0 1 2 3 4 5 6 7 8 9; do
66    ret=0
67    grep 'dlz_example: shutting down zone example.nil' ns1/named.run > /dev/null 2>&1 || ret=1
68    [ "$ret" -eq 0 ] && break
69done
70[ "$ret" -eq 0 ] || echo "I:failed"
71status=`expr $status + $ret`
72
73exit $status
74