Commit graph

55 commits

Author SHA1 Message Date
Štěpán Balážik
790745da18 Built-in types are now subscriptable
Generated with: ruff check --extend-select UP006 --fix
2026-02-20 15:17:32 +01:00
Štěpán Balážik
7178c97e5c Set pytestmark explicitly in rollover* and nsec3* tests
Importing pytestmark confuses static analysis tools as they flag it as
unused.
2026-02-20 15:17:32 +01:00
Štěpán Balážik
ef21b77912 Make default_algorithm accessible through a fixture and method
Importing pytest fixture trips up static analysis tools, so move
default_algorithm to conftest.py and use it instead of os.environ
accesses in various system tests.

For use outside test function, use Algorithm.default().
2026-02-20 15:17:32 +01:00
Štěpán Balážik
ffd5b6ac26 Automatically sort imports in Python code
Generated with: ruff check --extend-select I --fix (with the changes to
pyproject.toml applied).
2026-02-20 15:17:32 +01:00
Matthijs Mekking
52c940551d Change notify-cds option to notify-cfg CDS
Change the notify configuration to be more flexible for other types
of generalized DNS notifications.

Also allow for notify-cfg SOA.
2025-12-29 10:06:16 +01:00
Matthijs Mekking
f6749a432b Add isctest.kasp.SettimeOptions
This Class sets settime parameters and these can be called with key.settime()
that runs dnssec-settime on the given key with the given parameters.
2025-12-22 09:04:46 +00:00
Matthijs Mekking
35a7024e8c Test sending NOTIFY(CDS) messages during rollover
When doing rollover and the CDS/CDNSKEY RRset is updated, test that a
NOTIFY(CDS) message is sent. For other steps in the rollover, prohibit
any dsyncfetch activity.
2025-12-19 15:01:36 +01:00
Matthijs Mekking
594ff0816a Drop and replace CmdHelper with EnvCmd
A generic helper that calls environment-specified binaries has been added,
drop and replace the introduced CmdHelper for the more generic method.
2025-12-19 11:49:00 +01:00
Matthijs Mekking
e172b4ff1a rollover-zsk-prepub: From setup.sh to pytest bootstrap
Symlink ns1 and ns2 to rollover/ns1 and rollover/ns2.
Symlink ns3/template.db.j2.manual to rollover/ns3/template.db.j2.manual.

Since the bootstrapping is done before the templates are rendered
automatically, replace @DEFAULT_ALGORITHM@ in ns3/kasp.conf.j2 to
ecdsa256 and rename to ns3/kasp.conf.
2025-12-19 11:47:50 +01:00
Matthijs Mekking
da04c75cec rollover-straight2none: From setup.sh to pytest bootstrap
Similar to rollover-going-insecure.
2025-12-19 11:47:50 +01:00
Matthijs Mekking
4ed35f02b1 rollover-ksk-3crowd: From setup.sh to pytest bootstrap
Similar to rollover-ksk-doubleksk.
2025-12-19 11:47:50 +01:00
Matthijs Mekking
08236f4bd6 rollover-ksk-doubleksk: From setup.sh to pytest bootstrap
Symlink ns1 and ns2 to rollover/ns1 and rollover/ns2.
Symlink ns3/template.db.j2.manual to rollover/ns3/template.db.j2.manual.

Since the bootstrapping is done before the templates are rendered
automatically, replace @DEFAULT_ALGORITHM@ in ns3/kasp.conf.j2 to
ecdsa256 and rename to ns3/kasp.conf.
2025-12-19 11:47:50 +01:00
Matthijs Mekking
cc4244f384 rollover-going-insecure: From setup.sh to pytest bootstrap
Symlink ns1 and ns2 to rollover/ns1 and rollover/ns2.
Symlink ns3/template.db.j2.manual to rollover/ns3/template.db.j2.manual.

Since the bootstrapping is done before the templates are rendered
automatically, replace @DEFAULT_ALGORITHM@ in ns3/kasp.conf.j2 to
ecdsa256 and rename to ns3/kasp.conf.

