tests.sh 10.3 KB
Newer Older
1 2
#!/bin/sh
#
3
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4
#
5 6 7
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 9 10
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
11 12 13 14

SYSTEMTESTTOP=..
. $SYSTEMTESTTOP/conf.sh

Evan Hunt's avatar
Evan Hunt committed
15 16 17
DIGOPTS="-p ${PORT}"
RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p ${CONTROLPORT} -s"

18 19 20 21 22
status=0
n=0

dotests() {
    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
23
    echo_i "test with RT, single zone (+rec) ($n)"
24
    ret=0
Evan Hunt's avatar
Evan Hunt committed
25
    $DIG $DIGOPTS +rec -t RT rt.rt.example @10.53.0.1 > dig.out.$n || ret=1
26
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
27
            echo_i " failed"; status=1
28 29 30
    fi

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
31
    echo_i "test with RT, two zones (+rec) ($n)"
32
    ret=0
Evan Hunt's avatar
Evan Hunt committed
33
    $DIG $DIGOPTS +rec -t RT rt.rt2.example @10.53.0.1 > dig.out.$n || ret=1
34
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
35
            echo_i " failed"; status=1
36 37 38
    fi

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
39
    echo_i "test with NAPTR, single zone (+rec) ($n)"
40
    ret=0
Evan Hunt's avatar
Evan Hunt committed
41
    $DIG $DIGOPTS +rec -t NAPTR nap.naptr.example @10.53.0.1 > dig.out.$n || ret=1
42
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
43
            echo_i " failed"; status=1
44 45 46
    fi

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
47
    echo_i "test with NAPTR, two zones (+rec) ($n)"
48
    ret=0
Evan Hunt's avatar
Evan Hunt committed
49
    $DIG $DIGOPTS +rec -t NAPTR nap.hang3b.example @10.53.0.1 > dig.out.$n || ret=1
50
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
51
            echo_i " failed"; status=1
52 53 54
    fi

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
55
    echo_i "test with LP (+rec) ($n)"
56
    ret=0
Evan Hunt's avatar
Evan Hunt committed
57
    $DIG $DIGOPTS +rec -t LP nid2.nid.example @10.53.0.1 > dig.out.$n || ret=1
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    case $minimal in
    no)
      grep -w "NS" dig.out.$n > /dev/null || ret=1
      grep -w "L64" dig.out.$n > /dev/null || ret=1
      grep -w "L32" dig.out.$n > /dev/null || ret=1
      ;;
    yes)
      grep -w "NS" dig.out.$n > /dev/null && ret=1
      grep -w "L64" dig.out.$n > /dev/null && ret=1
      grep -w "L32" dig.out.$n > /dev/null && ret=1
      ;;
    no-auth)
      grep -w "NS" dig.out.$n > /dev/null && ret=1
      grep -w "L64" dig.out.$n > /dev/null || ret=1
      grep -w "L32" dig.out.$n > /dev/null || ret=1
      ;;
    no-auth-recursive)
      grep -w "NS" dig.out.$n > /dev/null && ret=1
      grep -w "L64" dig.out.$n > /dev/null || ret=1
      grep -w "L32" dig.out.$n > /dev/null || ret=1
      ;;
    esac
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
81
            echo_i " failed"; status=1
82 83 84
    fi

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
85
    echo_i "test with NID (+rec) ($n)"
86
    ret=0
Evan Hunt's avatar
Evan Hunt committed
87
    $DIG $DIGOPTS +rec -t NID ns1.nid.example @10.53.0.1 > dig.out.$n || ret=1
88
    if [ $minimal = no ] ; then
89 90 91
      # change && to || when we support NID additional processing
      grep -w "L64" dig.out.$n > /dev/null && ret=1
      grep -w "L32" dig.out.$n > /dev/null && ret=1
92
    else
93 94
      grep -w "L64" dig.out.$n > /dev/null && ret=1
      grep -w "L32" dig.out.$n > /dev/null && ret=1
95 96
    fi
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
97
            echo_i " failed"; status=1
