]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
add subnetcache test and rename/improve cachedb test
authorTCY16 <tom@nlnetlabs.nl>
Thu, 24 Nov 2022 15:14:37 +0000 (16:14 +0100)
committerTCY16 <tom@nlnetlabs.nl>
Thu, 24 Nov 2022 15:14:37 +0000 (16:14 +0100)
16 files changed:
testdata/ede_caching_cachedb.tdir/ede-auth.conf [moved from testdata/ede-caching-cachedb.tdir/ede-auth.conf with 100% similarity]
testdata/ede_caching_cachedb.tdir/ede.conf [moved from testdata/ede-caching-cachedb.tdir/ede.conf with 100% similarity]
testdata/ede_caching_cachedb.tdir/ede_caching_cachedb.dsc [moved from testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.dsc with 65% similarity]
testdata/ede_caching_cachedb.tdir/ede_caching_cachedb.post [moved from testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.post with 87% similarity]
testdata/ede_caching_cachedb.tdir/ede_caching_cachedb.pre [new file with mode: 0644]
testdata/ede_caching_cachedb.tdir/ede_caching_cachedb.test [moved from testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.test with 95% similarity]
testdata/ede_caching_cachedb.tdir/example.nl.zone [moved from testdata/ede-caching-cachedb.tdir/example.nl.zone with 100% similarity]
testdata/ede_caching_cachedb.tdir/root.key [moved from testdata/ede-caching-cachedb.tdir/root.key with 100% similarity]
testdata/ede_caching_subnetcache.tdir/ede-auth.conf [new file with mode: 0644]
testdata/ede_caching_subnetcache.tdir/ede.conf [new file with mode: 0644]
testdata/ede_caching_subnetcache.tdir/ede_caching_subnetcache.dsc [new file with mode: 0644]
testdata/ede_caching_subnetcache.tdir/ede_caching_subnetcache.post [new file with mode: 0644]
testdata/ede_caching_subnetcache.tdir/ede_caching_subnetcache.pre [moved from testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.pre with 79% similarity]
testdata/ede_caching_subnetcache.tdir/ede_caching_subnetcache.test [new file with mode: 0644]
testdata/ede_caching_subnetcache.tdir/example.nl.zone [new file with mode: 0644]
testdata/ede_caching_subnetcache.tdir/root.key [new file with mode: 0644]

similarity index 65%
rename from testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.dsc
rename to testdata/ede_caching_cachedb.tdir/ede_caching_cachedb.dsc
index 7cce6fa22d21737c39b06c7e8a49e3cc304c4520..8738cf4bbe10c6bf002b88ba96b4aa961071fee2 100644 (file)
@@ -1,4 +1,4 @@
-BaseName: ede-caching-cachedb
+BaseName: ede_caching_cachedb
 Version: 1.0
 Description: Test caching of Extended DNS Errors (rfc8914) in the cachedb
 CreationDate: Mon Nov 21 11:42:11 UTC 2022
@@ -8,9 +8,9 @@ Component:
 CmdDepends:
 Depends:
 Help:
-Pre: ede-caching-cachedb.pre
-Post: ede-caching-cachedb.post
-Test: ede-caching-cachedb.test
+Pre: ede_caching_cachedb.pre
+Post: ede_caching_cachedb.post
+Test: ede_caching_cachedb.test
 AuxFiles: 
 Passed:
 Failure:
similarity index 87%
rename from testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.post
rename to testdata/ede_caching_cachedb.tdir/ede_caching_cachedb.post
index 75e4823e12e00dbdaaeeb47437663712c4df746f..54efdf0f1d960230cc1decec7a8d4babc13df451 100644 (file)
@@ -1,4 +1,4 @@
-# #-- ede.post --#
+# #-- ede_caching_cachedb.post --#
 # 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
