xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/case/tests.sh (revision 528ce0b18ee40383f14928382d06afd754b01561)
1#!/bin/sh
2
3# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4#
5# SPDX-License-Identifier: MPL-2.0
6#
7# This Source Code Form is subject to the terms of the Mozilla Public
8# License, v. 2.0.  If a copy of the MPL was not distributed with this
9# file, you can obtain one at https://mozilla.org/MPL/2.0/.
10#
11# See the COPYRIGHT file distributed with this work for additional
12# information regarding copyright ownership.
13
14SYSTEMTESTTOP=..
15. $SYSTEMTESTTOP/conf.sh
16
17DIGOPTS="+tcp +nosea +nostat +noquest +nocomm +nocmd -p ${PORT}"
18
19wait_for_serial() (
20    $DIG $DIGOPTS "@$1" "$2" SOA > "$4"
21    serial=$(awk '$4 == "SOA" { print $7 }' "$4")
22    [ "$3" -eq "${serial:--1}" ]
23)
24
25status=0
26n=0
27
28n=`expr $n + 1`
29echo_i "waiting for zone transfer to complete ($n)"
30ret=0
31for i in 1 2 3 4 5 6 7 8 9
32do
33	$DIG $DIGOPTS soa example. @10.53.0.2 > dig.ns2.test$n
34	grep SOA dig.ns2.test$n > /dev/null && break
35	sleep 1
36done
37for i in 1 2 3 4 5 6 7 8 9
38do
39	$DIG $DIGOPTS soa dynamic. @10.53.0.2 > dig.ns2.test$n
40	grep SOA dig.ns2.test$n > /dev/null && break
41	sleep 1
42done
43
44n=`expr $n + 1`
45echo_i "testing case preserving responses - no acl ($n)"
46ret=0
47$DIG $DIGOPTS mx example. @10.53.0.1 > dig.ns1.test$n
48grep "0.mail.eXaMpLe" dig.ns1.test$n > /dev/null || ret=1
49grep "mAiL.example" dig.ns1.test$n > /dev/null || ret=1
50test $ret -eq 0 || echo_i "failed"
51status=`expr $status + $ret`
52
53n=`expr $n + 1`
54echo_i "testing no-case-compress acl '{ 10.53.0.2; }' ($n)"
55ret=0
56
57# check that we preserve zone case for non-matching query (10.53.0.1)
58$DIG $DIGOPTS mx example. -b 10.53.0.1 @10.53.0.1 > dig.ns1.test$n
59grep "0.mail.eXaMpLe" dig.ns1.test$n > /dev/null || ret=1
60grep "mAiL.example" dig.ns1.test$n > /dev/null || ret=1
61
62# check that we don't preserve zone case for match (10.53.0.2)
63$DIG $DIGOPTS mx example. -b 10.53.0.2 @10.53.0.2 > dig.ns2.test$n
64grep "0.mail.example" dig.ns2.test$n > /dev/null || ret=1
65grep "mail.example" dig.ns2.test$n > /dev/null || ret=1
66
67test $ret -eq 0 || echo_i "failed"
68status=`expr $status + $ret`
69
70n=`expr $n + 1`
71echo_i "testing load of dynamic zone with various \$ORIGIN values ($n)"
72ret=0
73$DIG $DIGOPTS axfr dynamic @10.53.0.1 > dig.ns1.test$n
74digcomp dig.ns1.test$n dynamic.good || ret=1
75
76test $ret -eq 0 || echo_i "failed"
77status=`expr $status + $ret`
78
79n=`expr $n + 1`
80echo_i "transfer of dynamic zone with various \$ORIGIN values ($n)"
81ret=0
82$DIG $DIGOPTS axfr dynamic @10.53.0.2 > dig.ns2.test$n
83digcomp dig.ns2.test$n dynamic.good || ret=1
84
85test $ret -eq 0 || echo_i "failed"
86status=`expr $status + $ret`
87
88n=`expr $n + 1`
89echo_i "change SOA owner case via update ($n)"
90$NSUPDATE << EOF
91server 10.53.0.1 ${PORT}
92zone dynamic
93update add dYNAMIc 0 SOA mname1. . 2000042408 20 20 1814400 3600
94send
95EOF
96$DIG $DIGOPTS axfr dynamic @10.53.0.1 > dig.ns1.test$n
97digcomp dig.ns1.test$n postupdate.good || ret=1
98
99test $ret -eq 0 || echo_i "failed"
100status=`expr $status + $ret`
101
102n=`expr $n + 1`
103ret=0
104echo_i "wait for zone to transfer ($n)"
105retry_quiet 20 wait_for_serial 10.53.0.2 dynamic 2000042408 dig.ns2.test$n || ret=1
106
107test $ret -eq 0 || echo_i "failed"
108status=`expr $status + $ret`
109
110n=`expr $n + 1`
111echo_i "check SOA owner case is transferred to secondary ($n)"
112ret=0
113$DIG $DIGOPTS axfr dynamic @10.53.0.2 > dig.ns2.test$n
114digcomp dig.ns2.test$n postupdate.good || ret=1
115
116test $ret -eq 0 || echo_i "failed"
117status=`expr $status + $ret`
118
119#update delete Ns1.DyNaMIC. 300 IN A 10.53.0.1
120n=`expr $n + 1`
121echo_i "change A record owner case via update ($n)"
122$NSUPDATE << EOF
123server 10.53.0.1 ${PORT}
124zone dynamic
125update add Ns1.DyNaMIC. 300 IN A 10.53.0.1
126send
127EOF
128$DIG $DIGOPTS axfr dynamic @10.53.0.1 > dig.ns1.test$n
129digcomp dig.ns1.test$n postns1.good || ret=1
130
131test $ret -eq 0 || echo_i "failed"
132status=`expr $status + $ret`
133
134n=`expr $n + 1`
135ret=0
136echo_i "wait for zone to transfer ($n)"
137retry_quiet 20 wait_for_serial 10.53.0.2 dynamic 2000042409 dig.ns2.test$n || ret=1
138
139test $ret -eq 0 || echo_i "failed"
140status=`expr $status + $ret`
141
142n=`expr $n + 1`
143echo_i "check A owner case is transferred to secondary ($n)"
144ret=0
145$DIG $DIGOPTS axfr dynamic @10.53.0.2 > dig.ns2.test$n
146digcomp dig.ns2.test$n postns1.good || ret=1
147status=`expr $status + $ret`
148
149echo_i "exit status: $status"
150[ $status -eq 0 ] || exit 1
151