Now we have to fake different lifetimes, so adjust fake_lifetime
to update a single key.

Note that we have changed the setup slightly: We also sign the
step2 zones, but with post validation disabled. This is more
accurate because we need to test that the public keys and signatures
are being removed from the zone.
2025-12-19 11:47:50 +01:00
Matthijs Mekking
ef2a824df6 rollover-enable-dnssec: From setup.sh to pytest bootstrap
Symlink ns1 and ns2 to rollover/ns1 and rollover/ns2.
Symlink ns3/template.db.j2.manual to rollover/ns3/template.db.j2.manual.

Since the bootstrapping is done before the templates are rendered
automatically, replace @DEFAULT_ALGORITHM_NUMBER@ in ns3/kasp.conf.j2 to
13 and rename to ns3/kasp.conf.

This test introduces an unsigned delegation, adjust render_and_sign_zone
and configure_tld accordingly.
2025-12-19 11:47:50 +01:00
Matthijs Mekking
ef7d617e3f rollover-csk-roll2: From setup.sh to pytest bootstrap
Similar to rollover-csk-roll1.
2025-12-19 11:47:50 +01:00
Matthijs Mekking
1635bcf1ef rollover-csk-roll1: From setup.sh to pytest bootstrap
Symlink ns1 and ns2 to rollover/ns1 and rollover/ns2.
Symlink ns3/template.db.j2.manual to rollover/ns3/template.db.j2.manual.

Since the bootstrapping is done before the templates are rendered
automatically, replace @DEFAULT_ALGORITHM@ in ns3/kasp.conf.j2 to
ecdsa256 and rename to ns3/kasp.conf.

Write a python method to set the key predecessor/successor relationship
into the key state files.
2025-12-19 11:47:50 +01:00
Matthijs Mekking
72d3551355 rollover-algo-ksk-zsk: From setup.sh to pytest bootstrap
Symlink ns1 and ns2 to rollover/ns1 and rollover/ns2.
Symlink ns3/template.db.j2.manual to rollover/ns3/template.db.j2.manual.

The RSASHA256 keys are generated with dnssec-keygen, without a policy
provided. Thus we have to fake the lifetime for these keys.

Signing has to be done without the -z option, because the KSK should
not sign all records in case of a KSK/ZSK split. Update the signing
code to allow for extra options when signing with CSK only.
2025-12-19 11:47:50 +01:00
Matthijs Mekking
3a6ed195fa rollover-algo-csk: From setup.sh to pytest bootstrap
Symlink ns1 and ns2 to rollover/ns1 and rollover/ns2.
Symlink ns3/template.db.j2.manual to rollover/ns3/template.db.j2.manual.

Since the bootstrapping is done before the templates are rendered
automatically, replace @DEFAULT_ALGORITHM@ in ns3/csk2.conf.j2 to
ecdsa256 and rename to ns3/csk2.conf.
2025-12-19 11:47:50 +01:00
Matthijs Mekking
f31514e658 rollover: From setup.sh to pytest bootstrap
Introduce rollover/setup.py for all setup related test code.

Introduce rollover/ns1 and rollover/ns2 to create a chain of trust to
all rollover related test zones. The tld zones in rollover/ns2 contain
a DSYNC record that at a later time will be used for testing Generalized
DNS Notifications.

Write a python version of private_type_record so we can put such
records in the zone via jinja2 templating.
2025-12-19 11:47:49 +01:00
Nicki Křížek
f33e2b6d87 Refactor NamedInstance.rndc() to use EnvCmd() interface
To unify the command handling, utilize EnvCmd() to handle rndc commands:

1. Remove isctest.rndc abstractions. They were intended for an upcoming
   python-only implementation. A couple of years later, it doesn't seem
   to be coming any time soon, so let's stick with the interface that
   makes sense today, i.e. use the same command handling interface
   everywhere.
2. Remove the specialized rndc.log in favor of the generic logging
   already implemented by isctest.run.cmd(). I believe the cause of the
   many rndc(log=False) invocations was that nobody wanted this extra
   file. Yet, logging everything by default makes sense for debugging,
   unless there's a good reason not to. In almost all cases, logging was
   switched to the default (enabled).
