From 830407e88f9d40d954356c3754f2647f91d5c06a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 17:26:00 +0200 Subject: Adding upstream version 5.6.0. Signed-off-by: Daniel Baumann --- modules/prefill/prefill.test/empty.zone | 0 modules/prefill/prefill.test/example.com.zone | 12 ++ modules/prefill/prefill.test/prefill.test.lua | 123 +++++++++++++++++++++ modules/prefill/prefill.test/random.zone | 2 + modules/prefill/prefill.test/testroot.zone | 59 ++++++++++ .../prefill/prefill.test/testroot.zone.unsigned | 4 + modules/prefill/prefill.test/testroot_no_soa.zone | 52 +++++++++ 7 files changed, 252 insertions(+) create mode 100644 modules/prefill/prefill.test/empty.zone create mode 100644 modules/prefill/prefill.test/example.com.zone create mode 100644 modules/prefill/prefill.test/prefill.test.lua create mode 100644 modules/prefill/prefill.test/random.zone create mode 100644 modules/prefill/prefill.test/testroot.zone create mode 100644 modules/prefill/prefill.test/testroot.zone.unsigned create mode 100644 modules/prefill/prefill.test/testroot_no_soa.zone (limited to 'modules/prefill/prefill.test') diff --git a/modules/prefill/prefill.test/empty.zone b/modules/prefill/prefill.test/empty.zone new file mode 100644 index 0000000..e69de29 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=gBiڴ=FN50H.Áa@汁wUټPn2ޗt}3qUlΤQIa  yGD# ֈ>SdjU?ʨTWMC}2 )`a *lj7V5%圅. eZ5BISޚLv>|