Test loading a cached zone that has lines consisting of blanks

This commit is contained in:
Philip Homburg 2022-06-08 14:42:37 +02:00
parent 459b73018f
commit c6ef39a22d
6 changed files with 147 additions and 0 deletions

View file

@ -0,0 +1,23 @@
; Test if the zone parser accepts various blank lines
@ IN SOA ns1.example.com dnsmaster.example.com. (
1 ; Serial
7200 ; Refresh 2 hours
3600 ; Retry 1 hour
2419200 ; expire - 4 weeks
3600 ; Minimum 1 hour
)
7200 IN NS ns1
ns1 IN A 192.0.2.1
IN AAAA 2001:dbb::1
; completely blank line
; line with one space
; line with one tab
; line with spaces followed by comment
; test comment
; line with tabs followed by comment
; test comment
; Final line with spaces, tabs and comment
; test comment

View file

@ -0,0 +1,25 @@
server:
verbosity: 7
# num-threads: 1
interface: 127.0.0.1
port: @PORT@
use-syslog: no
directory: ""
pidfile: "unbound.pid"
chroot: ""
username: ""
do-not-query-localhost: no
use-caps-for-id: yes
module-config: "respip validator iterator"
auth-zone:
name: blanks.example.com
zonefile: "blanks.example.com"
url: "https://www.example.com/blanks.example.com.zone"
for-upstream: yes
for-downstream: yes
#rpz:
# name: blanks.example.com
# zonefile: "blanks.example.com"
# url: "https://127.0.0.1:@TOPORT@/blanks.example.com.zone"

View file

@ -0,0 +1,16 @@
BaseName: blanks_cached_zone
Version: 1.0
Description: Check if a cached zone with blank line can be loaded
CreationDate: Wed 08 Jun 2022 11:16:25 AM CEST
Maintainer: Philip Homburg
Category:
Component:
CmdDepends:
Depends:
Help:
Pre: blanks_cached_zone.pre
Post: blanks_cached_zone.post
Test: blanks_cached_zone.test
AuxFiles:
Passed:
Failure:

View file

@ -0,0 +1,10 @@
# #-- blanks_cached_zone.post --#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# source the test var file when it's there
[ -f .tpkg.var.test ] && source .tpkg.var.test
#
# do your teardown here
PRE="../.."
. ../common.sh
kill_pid $UNBOUND_PID

View file

@ -0,0 +1,22 @@
# #-- blanks_cached_zone.pre--#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
PRE="../.."
. ../common.sh
get_random_port 2
UNBOUND_PORT=$RND_PORT
echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
# make config file
sed -e 's/@PORT\@/'$UNBOUND_PORT'/' < blanks_cached_zone.conf > ub.conf
# start unbound in the background
$PRE/unbound -d -c ub.conf >unbound.log 2>&1 &
UNBOUND_PID=$!
echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
cat .tpkg.var.test
wait_unbound_up unbound.log

View file

@ -0,0 +1,51 @@
# #-- blanks_cached_zone.test --#
# source the master var file when it's there
[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
# use .tpkg.var.test for in test variable passing
[ -f .tpkg.var.test ] && source .tpkg.var.test
PRE="../.."
# do the test
TARGET=ns1.blanks.example.com.
echo "> dig $TARGET"
dig @localhost -p $UNBOUND_PORT $TARGET | tee outfile
if grep SERVFAIL outfile; then
echo "> try again"
dig @localhost -p $UNBOUND_PORT $TARGET | tee outfile
fi
if grep SERVFAIL outfile; then
echo "> try again"
sleep 1
dig @localhost -p $UNBOUND_PORT $TARGET | tee outfile
fi
if grep SERVFAIL outfile; then
echo "> try again"
sleep 1
dig @localhost -p $UNBOUND_PORT $TARGET | tee outfile
fi
if grep SERVFAIL outfile; then
echo "> try again"
sleep 1
dig @localhost -p $UNBOUND_PORT $TARGET | tee outfile
fi
if grep SERVFAIL outfile; then
echo "> try again"
sleep 10
dig @localhost -p $UNBOUND_PORT $TARGET | tee outfile
fi
if grep SERVFAIL outfile; then
echo "> try again"
sleep 10
dig @localhost -p $UNBOUND_PORT $TARGET | tee outfile
fi
echo "> cat logfiles"
cat unbound.log
echo "> check answer"
if grep "192.0.2.1" outfile; then
echo "OK"
else
echo "Not OK"
exit 1
fi
exit 0