3. With the NamedInstance.rndc() call now returning CmdResult rather
   than combined stdout+stderr string, adjust all the invocations to use
   `.out` or `.err` as necessary.
4. Replace some manual rndc invocation and its base argument
   construction with the standardized nsX.rndc() call.
5. In cases where rndc is expected to fail, utilize
   raise_on_exception=False and check the `.rc` from the result, rather
   than handling an exception.
6. In addzone/tests_rndc_deadlock.py, refactor the test slightly to
   avoid using EnvCmd() entirely to avoid spamming the logs. This test
   calls rndc in a loop from multiple threads and such test case is an
   exception which doesn't warrant changing the `isctest.run.cmd()`
   implementation.
2025-12-08 14:57:47 +01:00
Matthijs Mekking
149ca5d46a Rollover test case for rumoured zone signatures
Test a manual rollover when zone signatures have not become omnipresent
yet. This should not immediately remove the predecessor key.
2025-12-05 12:14:14 +01:00
Nicki Křížek
e49c467efb Use full path for shared test code imports in rollover tests
Previously, symlinks and relative directory imports were used in test
modules. This caused a name clash when a shared code module "common.py"
was introduced for a different test. To avoid the issue, use full paths
in imports.
2025-08-05 23:01:04 -07:00
Nicki Křížek
467b826162 Add wait_for_keymgr_done() util function to tests
The kasp test cases assume that keymgr operations on the zone under test
have been completed before the test is executed. These are typically
quite fast, but the logs need to be explicitly checked for the messages,
otherwise there's a possibility of race conditions causing the
kasp/rollover tests to become unstable.

Call the wait function in all the kasp/rollover tests where it is
expected (which is generally in each test, unless we're dealing with
unsigned zones).
2025-07-18 14:37:32 +02:00
Nicki Křížek
fe55342916 Add nsX fixtures to system tests
Many of our test cases only use a single NamedInstance from the
`servers` fixture. Introduce `nsX` helper fixtures to simplify these
tests and reduce boilterplate code further.

