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