diff --git a/testdata/ede_caching_cachedb.tdir/ede_caching_cachedb.pre b/testdata/ede_caching_cachedb.tdir/ede_caching_cachedb.pre
new file mode 100644 (file)
index 0000000..a9b453f
--- /dev/null
@@ -0,0 +1,43 @@
+# #-- ede_caching_cachedb.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
+
+$PRE/unbound -V > cachedb_module_check.txt
+
+if ! grep -q -e "enable-cachedb" cachedb_module_check.txt
+then
+       echo "Missing cachedb_module in the ./configure stage:"
+       echo "'unbound -V' output:"
+       cat cachedb_module_check.txt
+       exit 1
+fi
+
+get_random_port 2
+UNBOUND_PORT=$RND_PORT
+UNBOUND_PORT2=$(($RND_PORT + 1))
+echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
+echo "UNBOUND_PORT2=$UNBOUND_PORT2" >> .tpkg.var.test
+
+# rewrite config file with created ports
+sed -e 's/@PORT\@/'$UNBOUND_PORT'/' < ede.conf > temp.conf
+sed -e 's/@PORT2\@/'$UNBOUND_PORT2'/' < temp.conf > ub.conf
+sed -e 's/@PORT2\@/'$UNBOUND_PORT2'/' < ede-auth.conf > ub2.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
+
+# start authoritative unbound in the background
+$PRE/unbound -d -c ub2.conf > unbound2.log 2>&1 &
+UNBOUND_PID2=$!
+echo "UNBOUND_PID2=$UNBOUND_PID2" >> .tpkg.var.test
+
+cat .tpkg.var.test
+wait_unbound_up unbound.log
+wait_unbound_up unbound2.log
similarity index 95%
rename from testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.test
rename to testdata/ede_caching_cachedb.tdir/ede_caching_cachedb.test
index 7b7ef58bfba594bbf92a313c0f9e7bd46d410eb2..47af17f03efa7895c83ea3a9c2b4fe7409dea7c4 100644 (file)
@@ -1,4 +1,4 @@
-# #-- ede-caching-cachedb.test --#
+# #-- ede_caching_cachedbtest --#
 # 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
diff --git a/testdata/ede_caching_subnetcache.tdir/ede-auth.conf b/testdata/ede_caching_subnetcache.tdir/ede-auth.conf
new file mode 100644 (file)
index 0000000..0ec1019
--- /dev/null
@@ -0,0 +1,13 @@
+server:
+       verbosity: 1
+       use-syslog: no
+       chroot: ""
+       username: ""
+       directory: ""
+       pidfile: "unbound2.pid"
+       interface: 127.0.0.1
+       port: @PORT2@
+
+auth-zone:
+               name: "example.nl"
+               zonefile: "example.nl.zone"
diff --git a/testdata/ede_caching_subnetcache.tdir/ede.conf b/testdata/ede_caching_subnetcache.tdir/ede.conf
new file mode 100644 (file)
index 0000000..f3efd07
--- /dev/null
@@ -0,0 +1,25 @@
+server:
+       verbosity: 3
+       interface: 127.0.0.1
+       port: @PORT@
+       use-syslog: no
+       directory: .
+       pidfile: "unbound.pid"
+       chroot: ""
+       username: ""
+       directory: ""
+       val-log-level: 2
+
+       auto-trust-anchor-file: "root.key"
+
+       module-config: "subnetcache validator iterator"
+
+       client-subnet-always-forward: yes
+
+       ede: yes
+
+       do-not-query-localhost: no
+
+forward-zone:
+       name: "example.nl"
+       forward-addr: 127.0.0.1@@PORT2@
diff --git a/testdata/ede_caching_subnetcache.tdir/ede_caching_subnetcache.dsc b/testdata/ede_caching_subnetcache.tdir/ede_caching_subnetcache.dsc
new file mode 100644 (file)
index 0000000..06a91a5
--- /dev/null
@@ -0,0 +1,16 @@
+BaseName: ede_caching_subnetcache
+Version: 1.0
+Description: Test caching of Extended DNS Errors (rfc8914) in the subnetcache
+CreationDate: Mon Nov 21 11:42:11 UTC 2022
+Maintainer: Tom Carpay
+Category: 
+Component:
+CmdDepends:
+Depends:
+Help:
+Pre: ede_caching_subnetcache.pre
+Post: ede_caching_subnetcache.post
+Test: ede_caching_subnetcache.test
+AuxFiles: 
+Passed:
+Failure:
diff --git a/testdata/ede_caching_subnetcache.tdir/ede_caching_subnetcache.post b/testdata/ede_caching_subnetcache.tdir/ede_caching_subnetcache.post
new file mode 100644 (file)
index 0000000..5d4c89c
--- /dev/null
@@ -0,0 +1,9 @@
+# #-- ede_caching_subnetcache.post --#
+# 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
+
+# teardown
+. ../common.sh
+kill_pid $UNBOUND_PID
similarity index 79%
rename from testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.pre
rename to testdata/ede_caching_subnetcache.tdir/ede_caching_subnetcache.pre
index e7599ffb380b815e2dc0ec773024669aec66718f..64666ab0b1076f53028b2c6b4dfc267f9fbda450 100644 (file)
@@ -1,4 +1,4 @@
-# #-- ede-caching-cachedb.pre --#
+# #-- ede_caching_cachedb.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
@@ -7,6 +7,16 @@
 PRE="../.."
 . ../common.sh
 
