summaryrefslogtreecommitdiffstats
path: root/modules/prefill/prefill.test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:26:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:26:00 +0000
commit830407e88f9d40d954356c3754f2647f91d5c06a (patch)
treed6a0ece6feea91f3c656166dbaa884ef8a29740e /modules/prefill/prefill.test
parentInitial commit. (diff)
downloadknot-resolver-830407e88f9d40d954356c3754f2647f91d5c06a.tar.xz
knot-resolver-830407e88f9d40d954356c3754f2647f91d5c06a.zip
Adding upstream version 5.6.0.upstream/5.6.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--modules/prefill/prefill.test/empty.zone0
-rw-r--r--modules/prefill/prefill.test/example.com.zone12
-rw-r--r--modules/prefill/prefill.test/prefill.test.lua123
-rw-r--r--modules/prefill/prefill.test/random.zone2
-rw-r--r--modules/prefill/prefill.test/testroot.zone59
-rw-r--r--modules/prefill/prefill.test/testroot.zone.unsigned4
-rw-r--r--modules/prefill/prefill.test/testroot_no_soa.zone52
7 files changed, 252 insertions, 0 deletions
diff --git a/modules/prefill/prefill.test/empty.zone b/modules/prefill/prefill.test/empty.zone
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/modules/prefill/prefill.test/empty.zone
diff --git a/modules/prefill/prefill.test/example.com.zone b/modules/prefill/prefill.test/example.com.zone
new file mode 100644
index 0000000..55edbf0
--- /dev/null
+++ b/modules/prefill/prefill.test/example.com.zone
@@ -0,0 +1,12 @@
+; SPDX-License-Identifier: GPL-3.0-or-later
+$ORIGIN example.com.
+$TTL 3600
+
+@ SOA dns1.example.com. hostmaster.example.com. (
+ 2010111213 ; serial
+ 6h ; refresh
+ 1h ; retry
+ 1w ; expire
+ 1d ) ; minimum
+
+ NS dns1
diff --git a/modules/prefill/prefill.test/prefill.test.lua b/modules/prefill/prefill.test/prefill.test.lua
new file mode 100644
index 0000000..3d39d8f
--- /dev/null
+++ b/modules/prefill/prefill.test/prefill.test.lua
@@ -0,0 +1,123 @@
+-- SPDX-License-Identifier: GPL-3.0-or-later
+-- unload modules which are not related to this test
+if ta_signal_query then
+ modules.unload('ta_signal_query')
+end
+if priming then
+ modules.unload('priming')
+end
+if detect_time_skew then
+ modules.unload('detect_time_skew')
+end
+
+-- test. domain is used by some tests, allow it
+policy.add(policy.suffix(policy.PASS, {todname('test.')}))
+
+cache.size = 2*MB
+-- log_level('debug')
+
+-- Self-checks on globals
+assert(help() ~= nil)
+assert(worker.id ~= nil)
+-- Self-checks on facilities
+assert(cache.stats() ~= nil)
+assert(cache.backends() ~= nil)
+assert(worker.stats() ~= nil)
+assert(net.interfaces() ~= nil)
+-- Self-checks on loaded stuff
+assert(#modules.list() > 0)
+-- Self-check timers
+ev = event.recurrent(1 * sec, function () return 1 end)
+event.cancel(ev)
+ev = event.after(0, function () return 1 end)
+
+
+-- Import fake root zone; avoid interference with configured keyfile_default.
+trust_anchors.remove('.')
+trust_anchors.add('. IN DS 18213 7 2 A1D391053583A4BC597DB9588B296060FC55EAC80B3831CA371BA1FA AE997244')
+
+-- do not attempt to contact outside world, operate only on cache
+net.ipv4 = false
+net.ipv6 = false
+-- do not listen, test is driven by config code
+env.KRESD_NO_LISTEN = true
+
+local check_answer = require('test_utils').check_answer
+
+local function zone_import(fname, downgrade)
+ return require('ffi').C.zi_zone_import({
+ zone_file = fname,
+ downgrade = downgrade,
+ })
+end
+
+local function import_valid_root_zone()
+ cache.clear()
+ local import_res = zone_import('testroot.zone')
+ assert(import_res == 0)
+ -- beware that import takes at least 100 ms
+ worker.sleep(0.2) -- zimport is delayed by 100 ms from function call
+ -- sanity checks - cache must be filled in
+ ok(cache.count() > 0, 'cache is not empty after import of valid signed root zone')
+ check_answer('root apex is in cache',
+ '.', kres.type.NS, kres.rcode.NOERROR)
+ check_answer('deep subdomain is in cache',
+ 'a.b.subtree1.', kres.type.AAAA, kres.rcode.NOERROR)
+end
+
+local function import_root_no_soa()
+ cache.clear()
+ local import_res = zone_import('testroot_no_soa.zone')
+ assert(import_res == -1)
+ -- beware that import takes at least 100 ms
+ worker.sleep(0.2) -- zimport is delayed by 100 ms from function call
+ -- sanity checks - cache must be filled in
+ ok(cache.count() == 0 , 'cache is still empty after import of zone without SOA record')
+end
+
+local function import_unsigned_root_zone()
+ cache.clear()
+ zone_import('testroot.zone.unsigned')
+ -- beware that import takes at least 100 ms
+ worker.sleep(0.2) -- zimport is delayed by 100 ms from function call
+ -- we wanted it to fail
+ ok(cache.count() == 0, 'cache is still empty after import of unsigned zone')
+end
+
+local function import_not_root_zone()
+ cache.clear()
+ zone_import('example.com.zone')
+ -- beware that import takes at least 100 ms
+ worker.sleep(0.2) -- zimport is delayed by 100 ms from function call
+ -- we wanted it to fail
+ ok(cache.count() == 0, 'cache is still empty after import of other zone than root')
+end
+
+local function import_empty_zone()
+ cache.clear()
+ local import_res = zone_import('empty.zone')
+ assert(import_res < 0)
+ -- beware that import takes at least 100 ms
+ worker.sleep(0.2) -- zimport is delayed by 100 ms from function call
+ -- sanity checks - cache must be filled in
+ ok(cache.count() == 0, 'cache is still empty after import of empty zone')
+end
+
+local function import_random_trash()
+ cache.clear()
+ local import_res = zone_import('random.zone')
+ assert(import_res < 0)
+ -- beware that import takes at least 100 ms
+ worker.sleep(0.2) -- zimport is delayed by 100 ms from function call
+ -- sanity checks - cache must be filled in
+ ok(cache.count() == 0, 'cache is still empty after import of unparseable file')
+end
+
+return {
+ import_valid_root_zone,
+ import_root_no_soa,
+ import_unsigned_root_zone,
+ import_not_root_zone,
+ import_empty_zone,
+ import_random_trash,
+}
diff --git a/modules/prefill/prefill.test/random.zone b/modules/prefill/prefill.test/random.zone
new file mode 100644
index 0000000..1650ac2
--- /dev/null
+++ b/modules/prefill/prefill.test/random.zone
@@ -0,0 +1,2 @@
+4=g<k~>Biڴ=FN50H.Áa@汁wUټPn2ޗt}3qUlΤQIa  yGD# ֈ>SdjU?ʨTWMC}2 )`a *lj7V5%圅. eZ5BISޚLv>|<dF;6 GL{tɹ݌*Ccj$G)IC0}tNK^d
+; SPDX-License-Identifier: GPL-3.0-or-later
diff --git a/modules/prefill/prefill.test/testroot.zone b/modules/prefill/prefill.test/testroot.zone
new file mode 100644
index 0000000..76b9d18
--- /dev/null
+++ b/modules/prefill/prefill.test/testroot.zone
@@ -0,0 +1,59 @@
+; SPDX-License-Identifier: GPL-3.0-or-later
+; File written on Thu Aug 22 15:47:02 2019
+; dnssec_signzone version 9.11.3-1ubuntu1.8-Ubuntu
+. 86400 IN SOA rootns. you.test. (
+ 2017071102 ; serial
+ 1800 ; refresh (30 minutes)
+ 900 ; retry (15 minutes)
+ 604800 ; expire (1 week)
+ 86400 ; minimum (1 day)
+ )
+ 86400 RRSIG SOA 7 0 86400 (
+ 20500101000000 20190822124702 46349 .
+ QRmlVBvwhkNqmsp4H9zxcPeVg++5g/eR8EPb
+ DldazjUIoqbQYarTD+3DDf8tvwJu1aBNvBhm
+ cQCauTS5JWzisg== )
+ 86400 NS rootns.
+ 86400 RRSIG NS 7 0 86400 (
+ 20500101000000 20190822124702 46349 .
+ kMiL+id0WrESTSw51qI96kbolLTegn+Uraim
+ 8GjNr0d2fH8m885ORkr7C4g0RrzfAKNokArF
+ rQltwL8sMowgJg== )
+ 86400 NSEC a.b.subtree1. NS SOA RRSIG NSEC DNSKEY
+ 86400 RRSIG NSEC 7 0 86400 (
+ 20500101000000 20190822124702 46349 .
+ zv+f8FELPfYeWn7Ryy/+rBR+qASu4QC6gAka
+ vpeWRgybUQh50LrJIxINuf0YLCpqxjsX6zkK
+ zwbt0BgPHjfRHA== )
+ 86400 DNSKEY 256 3 7 (
+ AwEAAc9BtlREycexYH5az+dIbhI6sM56F+kd
+ SI43ZTGNT/Bam5vGrXju0uTHCJ2+KBwOSz7d
+ ZVchX0ulIJOUV9MteT0=
+ ) ; ZSK; alg = NSEC3RSASHA1 ; key id = 46349
+ 86400 DNSKEY 257 3 7 (
+ AwEAAcEFKHPyE1JMfRLhJK9mgcBZ+TR0Pj6u
+ shF6YbLkQoRs6Uzm458ErCcAdukJsTckqCzq
+ PFEqGLRztzyAJ7Z3G0k=
+ ) ; KSK; alg = NSEC3RSASHA1 ; key id = 18213
+ 86400 RRSIG DNSKEY 7 0 86400 (
+ 20500101000000 20190822124702 18213 .
+ ih4ScNqt9muT/Dqc05oO5T/xAyRK1/LblHph
+ GHedPHW7mC6IzsDBbqjD/P1nVK5RkM2Q+ozV
+ Ltbtmt2CafXsLA== )
+ 86400 RRSIG DNSKEY 7 0 86400 (
+ 20500101000000 20190822124702 46349 .
+ Lqle63cGoJdZA4CHHUq3ZqFxsbYATelzj5Dl
+ lDcc7vLbn2Qy9AVUC5I6UdZqMK2UDyO+DWCG
+ Cmq5705eAQlcsQ== )
+a.b.subtree1. 86400 IN AAAA 2001:db8::
+ 86400 RRSIG AAAA 7 3 86400 (
+ 20500101000000 20190822124702 46349 .
+ Hq6CUu3CVN/90b1Sozv0uIgH5ePxY3olc3eq
+ PoeyfdS+3HjSgb+Ji+GjYAAOMaVDS0APwwMe
+ pHxhdgO/zpKHRQ== )
+ 86400 NSEC . AAAA RRSIG NSEC
+ 86400 RRSIG NSEC 7 3 86400 (
+ 20500101000000 20190822124702 46349 .
+ lcJ7xdzxgTTvj2JiwzhDRyxTx2ZJ5zwzx0hC
+ ttTrSfG+2GyMnPzJ9MFid5S2w0WbWOWWLaKH
+ O0ucI8xvYInNAA== )
diff --git a/modules/prefill/prefill.test/testroot.zone.unsigned b/modules/prefill/prefill.test/testroot.zone.unsigned
new file mode 100644
index 0000000..fbc551f
--- /dev/null
+++ b/modules/prefill/prefill.test/testroot.zone.unsigned
@@ -0,0 +1,4 @@
+; SPDX-License-Identifier: GPL-3.0-or-later
+. 86400 SOA rootns. you.test. 2017071101 1800 900 604800 86400
+. 86400 NS rootns.
+a.b.subtree1. 86400 AAAA 2001:db8::
diff --git a/modules/prefill/prefill.test/testroot_no_soa.zone b/modules/prefill/prefill.test/testroot_no_soa.zone
new file mode 100644
index 0000000..e3ad08c
--- /dev/null
+++ b/modules/prefill/prefill.test/testroot_no_soa.zone
@@ -0,0 +1,52 @@
+; SPDX-License-Identifier: GPL-3.0-or-later
+; File written on Thu Aug 22 15:47:02 2019
+; dnssec_signzone version 9.11.3-1ubuntu1.8-Ubuntu
+. 86400 RRSIG SOA 7 0 86400 (
+ 20500101000000 20190822124702 46349 .
+ QRmlVBvwhkNqmsp4H9zxcPeVg++5g/eR8EPb
+ DldazjUIoqbQYarTD+3DDf8tvwJu1aBNvBhm
+ cQCauTS5JWzisg== )
+ 86400 NS rootns.
+ 86400 RRSIG NS 7 0 86400 (
+ 20500101000000 20190822124702 46349 .
+ kMiL+id0WrESTSw51qI96kbolLTegn+Uraim
+ 8GjNr0d2fH8m885ORkr7C4g0RrzfAKNokArF
+ rQltwL8sMowgJg== )
+ 86400 NSEC a.b.subtree1. NS SOA RRSIG NSEC DNSKEY
+ 86400 RRSIG NSEC 7 0 86400 (
+ 20500101000000 20190822124702 46349 .
+ zv+f8FELPfYeWn7Ryy/+rBR+qASu4QC6gAka
+ vpeWRgybUQh50LrJIxINuf0YLCpqxjsX6zkK
+ zwbt0BgPHjfRHA== )
+ 86400 DNSKEY 256 3 7 (
+ AwEAAc9BtlREycexYH5az+dIbhI6sM56F+kd
+ SI43ZTGNT/Bam5vGrXju0uTHCJ2+KBwOSz7d
+ ZVchX0ulIJOUV9MteT0=
+ ) ; ZSK; alg = NSEC3RSASHA1 ; key id = 46349
+ 86400 DNSKEY 257 3 7 (
+ AwEAAcEFKHPyE1JMfRLhJK9mgcBZ+TR0Pj6u
+ shF6YbLkQoRs6Uzm458ErCcAdukJsTckqCzq
+ PFEqGLRztzyAJ7Z3G0k=
+ ) ; KSK; alg = NSEC3RSASHA1 ; key id = 18213
+ 86400 RRSIG DNSKEY 7 0 86400 (
+ 20500101000000 20190822124702 18213 .
+ ih4ScNqt9muT/Dqc05oO5T/xAyRK1/LblHph
+ GHedPHW7mC6IzsDBbqjD/P1nVK5RkM2Q+ozV
+ Ltbtmt2CafXsLA== )
+ 86400 RRSIG DNSKEY 7 0 86400 (
+ 20500101000000 20190822124702 46349 .
+ Lqle63cGoJdZA4CHHUq3ZqFxsbYATelzj5Dl
+ lDcc7vLbn2Qy9AVUC5I6UdZqMK2UDyO+DWCG
+ Cmq5705eAQlcsQ== )
+a.b.subtree1. 86400 IN AAAA 2001:db8::
+ 86400 RRSIG AAAA 7 3 86400 (
+ 20500101000000 20190822124702 46349 .
+ Hq6CUu3CVN/90b1Sozv0uIgH5ePxY3olc3eq
+ PoeyfdS+3HjSgb+Ji+GjYAAOMaVDS0APwwMe
+ pHxhdgO/zpKHRQ== )
+ 86400 NSEC . AAAA RRSIG NSEC
+ 86400 RRSIG NSEC 7 3 86400 (
+ 20500101000000 20190822124702 46349 .
+ lcJ7xdzxgTTvj2JiwzhDRyxTx2ZJ5zwzx0hC
+ ttTrSfG+2GyMnPzJ9MFid5S2w0WbWOWWLaKH
+ O0ucI8xvYInNAA== )