From: TCY16 Date: Mon, 21 Nov 2022 14:26:49 +0000 (+0100) Subject: add ede cachedb test X-Git-Tag: release-1.18.0rc1~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=79108f4c3dd20dd4076cf1a29d24e44c725946e3;p=thirdparty%2Funbound.git add ede cachedb test --- diff --git a/testdata/ede-caching-cachedb.tdir/ede-auth.conf b/testdata/ede-caching-cachedb.tdir/ede-auth.conf new file mode 100644 index 000000000..0ec101970 --- /dev/null +++ b/testdata/ede-caching-cachedb.tdir/ede-auth.conf @@ -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-cachedb.tdir/ede-caching-cachedb.dsc b/testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.dsc new file mode 100644 index 000000000..7cce6fa22 --- /dev/null +++ b/testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.dsc @@ -0,0 +1,16 @@ +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 +Maintainer: Tom Carpay +Category: +Component: +CmdDepends: +Depends: +Help: +Pre: ede-caching-cachedb.pre +Post: ede-caching-cachedb.post +Test: ede-caching-cachedb.test +AuxFiles: +Passed: +Failure: diff --git a/testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.post b/testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.post new file mode 100644 index 000000000..75e4823e1 --- /dev/null +++ b/testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.post @@ -0,0 +1,9 @@ +# #-- ede.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 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 index 000000000..e7599ffb3 --- /dev/null +++ b/testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.pre @@ -0,0 +1,33 @@ +# #-- 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 + +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 diff --git a/testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.test b/testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.test new file mode 100644 index 000000000..7b7ef58bf --- /dev/null +++ b/testdata/ede-caching-cachedb.tdir/ede-caching-cachedb.test @@ -0,0 +1,29 @@ +# #-- ede-caching-cachedb.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 +ednsopt=49152 > 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 +ednsopt=49152 > 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-cachedb.tdir/ede.conf b/testdata/ede-caching-cachedb.tdir/ede.conf new file mode 100644 index 000000000..d9bcbabab --- /dev/null +++ b/testdata/ede-caching-cachedb.tdir/ede.conf @@ -0,0 +1,26 @@ +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: "/usr/local/etc/unbound/root.key" + + module-config: "cachedb validator iterator" + + ede: yes + + do-not-query-localhost: no + +forward-zone: + name: "example.nl" + forward-addr: 127.0.0.1@@PORT2@ + +cachedb: + backend: testframe diff --git a/testdata/ede-caching-cachedb.tdir/example.nl.zone b/testdata/ede-caching-cachedb.tdir/example.nl.zone new file mode 100644 index 000000000..b87b65859 --- /dev/null +++ b/testdata/ede-caching-cachedb.tdir/example.nl.zone @@ -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-cachedb.tdir/root.key b/testdata/ede-caching-cachedb.tdir/root.key new file mode 100644 index 000000000..ccdfb5d1b --- /dev/null +++ b/testdata/ede-caching-cachedb.tdir/root.key @@ -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