+$PRE/unbound -V > subnet_module_check.txt
+
+if ! grep -q -e "enable-subnet" subnet_module_check.txt
+then
+       echo "Missing subnet_module in the ./configure stage:"
+       echo "'unbound -V' output:"
+       cat subnet_module_check.txt
+       exit 1
+fi
+
 get_random_port 2
 UNBOUND_PORT=$RND_PORT
 UNBOUND_PORT2=$(($RND_PORT + 1))
diff --git a/testdata/ede_caching_subnetcache.tdir/ede_caching_subnetcache.test b/testdata/ede_caching_subnetcache.tdir/ede_caching_subnetcache.test
new file mode 100644 (file)
index 0000000..4753159
--- /dev/null
@@ -0,0 +1,29 @@
+# #-- ede_caching_subnetcache.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
+. ../common.sh
+
+# query with the priming edns opt
+dig @127.0.0.1 -p $UNBOUND_PORT example.nl +subnet=127.0.0.0/17 > query1.txt
+
+if ! grep -q -e "OPT=15: 00 09" -e "EDE: 9" query1.txt
+then
+       echo "Priming query fails"
+       cat query1.txt
+       exit 1
+fi
+
+# kill the authoritative Unbound instance?
+kill_pid $UNBOUND_PID2
+
+# query again to see if we have indeed cached the response
+dig @127.0.0.1 -p $UNBOUND_PORT example.nl +subnet=127.0.0.0/17 > query2.txt
+
+if ! grep -q -e "OPT=15: 00 09" -e "EDE: 9" query2.txt
+then
+       echo "Cached query fails"
+       cat query2.txt
+       exit 1
+fi
diff --git a/testdata/ede_caching_subnetcache.tdir/example.nl.zone b/testdata/ede_caching_subnetcache.tdir/example.nl.zone
new file mode 100644 (file)
index 0000000..b87b658
--- /dev/null
@@ -0,0 +1,16 @@
+$ORIGIN example.nl.
+$TTL 86400 ; default time-to-live for this zone
+
+example.nl.   IN  SOA     ns.example.nl. noc.dns.icann.org. (
+        2020080302  ;Serial
+        7200        ;Refresh
+        3600        ;Retry
+        1209600     ;Expire
+        3600        ;Negative response caching TTL
+)
+
+; The nameserver that are authoritative for this zone.
+                                NS      example.nl.
+
+; these A records below are equivalent
+example.nl.    A       1.2.3.4
diff --git a/testdata/ede_caching_subnetcache.tdir/root.key b/testdata/ede_caching_subnetcache.tdir/root.key
new file mode 100644 (file)
index 0000000..ccdfb5d
--- /dev/null
@@ -0,0 +1,9 @@
+; autotrust trust anchor file
+;;id: . 1
+;;last_queried: 1669040556 ;;Mon Nov 21 15:22:36 2022
+;;last_success: 1669040556 ;;Mon Nov 21 15:22:36 2022
+;;next_probe_time: 1669081693 ;;Tue Nov 22 02:48:13 2022
+;;query_failed: 0
+;;query_interval: 43200
+;;retry_time: 8640
+.      86400   IN      DNSKEY  257 3 8 AwEAAaz/tAm8yTn4Mfeh5eyI96WSVexTBAvkMgJzkKTOiW1vkIbzxeF3+/4RgWOq7HrxRixHlFlExOLAJr5emLvN7SWXgnLh4+B5xQlNVz8Og8kvArMtNROxVQuCaSnIDdD5LKyWbRd2n9WGe2R8PzgCmr3EgVLrjyBxWezF0jLHwVN8efS3rCj/EWgvIWgb9tarpVUDK/b58Da+sqqls3eNbuv7pr+eoZG+SrDK6nWeL3c6H5Apxz7LjVc1uTIdsIXxuOLYA4/ilBmSVIzuDWfdRUfhHdY6+cn8HFRm+2hM8AnXGXws9555KrUB5qihylGa8subX2Nn6UwNR1AkUTV74bU= ;{id = 20326 (ksk), size = 2048b} ;;state=2 [  VALID  ] ;;count=0 ;;lastchange=1628842824 ;;Fri Aug 13 10:20:24 2021