Specifically, the test no longer has to either define its own variable
to extract a single server from the list, or use the longer
servers["nsX"] syntax. While this may seem minor, the amount of times it
is repeated across the tests justifies the change. It also promotes
using more explicit server identification, i.e. `nsX`, rather than
generic `server`. This also improves the clarity of the tests and may be
helpful in traceback during debugging as well.
2025-07-18 14:37:32 +02:00
Nicki Křížek
42b034460f Clean up rollover test case 2025-07-18 13:43:53 +02:00
Nicki Křížek
86c3c1da77 Isolate rollover-multisigner test case 2025-07-18 13:43:51 +02:00
Nicki Křížek
e294177312 Isolate rollover-enable-dnssec test case 2025-07-18 13:37:58 +02:00
Nicki Křížek
64199e062d Isolate rollover-zsk-prepub test case 2025-07-18 13:37:58 +02:00
Nicki Křížek
bc7be041e1 Isolate rollover-ksk-3crowd test case 2025-07-18 13:37:58 +02:00
Nicki Křížek
d6dffe6603 Use common test functions for three-is-a-crowd test
Previously, a lot of the checking was re-implemented and duplicated from
check_rollover_step(). Use that function where possible and only
override the needed checks.
2025-07-18 13:37:58 +02:00
Nicki Křížek
bd5a55c5b7 Isolate rollover-ksk-doubleksk test case 2025-07-18 13:37:58 +02:00
Nicki Křížek
296cfc8363 Isolate rollover-csk-roll1 test case 2025-07-18 13:37:58 +02:00
Nicki Křížek
9d2bd1b646 Isolate rollover-csk-roll2 test case 2025-07-18 13:37:58 +02:00
Nicki Křížek
fdecef5378 Isolate rollover-algo-csk test 2025-07-18 13:37:58 +02:00
Nicki Křížek
8be9a8b52a Isolate rollover-algo-ksk-zsk test 2025-07-18 13:37:58 +02:00
Nicki Křížek
519f9082df Isolate rollover-straight2none test 2025-07-18 13:37:58 +02:00
Nicki Křížek
a9c70c3e26 Isolate rollover-lifetime test 2025-07-18 13:37:58 +02:00
Nicki Křížek
7001056eab Isolate rollover-going-insecure test case 2025-07-18 13:37:58 +02:00
Nicki Křížek
8503a218c3 Isolate rollover-dynamic2inline test 2025-07-18 13:37:58 +02:00
Nicki Křížek
44dd5b3240 Separate common templates and test code for rollover tests
This is a preparation to split up and further isolate the various
rollover tests in a subsequent commits.
2025-07-18 13:37:58 +02:00
Nicki Křížek
b410710354 Move shared test code into isctest.kasp module
Move key calculations and rollover step checks into the shared
isctest.kasp module. Deduplicate the key interval calculations.
2025-07-18 13:37:58 +02:00
Nicki Křížek
784a252425 Use a single named.conf template in rollover test
Rather than using multiple slightly modified named.conf files, use a
single template which can be rendered differently based on an input
argument -- in this case, csk_roll.
2025-07-18 13:37:58 +02:00
Nicki Křížek
9f3f6ec38e Log command stdout when using isctest.run.cmd()
The command's stdout may provide useful debug info, so make sure we log
it by default. It doesn't seem to have a significant impact on the log
size.
2025-06-27 16:31:49 +02:00
Matthijs Mekking
80992c7b96 Convert algorithm rollover tests to pytest
Roll the algorithm rollover test cases over to the rollover directory
and rewrite using pytest.
2025-06-18 10:01:24 +02:00
Matthijs Mekking
b1d8217d1a Convert going insecure kasp test to pytest
When going insecure, we publish CDS and CDNSKEY DELETE records. Update
the check_apex function to test this.

Also, skip some tests in the 'check_rollover_step()' function. If
we change the DNSSEC Policy, keys that no longer match the policy will
be retired. When this exactly happens is hard to determine, as it
happens on the reconfigure. So for these tests, we skip the key timing
metadata checks.

Also, the zone becomes unsigned, so don't call 'check_zone_is_signed'
in those cases.
2025-06-18 10:01:24 +02:00
Matthijs Mekking
de3c0970eb Convert policy changes tests to pytest
These test cases involve a reconfiguration. The first one is a zone
that changes from dynamic to inline-signing. The others are tests that
key lifetimes are updated correctly after changing them.
2025-06-18 10:01:24 +02:00
Mark Andrews
80fedf7fcf unstable rollover/tests_rollover.py::test_rollover_manual
The state files need to be written before trying to identify zsk/ksk
keys.  Wait for "keymgr: manual-rollover.kasp done" to appear in
named.run first.
2025-06-17 14:32:49 +10:00
Nicki Křížek
c00121b4c2 Add dynamic update facility to NamedInstance
Deduplicate the code for dynamic updates and increase code clarity by
using an actual dns.update.UpdateMessage rather than an undefined
intermediary format passed around as a list of arguments.
2025-06-02 09:21:06 +00:00
Matthijs Mekking
fd290f391f Convert csk rollover test cases to pytest
Move the 'csk-roll1' and 'csk-roll2' zones to the rollover test dir and
convert CSK rollover tests to pytest.

The DS swap spans multiple steps. Only the first time we should check
if the "CDS is now published" log is there, and only the first time we
should run 'rndc dnssec -checkds' on the keys. Add a new key to the
step dictionary to disable the DS swap checks.

This made me realize that we need to check for "is not None" in case
the value in the dictionary is False. Update check_rollover_step()
accordingly, and also add a log message which step/zone we are currently
checking.
2025-06-02 09:21:06 +00:00
Matthijs Mekking
46800e407e Convert the 'three is a crowd' test case to pytest
This test shows similarities with the Double KSK rollover method, so
put the test in there.
2025-06-02 09:21:06 +00:00