Commit graph

12720 commits

Author SHA1 Message Date
Mark Andrews
53c8c5233a Add tests for DSYNC 2025-08-05 17:27:44 +10:00
Mark Andrews
c47615094e Add support for parsing and displaying DSYNC rdata type 2025-08-05 17:27:44 +10:00
Matthijs Mekking
4ef00f97d6 Test adding ede with rpz cname override policy
When the zone is configured with a CNAME override policy, the EDE code
is not added as expected. Add a test case based on the issue in GitLab
(#5342).

When the zone contains a wildcard CNAME, the EDE code is not added as
expected. Also add a test case for this.
2025-08-05 08:35:51 +02:00
Ondřej Surý
f7e5c1db38
Change the 'isc_g_mctx' to be always available
This required couple of internal changes to the isc_mem_debugging.

The isc_mem_debugging is now internal to isc_mem unit and there are
three new functions:

1. isc_mem_setdebugging() can change the debugging setting for an
   individual memory context.  This is need for the memory contexts used
   for OpenSSL, libxml and libuv accounting as recording and tracing
   memory is broken there.

2. isc_mem_debugon() / isc_mem_debugoff() can be used to change default
   memory debugging flags as well as debugging flags for isc_g_mctx.

Additionally, the memory debugging is inconsistent across the code-base.
For now, we are keeping the existing flags, but three new environment
variables have been added 'ISC_MEM_DEBUGRECORD', 'ISC_MEM_DEBUGTRACE'
and 'ISC_MEM_DEBUGUSAGE' to set the global debugging flags at any
program using the memory contexts.
2025-08-04 11:29:50 +02:00
Ondřej Surý
74726b3313
Add and use global memory context called isc_g_mctx
Instead of having individual memory contexts scattered across different
files and called different names, add a single memory context called
isc_g_mctx that replaces named_g_mctx and various other global memory
contexts in various utilities and tests.
2025-08-04 11:29:26 +02:00
Nicki Křížek
53be3af05c Use nsX fixtures rather than servers
Rather than using servers["nsX"] syntax, utilize the nsX fixtures to
make the test code a bit more concise.

See fe55342916
2025-07-31 12:55:40 -07:00
Nicki Křížek
d0e2487ab6 Various TTL fixes in dnssec tests
Make sure the various TTL checks are using a lower bound as well and use
a common TTL of 5 min.
2025-07-31 12:55:40 -07:00
Nicki Křížek
19941adab0 Split up dnssec validation tests to multiple modules
Put each config into a separate module to avoid interfering with other
tests.
2025-07-31 12:55:40 -07:00
Nicki Křížek
b7a2061e5f Split up badkey tests into separate modules
If nsX.reconfigure() is used in a way that might affect other tests
within the same module, it's best to split up the tests which need the
reconfig to a separate module. This ensures the reconfigure() won't
interfere with test results in case the tests are executed separately,
or in a different order.
2025-07-31 12:55:40 -07:00
Nicki Křížek
e7bd28dbf8 Parametrize dnssec/tests_badkey.py tests
Utilize test parametrization to reduce code duplication.
2025-07-31 12:55:40 -07:00
Evan Hunt
3c067e99b3 tidy up the dnssec test tree
many of the zones in the dnssec system test were identical or
had only trivial differences, and it would be easier to keep track
of them if they were sourced from template files.

also, the extra_artifacts have been simplified and restored to
the test files.
2025-07-31 12:55:40 -07:00
Evan Hunt
5a457268d1 convert delv tests to python
move all dnssec tests using delv from the shell test to tests_delv.py,
and remove tests.sh and tests_sh_dnssec.py.
2025-07-31 12:55:40 -07:00
Evan Hunt
4bd0213fe7 convert dnssec signing tests to python
the shell tests that queried servers to check correct signing
behavior (using dnssec-signzone, dnssec-policy and nsupdate),
as well as "rndc signing", private-type records, rndc zonestatus,
offline keys, etc, have been moved to tests_signing.py.

the minimal update test in the dnssec_update_test.pl script
was also moved here and the perl script has been removed.
2025-07-31 12:55:40 -07:00
Evan Hunt
950df056b3 convert dnssec validation tests to python
begin converting DNSSEC validation tests from shell to python,
and simplify the name servers used in the test.

ns4, the name server used for validation tests, is now configured
using jinja2 templates.

ns8, which was previously used for testing unsupported, disabled
and revoked keys and trust anchors, has been removed.  we now
use a jinja2 configuration in ns5 for this purpose.

the configurations in ns7 and ns6 didn't conflict with one another,
so the two servers have been merged into one.
2025-07-31 12:55:40 -07:00
Evan Hunt
8ddec41987 convert dnssec-policy tests to python
move the signatures-validity tests to tests_policy.py
2025-07-31 12:55:40 -07:00
Evan Hunt
0fabb0fbb6 convert TAT tests to python
the trust-anchor-telemetry tests have been moved to a new
python subtest, dnssec/tests_tat.py.
2025-07-31 12:55:40 -07:00
Evan Hunt
e1fa6f089b move some test cases to different system tests
- dnssec tool tests (i.e., dnssec-signzone, dnssec-keygen, etc) that
  don't require interaction with a running server have been moved
  to a new 'dnssectools' system test directory.
- a dig formatting test has been moved to digdelv.
- a named-rrchecker test has been moved to rrchecker
2025-07-31 12:55:40 -07:00
Evan Hunt
d3bfa916b3 move NTA test cases to a separate python test
the tests of "rndc nta" behavior have been moved out of the
dnssec shell test, into bin/tests/system/nta, and converted
to python. features of the dnssec test framework that were
needed for NTA testing have been moved to the nta test, and
dnssec has been correspondingly simplified.
2025-07-31 12:55:40 -07:00
Evan Hunt
bcf41973bb start converting dnssec system test to python/jinja2
- changed named.conf.in to named.conf.j2 in all server directories that
  don't currently need to use copy_setports() during the test.
- converted the tests that use ns5 to python, and replaced
  named1.conf.in and named2.conf.in with a jinja2 template instead.
  the only remaining server that still needs copy_setports() is ns4.
- removed ns4/named5.conf.in, and moved its functions to ns5 (which
  is supposed to be for servers with broken trust-anchor configurations,
  so it should have been there in the first place). converted the tests
  that used that ns4 configuration to use ns5 with jinja instead.
- revised the remaining ns4 configurations (named[1-4].conf.in) to
  minimize the differences between them. this will make it easier to
  convert it into a jinja2 template later.
2025-07-31 12:55:40 -07:00
Petr Špaček
b0c7f8b598 Fix compatibility with Python < 3.10
Dataclass kw_only argument was added only in Python 3.10 but EL9 image
has only 3.9.21.
2025-07-30 14:35:32 +00:00
Petr Špaček
6ae224fc9c Fix minimal dnspython version test
Wrong version number was uncovered by Ubuntu 22.04 Jammy which actually
has dnspython 2.1.0.
2025-07-30 14:35:32 +00:00
Nicki Křížek
64143ea077 Use isctest.query.create across system tests
Rather than using the dnspython's facilities and defaults to create the
queries, use the isctest.query.create function in all the cases that
don't require special handling to have consistent defaults.
2025-07-29 12:13:11 -07:00
Nicki Křížek
f2a4c5dcb0 Add RA flag checks to isctest.check 2025-07-29 12:12:44 -07:00
Nicki Křížek
989e64b9b0 Refactor and move query helper to isctest.query.create
Make the query helper function more universal and reusable across our
system tests -- default to using EDNS and sending AD=1.
2025-07-29 12:12:44 -07:00
Nicki Křížek
efd60348b9 Unify RR counting in isctest.check helper
Use a common function to count the number of RRs in any section of the
DNS message. For the ADDITIONAL section, stick with the dnspython
convention of not including OPT and TSIG.
2025-07-29 12:12:44 -07:00
Nicki Křížek
b24dd20e5a Refactor isctest.check.section_equal comparison
Use the same logic as dnspython uses in dns.message.Message.
2025-07-29 12:12:44 -07:00
Evan Hunt
b69097f139 add helper functions to isctest
added some helper functions in isctest to reduce code repetition
in dnssec-related tests:

- isctest.check.adflag() - checks that a response contains AD=1
- isctest.check.noadflag() - checks that a response contains AD=0

- isctest.check.rdflag() - checks that a response contains RD=1
- isctest.check.nordflag() - checks that a response contains RD=0

- isctest.check.answer_count_eq() - checks the answer count is correct
- isctest.check.additional_count_eq() - same for authority count
- isctest.check.authority_count_eq() - same for additional count

- isctest.check.same_data() - check that two message have the
                              same rcode and data
- isctest.check.same_answer() - check that two message have the same
                                rcode and answer

- isctest.dnssec.msg() - a wrapper for dns.message.make_query() that
                         creates a query message similar to dig +dnssec:
                         use_edns=True, want_dnssec=True,
                         and flags are set to (RD|AD) by default, but
                         options exist to disable AD or enable CD.
                         (to generate non-DNSSEC queries, use
                         message.make_query() directly.)
2025-07-29 12:12:44 -07:00
Matthijs Mekking
abdb9a1334 Improve key collision detection in ksr system test
MR !10238 added key collision detection in the ksr system test but it
was flawed because for every "collide" in the output we also log
"Generating an new key" and for each "Generating" we add the counter
by one, nullifying the subtract by one.

Use regular expressions to search in the output and make the string
expression more strict.
2025-07-29 13:57:06 +02:00
Michał Kępień
adb931f700 Adjust type hints for the "nsec3-answer" test
Add missing type hints in the tests_nsec3.py module.  Tweak the syntax
used for type hints for better consistency with other Python code in
bin/tests/system/.
2025-07-29 10:00:46 +02:00
Petr Špaček
fc3d5e5918 Add more empty non-terminals to test zone
I don't know exactly why, I just have a feeling there might be
interesting corner cases somewhere.
2025-07-29 10:00:46 +02:00
Petr Špaček
46781845ea Randomize NSEC3 salt
This should prevent the case where are are unlucky enough that static
values hash 'just right' for the test to pass, but only accidentally.
2025-07-29 10:00:46 +02:00
Petr Špaček
548632b18a Test proof of nonexistance of DS in insecure referrals
Currently this test is limited only to auth because currently BIND
resolver does not send DS proof of nonexistence for RD=0 queries.
2025-07-29 10:00:46 +02:00
Petr Špaček
73e4201331 Test dangling DNAME answers come with NXDOMAIN proofs
Simplistic test. Ignores the possibility of DNAME chain going through
multiple zones and/or wildcard expansions.
2025-07-29 10:00:46 +02:00
Petr Špaček
d0e413dd57 Test dangling CNAMEs come with NXDOMAIN proofs
Simplistic test. Ignores the possibility of CNAME chain going through
multiple zones and/or wildcard expansions.
2025-07-29 10:00:46 +02:00
Petr Špaček
cc6544b417 Move query outside of check_() functions
This allows better check() code reuse.
2025-07-29 10:00:46 +02:00
Petr Špaček
ac58b58002 Separate test into a new directory
The test actually needs just two servers - auth and resolver. The rest
was not needed and made test setup only slower and harder to debug.
2025-07-29 10:00:46 +02:00
Petr Špaček
a92391f60f Test simple NODATA answers with NSEC3 2025-07-29 10:00:46 +02:00
Petr Špaček
b854d5a3f5 Detect extraneous NSEC3 RRs in responses
We expect minimal possible answers which prove what they have to
according to DNSSEC protocol.
2025-07-29 10:00:46 +02:00
Petr Špaček
c45ad51860 Move proof checking into a NSEC3Checker class 2025-07-29 10:00:46 +02:00
Petr Špaček
cfaf5c997f Add consistency checks to responses with NSEC3
Basic sanity checks - limited to responses from a single zone:
- NSEC3 type cannot be present in type bitmap:
  By definition, the type bitmap describes state of the unhashed name
  but NSEC3 RR is present at a different owner name. RFC 7129 section 5
- NSEC3 owner names cannot be duplicated:
  Unless the response crosses zone boundary, parent zone has insecure
  delegation for child, but child is signed ... don't do that.
- All parameters are consistent across all RRs present in answer:
  RFC 5155 section 7.2, last paragraph - at least when we don't cross
  zone boundary.
2025-07-29 10:00:46 +02:00
Petr Špaček
9ca2077274 Split NXDOMAIN/NOERROR/NODATA test cases
Untangling individual cases allows for clearer documentation and makes
it easier to build similar but slightly different test cases.  Wildcard
NODATA answer was added.
2025-07-29 10:00:45 +02:00
Petr Špaček
f0592de608 Extract closest encloser and source of synthesis logic into ZoneAnalyzer
As a side-effect, we now have set of all existing names in a zone with a
test, too. These parts should be shared with new NSEC tests.
2025-07-29 10:00:45 +02:00
Petr Špaček
9cea2af25c Use isctest library to check hypothesis version
Side-effect of importing from isctest.hypothesis first is a version
check and clean Pytest skip if version is too old.
2025-07-29 10:00:45 +02:00
Petr Špaček
42b60a3819 Generate comprehensive tests for ZoneAnalyzer utility class
Test all combinations of wildcard, ENT, DNAME, NS, and ordinary
TXT records.

Test zone and expected outputs are generated by another script which
encodes node content into node name. This encoding removes 'node
content' level of indirection and thus enables simpler implementation of
same logic which needs to be in ZoneAnalyzer itself.

For humans the generated zone file also lists expected 'categories' a
name belongs to as dot-separated list on right hand side of a generated
RR.
2025-07-29 10:00:45 +02:00
Petr Špaček
cad48e56ab Test ZoneAnalyzer utility class
I've considered writing hypothesis test for this but I would have to
reimplement the same thing, which would probably have the same logic
bugs, so I will leave it as an exercise for someone else.
2025-07-29 10:00:37 +02:00
Petr Špaček
dbba59f48b Separate zone analyzer from NSEC3 test
Code to generate ENTs, detect wildcards, occlusion etc. is generic
enough to be in an utility module.
2025-07-29 10:00:37 +02:00
Petr Špaček
3fb6b990af Shorten syntax to access Name object
dns.name all over the place does not make it easier to read the code at
all, and I'm going to add lot more code here.
2025-07-29 10:00:36 +02:00
Petr Špaček
bd8be10329 Move multi-subdomain name generator into shared utilities 2025-07-29 10:00:36 +02:00
Evan Hunt
e263df8848 Add property based test for nsec3hash utility
Check the correctness of NSEC3 hash generation by generating random
combinations of name, salt, and iterations and comparing the outputs
of the nsec3hash tool against the dnspython nsec3_hash function
for the same inputs.
2025-07-29 10:00:36 +02:00
Petr Špaček
84ad35e7af Test also with subdomains of existing names
Composite strategy makes sure we always test with a subdomain of an
existing name.
2025-07-29 10:00:36 +02:00