tests.sh 12 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
. ../conf.sh
13

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

17 18 19 20 21
status=0
n=0

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

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

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

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

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
54
    echo_i "test with LP (+rec) ($n)"
55
    ret=0
Evan Hunt's avatar
Evan Hunt committed
56
    $DIG $DIGOPTS +rec -t LP nid2.nid.example @10.53.0.1 > dig.out.$n || ret=1
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
    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
80
            echo_i "failed"; status=$((status+1))
81 82 83
    fi

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

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

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

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

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

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

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
150
    echo_i "test with LP (+norec) ($n)"
151
    ret=0
Evan Hunt's avatar
Evan Hunt committed
152
    $DIG $DIGOPTS +norec -t LP nid2.nid.example @10.53.0.1 > dig.out.$n || ret=1
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
    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
176
            echo_i "failed"; status=$((status+1))
177 178 179
    fi

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

    n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
196
    echo_i "test with NID + LP (+norec) ($n)"
197
    ret=0
Evan Hunt's avatar
Evan Hunt committed
198
    $DIG $DIGOPTS +norec -t NID nid2.nid.example @10.53.0.1 > dig.out.$n || ret=1
199 200 201 202 203 204 205 206 207
    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
208 209
    fi
    if [ $ret -eq 1 ] ; then
210
            echo_i "failed"; status=$((status+1))
211
    fi
212 213 214 215 216 217 218 219

    n=`expr $n + 1`
    echo_i "test with NS, root zone ($n)"
    ret=0
    $DIG $DIGOPTS -t NS . @10.53.0.1 > dig.out.$n || ret=1
    # Always expect glue for root priming queries, regardless $minimal
    grep 'ADDITIONAL: 3' dig.out.$n > /dev/null || ret=1
    if [ $ret -eq 1 ] ; then
220
            echo_i "failed"; status=$((status+1))
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
    fi

    n=`expr $n + 1`
    echo_i "test with NS, non-root zone ($n)"
    ret=0
    $DIG $DIGOPTS -t NS rt.example @10.53.0.1 > dig.out.$n || ret=1
    case $minimal in
    yes)
      grep 'ADDITIONAL: 1' dig.out.$n > /dev/null || ret=1
      ;;
    no)
      grep 'ADDITIONAL: 2' dig.out.$n > /dev/null || ret=1
      ;;
    no-auth)
      grep 'ADDITIONAL: 2' dig.out.$n > /dev/null || ret=1
      ;;
    no-auth-recursive)
      grep 'ADDITIONAL: 2' dig.out.$n > /dev/null || ret=1
      ;;
    esac
    if [ $ret -eq 1 ] ; then
242
            echo_i "failed"; status=$((status+1))
243
    fi
244 245
}

Evan Hunt's avatar
Evan Hunt committed
246
echo_i "testing with 'minimal-responses yes;'"
247 248 249
minimal=yes
dotests

Evan Hunt's avatar
Evan Hunt committed
250 251
echo_i "reconfiguring server: minimal-responses no"
copy_setports ns1/named2.conf.in ns1/named.conf
252
rndc_reconfig ns1 10.53.0.1
253

Evan Hunt's avatar
Evan Hunt committed
254
echo_i "testing with 'minimal-responses no;'"
255 256 257
minimal=no
dotests

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

Evan Hunt's avatar
Evan Hunt committed
267 268
echo_i "reconfiguring server: minimal-any yes"
copy_setports ns1/named3.conf.in ns1/named.conf
269
rndc_reconfig ns1 10.53.0.1
Evan Hunt's avatar
Evan Hunt committed
270 271

n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
272
echo_i "testing with 'minimal-any yes;' over UDP ($n)"
273
ret=0
Evan Hunt's avatar
Evan Hunt committed
274
$DIG $DIGOPTS -t ANY +notcp www.rt.example @10.53.0.1 > dig.out.$n || ret=1
275 276
grep "ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1" dig.out.$n > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
277
    echo_i "failed"; status=$((status+1))
278 279 280
fi
n=`expr $n + 1`

