]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Test loading a cached zone that has lines consisting of blanks
authorPhilip Homburg <philip@nlnetlabs.nl>
Wed, 8 Jun 2022 12:42:37 +0000 (14:42 +0200)
committerPhilip Homburg <philip@nlnetlabs.nl>
Wed, 8 Jun 2022 12:45:30 +0000 (14:45 +0200)
testdata/blanks_cached_zone.tdir/blanks.example.com [new file with mode: 0644]
testdata/blanks_cached_zone.tdir/blanks_cached_zone.conf [new file with mode: 0644]
testdata/blanks_cached_zone.tdir/blanks_cached_zone.dsc [new file with mode: 0644]
testdata/blanks_cached_zone.tdir/blanks_cached_zone.post [new file with mode: 0644]
testdata/blanks_cached_zone.tdir/blanks_cached_zone.pre [new file with mode: 0644]
testdata/blanks_cached_zone.tdir/blanks_cached_zone.test [new file with mode: 0644]

diff --git a/testdata/blanks_cached_zone.tdir/blanks.example.com b/testdata/blanks_cached_zone.tdir/blanks.example.com
new file mode 100644 (file)
index 0000000..f5eba1f
--- /dev/null
@@ -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
diff --git a/testdata/blanks_cached_zone.tdir/blanks_cached_zone.conf b/testdata/blanks_cached_zone.tdir/blanks_cached_zone.conf
new file mode 100644 (file)
index 0000000..c3d43b7
--- /dev/null
@@ -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"
diff --git a/testdata/blanks_cached_zone.tdir/blanks_cached_zone.dsc b/testdata/blanks_cached_zone.tdir/blanks_cached_zone.dsc
new file mode 100644 (file)
index 0000000..1686aa4
--- /dev/null
@@ -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:
diff --git a/testdata/blanks_cached_zone.tdir/blanks_cached_zone.post b/testdata/blanks_cached_zone.tdir/blanks_cached_zone.post
new file mode 100644 (file)
index 0000000..c79a887
--- /dev/null
@@ -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
diff --git a/testdata/blanks_cached_zone.tdir/blanks_cached_zone.pre b/testdata/blanks_cached_zone.tdir/blanks_cached_zone.pre
new file mode 100644 (file)
index 0000000..4a9f69b
--- /dev/null
@@ -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
+
diff --git a/testdata/blanks_cached_zone.tdir/blanks_cached_zone.test b/testdata/blanks_cached_zone.tdir/blanks_cached_zone.test
new file mode 100644 (file)
index 0000000..c405950
--- /dev/null
@@ -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