98 99 100
    fi

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
101
    echo_i "test with NID + LP (+rec) ($n)"
102
    ret=0
Evan Hunt's avatar
Evan Hunt committed
103
    $DIG $DIGOPTS +rec -t NID nid2.nid.example @10.53.0.1 > dig.out.$n || ret=1
104 105
    if [ $minimal = no ] ; then
      # change && to || when we support NID additional processing
106 107 108
      grep -w "LP" dig.out.$n > /dev/null && ret=1
      grep -w "L64" dig.out.$n > /dev/null && ret=1
      grep -w "L32" dig.out.$n > /dev/null && ret=1
109
    else
110 111 112 113 114
      grep -w "LP" dig.out.$n > /dev/null && ret=1
      grep -w "L64" dig.out.$n > /dev/null && ret=1
      grep -w "L32" dig.out.$n > /dev/null && ret=1
    fi
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
115
            echo_i " failed"; status=1
116 117 118
    fi

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
119
    echo_i "test with RT, single zone (+norec) ($n)"
120
    ret=0
Evan Hunt's avatar
Evan Hunt committed
121
    $DIG $DIGOPTS +norec -t RT rt.rt.example @10.53.0.1 > dig.out.$n || ret=1
122
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
123
            echo_i " failed"; status=1
124
    fi
125 126

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
127
    echo_i "test with RT, two zones (+norec) ($n)"
128
    ret=0
Evan Hunt's avatar
Evan Hunt committed
129
    $DIG $DIGOPTS +norec -t RT rt.rt2.example @10.53.0.1 > dig.out.$n || ret=1
130
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
131
            echo_i " failed"; status=1
132 133 134
    fi

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
135
    echo_i "test with NAPTR, single zone (+norec) ($n)"
136
    ret=0
Evan Hunt's avatar
Evan Hunt committed
137
    $DIG $DIGOPTS +norec -t NAPTR nap.naptr.example @10.53.0.1 > dig.out.$n || ret=1
138
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
139
            echo_i " failed"; status=1
140 141 142
    fi

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
143
    echo_i "test with NAPTR, two zones (+norec) ($n)"
144
    ret=0
Evan Hunt's avatar
Evan Hunt committed
145
    $DIG $DIGOPTS +norec -t NAPTR nap.hang3b.example @10.53.0.1 > dig.out.$n || ret=1
146
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
147
            echo_i " failed"; status=1
148 149 150
    fi

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
151
    echo_i "test with LP (+norec) ($n)"
152
    ret=0
Evan Hunt's avatar
Evan Hunt committed
153
    $DIG $DIGOPTS +norec -t LP nid2.nid.example @10.53.0.1 > dig.out.$n || ret=1
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
    case $minimal in
    no)
      grep -w "NS" dig.out.$n > /dev/null || ret=1
      grep -w "L64" dig.out.$n > /dev/null || ret=1
      grep -w "L32" dig.out.$n > /dev/null || ret=1
      ;;
    yes)
      grep -w "NS" dig.out.$n > /dev/null && ret=1
      grep -w "L64" dig.out.$n > /dev/null && ret=1
      grep -w "L32" dig.out.$n > /dev/null && ret=1
      ;;
    no-auth)
      grep -w "NS" dig.out.$n > /dev/null && ret=1
      grep -w "L64" dig.out.$n > /dev/null || ret=1
      grep -w "L32" dig.out.$n > /dev/null || ret=1
      ;;
    no-auth-recursive)
      grep -w "NS" dig.out.$n > /dev/null || ret=1
      grep -w "L64" dig.out.$n > /dev/null || ret=1
      grep -w "L32" dig.out.$n > /dev/null || ret=1
      ;;
    esac
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
177
            echo_i " failed"; status=1
178 179 180
    fi

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
181
    echo_i "test with NID (+norec) ($n)"
182
    ret=0
Evan Hunt's avatar
Evan Hunt committed
183
    $DIG $DIGOPTS +norec -t NID ns1.nid.example @10.53.0.1 > dig.out.$n || ret=1
