From a50ab3df86aee08e11bfa0cfcb7a5fd336d0eb8d Mon Sep 17 00:00:00 2001 From: Diego dos Santos Fronza Date: Mon, 16 Sep 2019 12:03:10 -0300 Subject: [PATCH] Added tests for include directive + glob expressions. --- bin/tests/system/conf.sh.common | 3 +- bin/tests/system/include-multiplecfg/clean.sh | 21 +++++++++ .../include-multiplecfg/ns2/named.conf.in | 27 ++++++++++++ .../include-multiplecfg/ns2/zone1.com.db | 21 +++++++++ .../system/include-multiplecfg/ns2/zone1.conf | 8 ++++ .../include-multiplecfg/ns2/zone2.com.db | 21 +++++++++ .../system/include-multiplecfg/ns2/zone2.conf | 8 ++++ bin/tests/system/include-multiplecfg/setup.sh | 17 +++++++ bin/tests/system/include-multiplecfg/tests.sh | 44 +++++++++++++++++++ 9 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 bin/tests/system/include-multiplecfg/clean.sh create mode 100644 bin/tests/system/include-multiplecfg/ns2/named.conf.in create mode 100644 bin/tests/system/include-multiplecfg/ns2/zone1.com.db create mode 100644 bin/tests/system/include-multiplecfg/ns2/zone1.conf create mode 100644 bin/tests/system/include-multiplecfg/ns2/zone2.com.db create mode 100644 bin/tests/system/include-multiplecfg/ns2/zone2.conf create mode 100644 bin/tests/system/include-multiplecfg/setup.sh create mode 100644 bin/tests/system/include-multiplecfg/tests.sh diff --git a/bin/tests/system/conf.sh.common b/bin/tests/system/conf.sh.common index 0e559c7f79..5d541dddaa 100644 --- a/bin/tests/system/conf.sh.common +++ b/bin/tests/system/conf.sh.common @@ -60,7 +60,8 @@ PARALLEL_COMMON="dnssec rpzrecurse serve-stale \ dns64 dscp dsdigest dyndb \ ednscompliance emptyzones \ fetchlimit filter-aaaa formerr forward \ - geoip2 glue idna inline integrity ixfr \ + geoip2 glue idna include-multiplecfg \ + inline integrity ixfr \ kasp keepalive legacy limits \ masterfile masterformat metadata mirror mkeys \ names notify nslookup nsupdate nzd2nzf \ diff --git a/bin/tests/system/include-multiplecfg/clean.sh b/bin/tests/system/include-multiplecfg/clean.sh new file mode 100644 index 0000000000..42915e3a7f --- /dev/null +++ b/bin/tests/system/include-multiplecfg/clean.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# 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/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +# +# Clean up after allow query tests. +# + +rm -f dig.out.* +rm -f ns*/named.conf +rm -f */named.memstats +rm -f ns*/named.lock +rm -f ns*/named.run ns*/named.run.prev +rm -f ns*/managed-keys.bind* ns*/*.mkeys* diff --git a/bin/tests/system/include-multiplecfg/ns2/named.conf.in b/bin/tests/system/include-multiplecfg/ns2/named.conf.in new file mode 100644 index 0000000000..4ae6ac1c63 --- /dev/null +++ b/bin/tests/system/include-multiplecfg/ns2/named.conf.in @@ -0,0 +1,27 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * 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/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +options { + port @PORT@; + pid-file "named.pid"; + listen-on { 10.53.0.2; }; + listen-on-v6 { none; }; + recursion no; + notify no; +}; + +#zone "." { +# type hint; +# file "../../common/root.hint"; +#}; + +include "zone*.conf"; + diff --git a/bin/tests/system/include-multiplecfg/ns2/zone1.com.db b/bin/tests/system/include-multiplecfg/ns2/zone1.com.db new file mode 100644 index 0000000000..c7836be37b --- /dev/null +++ b/bin/tests/system/include-multiplecfg/ns2/zone1.com.db @@ -0,0 +1,21 @@ +$TTL 86400 +@ IN SOA dns1.zone1.com. hostmaster.zone1.com. ( + 2001062501 ; serial + 21600 ; refresh after 6 hours + 3600 ; retry after 1 hour + 604800 ; expire after 1 week + 86400 ) ; minimum TTL of 1 day + + IN NS dns1.zone1.com. + IN NS dns2.zone1.com. + + IN MX 10 mail1.zone1.com. + IN MX 20 mail2.zone1.com. + + IN A 10.53.0.1 + +dns1 IN A 10.53.0.1 +dns2 IN A 10.53.0.2 + +mail1 IN A 10.53.0.1 +mail2 IN A 10.53.0.2 diff --git a/bin/tests/system/include-multiplecfg/ns2/zone1.conf b/bin/tests/system/include-multiplecfg/ns2/zone1.conf new file mode 100644 index 0000000000..fe903bc0c9 --- /dev/null +++ b/bin/tests/system/include-multiplecfg/ns2/zone1.conf @@ -0,0 +1,8 @@ + +zone "zone1.com" { + type master; + file "zone1.com.db"; + allow-transfer { any; }; + allow-update { any; }; +}; + diff --git a/bin/tests/system/include-multiplecfg/ns2/zone2.com.db b/bin/tests/system/include-multiplecfg/ns2/zone2.com.db new file mode 100644 index 0000000000..4a08fa7cec --- /dev/null +++ b/bin/tests/system/include-multiplecfg/ns2/zone2.com.db @@ -0,0 +1,21 @@ +$TTL 86400 +@ IN SOA dns1.zone2.com. hostmaster.zone2.com. ( + 2001062501 ; serial + 21600 ; refresh after 6 hours + 3600 ; retry after 1 hour + 604800 ; expire after 1 week + 86400 ) ; minimum TTL of 1 day + + IN NS dns1.zone2.com. + IN NS dns2.zone2.com. + + IN MX 10 mail1.zone2.com. + IN MX 20 mail2.zone2.com. + + IN A 10.53.0.1 + +dns1 IN A 10.53.0.1 +dns2 IN A 10.53.0.2 + +mail1 IN A 10.53.0.1 +mail2 IN A 10.53.0.2 diff --git a/bin/tests/system/include-multiplecfg/ns2/zone2.conf b/bin/tests/system/include-multiplecfg/ns2/zone2.conf new file mode 100644 index 0000000000..4bbd56eea7 --- /dev/null +++ b/bin/tests/system/include-multiplecfg/ns2/zone2.conf @@ -0,0 +1,8 @@ + +zone "zone2.com" { + type master; + file "zone2.com.db"; + allow-transfer { any; }; + allow-update { any; }; +}; + diff --git a/bin/tests/system/include-multiplecfg/setup.sh b/bin/tests/system/include-multiplecfg/setup.sh new file mode 100644 index 0000000000..96c061bd3d --- /dev/null +++ b/bin/tests/system/include-multiplecfg/setup.sh @@ -0,0 +1,17 @@ +#!/bin/sh -e +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# 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/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +SYSTEMTESTTOP=.. +. $SYSTEMTESTTOP/conf.sh + +$SHELL clean.sh + +copy_setports ns2/named.conf.in ns2/named.conf diff --git a/bin/tests/system/include-multiplecfg/tests.sh b/bin/tests/system/include-multiplecfg/tests.sh new file mode 100644 index 0000000000..9de935b5e0 --- /dev/null +++ b/bin/tests/system/include-multiplecfg/tests.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# 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/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +# Test of include statement with glob expression. + + +SYSTEMTESTTOP=.. +. $SYSTEMTESTTOP/conf.sh + +DIGOPTS="+tcp +nosea +nostat +nocmd +norec +noques +noadd +nostats -p ${PORT}" + +status=0 +n=0 + +# Test 1 - check if zone1 was loaded. +n=`expr $n + 1` +echo_i "test $n: glob include zone1" +ret=0 +$DIG $DIGOPTS @10.53.0.2 -b 10.53.0.2 zone1.com. a > dig.out.ns2.$n || ret=1 +grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1 +grep '^zone1.com.' dig.out.ns2.$n > /dev/null || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +# Test 2 - check if zone2 was loaded. +n=`expr $n + 1` +echo_i "test $n: glob include zone2" +ret=0 +$DIG $DIGOPTS @10.53.0.2 -b 10.53.0.2 zone2.com. a > dig.out.ns2.$n || ret=1 +grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1 +grep '^zone2.com.' dig.out.ns2.$n > /dev/null || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + +echo_i "exit status: $status" +[ $status -eq 0 ] || exit 1