Evan Hunt's avatar
Evan Hunt committed
281
echo_i "testing with 'minimal-any yes;' over TCP ($n)"
282
ret=0
Evan Hunt's avatar
Evan Hunt committed
283
$DIG $DIGOPTS -t ANY +tcp www.rt.example @10.53.0.1 > dig.out.$n || ret=1
284 285
grep "ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1" dig.out.$n > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
286
    echo_i "failed"; status=$((status+1))
287 288 289
fi

n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
290
echo_i "testing with 'minimal-any yes;' over UDP ($n)"
291
ret=0
Evan Hunt's avatar
Evan Hunt committed
292
$DIG $DIGOPTS -t ANY +notcp www.rt.example @10.53.0.1 > dig.out.$n || ret=1
Evan Hunt's avatar
Evan Hunt committed
293 294
grep "ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1" dig.out.$n > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
295
    echo_i "failed"; status=$((status+1))
Evan Hunt's avatar
Evan Hunt committed
296 297
fi

Evan Hunt's avatar
Evan Hunt committed
298
echo_i "testing with 'minimal-responses no-auth;'"
299 300 301
minimal=no-auth
dotests

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

Evan Hunt's avatar
Evan Hunt committed
306
echo_i "testing with 'minimal-responses no-auth-recursive;'"
307 308 309
minimal=no-auth-recursive
dotests

310
n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
311
echo_i "testing returning TLSA records with MX query ($n)"
312
ret=0
Evan Hunt's avatar
Evan Hunt committed
313
$DIG $DIGOPTS -t mx mx.example @10.53.0.1 > dig.out.$n || ret=1
314 315 316 317
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
318
    echo_i "failed"; status=$((status+1))
319 320 321
fi

n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
322
echo_i "testing returning TLSA records with SRV query ($n)"
323
ret=0
Evan Hunt's avatar
Evan Hunt committed
324
$DIG $DIGOPTS -t srv _xmpp-client._tcp.srv.example @10.53.0.1 > dig.out.$n || ret=1
325 326 327 328
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
329
    echo_i "failed"; status=$((status+1))
330 331
fi

Evan Hunt's avatar
Evan Hunt committed
332 333
echo_i "reconfiguring server: minimal-responses no"
copy_setports ns1/named2.conf.in ns1/named.conf
334
rndc_reconfig ns1 10.53.0.1
335 336

n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
337
echo_i "testing NS handling in ANY responses (authoritative) ($n)"
338
ret=0
Evan Hunt's avatar
Evan Hunt committed
339
$DIG $DIGOPTS -t ANY rt.example @10.53.0.1 > dig.out.$n || ret=1
340 341 342
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
343
    echo_i "failed"; status=$((status+1))
344 345 346
fi

n=`expr $n + 1`
Evan Hunt's avatar
Evan Hunt committed
347
echo_i "testing NS handling in ANY responses (recursive) ($n)"
348
ret=0
Evan Hunt's avatar
Evan Hunt committed
349
$DIG $DIGOPTS -t ANY rt.example @10.53.0.3 > dig.out.$n || ret=1
350 351 352
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
353
    echo_i "failed"; status=$((status+1))
354 355
fi

356 357 358 359 360 361
n=`expr $n + 1`
echo_i "testing out-of-zone additional data from auth zones (authoritative) ($n)"
ret=0
$DIG $DIGOPTS -t NS rt.example @10.53.0.1 > dig.out.$n || ret=1
grep "ADDITIONAL: 2" dig.out.$n  > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
362
    echo_i "failed"; status=$((status+1))
363 364 365 366 367 368 369 370
fi

n=`expr $n + 1`
echo_i "testing out-of-zone additional data from auth zones (recursive) ($n)"
ret=0
$DIG $DIGOPTS -t NS ex @10.53.0.3 > dig.out.$n || ret=1
grep "ADDITIONAL: 3" dig.out.$n  > /dev/null || ret=1
if [ $ret -eq 1 ] ; then
371
    echo_i "failed"; status=$((status+1))
372 373
fi

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