184 185
    if [ $minimal = no ] ; then
      # change && to || when we support NID additional processing
186 187
      grep -w "L64" dig.out.$n > /dev/null && ret=1
      grep -w "L32" dig.out.$n > /dev/null && ret=1
188
    else
189 190 191 192
      grep -w "L64" dig.out.$n > /dev/null && ret=1
      grep -w "L32" dig.out.$n > /dev/null && ret=1
    fi
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
193
            echo_i " failed"; status=1
194 195 196
    fi

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
197
    echo_i "test with NID + LP (+norec) ($n)"
198
    ret=0
Evan Hunt's avatar
Evan Hunt committed
199
    $DIG $DIGOPTS +norec -t NID nid2.nid.example @10.53.0.1 > dig.out.$n || ret=1
200 201 202 203 204 205 206 207 208
    if [ $minimal = no ] ; then
      # change && to || when we support NID additional processing
      grep -w "LP" dig.out.$n > /dev/null && ret=1
      grep -w "L64" dig.out.$n > /dev/null && ret=1
      grep -w "L32" dig.out.$n > /dev/null && ret=1
    else
      grep -w "LP" dig.out.$n > /dev/null && ret=1
      grep -w "L64" dig.out.$n > /dev/null && ret=1
      grep -w "L32" dig.out.$n > /dev/null && ret=1
209 210
    fi
    if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
211
            echo_i " failed"; status=1
212 213 214
    fi
}

Evan Hunt's avatar
Evan Hunt committed
215
echo_i "testing with 'minimal-responses yes;'"
216 217 218
minimal=yes
dotests

Evan Hunt's avatar
Evan Hunt committed
219 220
echo_i "reconfiguring server: minimal-responses no"
copy_setports ns1/named2.conf.in ns1/named.conf
221
rndc_reconfig ns1 10.53.0.1
222

Evan Hunt's avatar
Evan Hunt committed
223
echo_i "testing with 'minimal-responses no;'"
224 225 226
minimal=no
dotests

Evan Hunt's avatar
Evan Hunt committed
227
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
228
echo_i "testing with 'minimal-any no;' ($n)"
229
ret=0
Evan Hunt's avatar
Evan Hunt committed
230
$DIG $DIGOPTS -t ANY www.rt.example @10.53.0.1 > dig.out.$n || ret=1
Evan Hunt's avatar
Evan Hunt committed
231 232
grep "ANSWER: 3, AUTHORITY: 1, ADDITIONAL: 2" dig.out.$n > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
233
    echo_i " failed"; status=1
Evan Hunt's avatar
Evan Hunt committed
234 235
fi

Evan Hunt's avatar
Evan Hunt committed
236 237
echo_i "reconfiguring server: minimal-any yes"
copy_setports ns1/named3.conf.in ns1/named.conf
238
rndc_reconfig ns1 10.53.0.1
Evan Hunt's avatar
Evan Hunt committed
239 240

n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
241
echo_i "testing with 'minimal-any yes;' over UDP ($n)"
242
ret=0
Evan Hunt's avatar
Evan Hunt committed
243
$DIG $DIGOPTS -t ANY +notcp www.rt.example @10.53.0.1 > dig.out.$n || ret=1
244 245
grep "ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1" dig.out.$n > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
246
    echo_i " failed"; status=1
247 248 249
fi
n=`expr $n + 1`

Evan Hunt's avatar
Evan Hunt committed
250
echo_i "testing with 'minimal-any yes;' over TCP ($n)"
251
ret=0
Evan Hunt's avatar
Evan Hunt committed
252
$DIG $DIGOPTS -t ANY +tcp www.rt.example @10.53.0.1 > dig.out.$n || ret=1
253 254
grep "ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1" dig.out.$n > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
255
    echo_i " failed"; status=1
256 257 258
fi

n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
259
echo_i "testing with 'minimal-any yes;' over UDP ($n)"
260
ret=0
Evan Hunt's avatar
Evan Hunt committed
261
$DIG $DIGOPTS -t ANY +notcp www.rt.example @10.53.0.1 > dig.out.$n || ret=1
Evan Hunt's avatar
Evan Hunt committed
262 263
grep "ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1" dig.out.$n > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
264
    echo_i " failed"; status=1
Evan Hunt's avatar
Evan Hunt committed
265 266
fi

Evan Hunt's avatar
Evan Hunt committed
267
echo_i "testing with 'minimal-responses no-auth;'"
268 269 270
minimal=no-auth
dotests

Evan Hunt's avatar
Evan Hunt committed
271 272
echo_i "reconfiguring server: minimal-responses no-auth-recursive"
copy_setports ns1/named4.conf.in ns1/named.conf
273
rndc_reconfig ns1 10.53.0.1
274

Evan Hunt's avatar
Evan Hunt committed
275
echo_i "testing with 'minimal-responses no-auth-recursive;'"
276 277 278
minimal=no-auth-recursive
dotests

279
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
280
echo_i "testing returning TLSA records with MX query ($n)"
281
ret=0
Evan Hunt's avatar
Evan Hunt committed
282
$DIG $DIGOPTS -t mx mx.example @10.53.0.1 > dig.out.$n || ret=1
283 284 285 286
grep "mx\.example\..*MX.0 mail\.mx\.example" dig.out.$n > /dev/null || ret=1
grep "mail\.mx\.example\..*A.1\.2\.3\.4" dig.out.$n > /dev/null || ret=1
grep "_25\._tcp\.mail\.mx\.example\..*TLSA.3 0 1 5B30F9602297D558EB719162C225088184FAA32CA45E1ED15DE58A21 D9FCE383" dig.out.$n > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
287
    echo_i " failed"; status=1
288 289 290
fi

n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
291
echo_i "testing returning TLSA records with SRV query ($n)"
292
ret=0
Evan Hunt's avatar
Evan Hunt committed
293
$DIG $DIGOPTS -t srv _xmpp-client._tcp.srv.example @10.53.0.1 > dig.out.$n || ret=1
294 295 296 297
grep "_xmpp-client\._tcp\.srv\.example\..*SRV.1 0 5222 server\.srv\.example" dig.out.$n > /dev/null || ret=1
grep "server\.srv\.example\..*A.1\.2\.3\.4" dig.out.$n > /dev/null || ret=1
grep "_5222\._tcp\.server\.srv\.example\..*TLSA.3 0 1 5B30F9602297D558EB719162C225088184FAA32CA45E1ED15DE58A21 D9FCE383" dig.out.$n > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
298
    echo_i " failed"; status=1
299 300
fi

Evan Hunt's avatar
Evan Hunt committed
301 302
echo_i "reconfiguring server: minimal-responses no"
copy_setports ns1/named2.conf.in ns1/named.conf
303
rndc_reconfig ns1 10.53.0.1
304 305

n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
306
echo_i "testing NS handling in ANY responses (authoritative) ($n)"
307
ret=0
Evan Hunt's avatar
Evan Hunt committed
308
$DIG $DIGOPTS -t ANY rt.example @10.53.0.1 > dig.out.$n || ret=1
309 310 311
grep "AUTHORITY: 0" dig.out.$n  > /dev/null || ret=1
grep "NS[ 	]*ns" dig.out.$n  > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
312
    echo_i " failed"; status=1
313 314 315
fi

n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
316
echo_i "testing NS handling in ANY responses (recursive) ($n)"
317
ret=0
Evan Hunt's avatar
Evan Hunt committed
318
$DIG $DIGOPTS -t ANY rt.example @10.53.0.3 > dig.out.$n || ret=1
319 320 321
grep "AUTHORITY: 0" dig.out.$n  > /dev/null || ret=1
grep "NS[ 	]*ns" dig.out.$n  > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
Evan Hunt's avatar
Evan Hunt committed
322
    echo_i " failed"; status=1
323 324
fi

Evan Hunt's avatar
Evan Hunt committed
325
echo_i "exit status: $status"
326
[ $status -eq 0 ] || exit 1