diff --git a/bin/tests/system/conftest.py b/bin/tests/system/conftest.py index b2102edbd3..4dd279e7bd 100644 --- a/bin/tests/system/conftest.py +++ b/bin/tests/system/conftest.py @@ -274,7 +274,7 @@ def control_port(): @pytest.fixture(scope="module") def default_algorithm(): - return isctest.vars.algorithms.Algorithm.default() + return isctest.algorithms.Algorithm.default() @pytest.fixture(scope="module") diff --git a/bin/tests/system/dnssec_py/tests_mixed_ds.py b/bin/tests/system/dnssec_py/tests_mixed_ds.py index a3c9d43845..57ca84457f 100644 --- a/bin/tests/system/dnssec_py/tests_mixed_ds.py +++ b/bin/tests/system/dnssec_py/tests_mixed_ds.py @@ -12,8 +12,8 @@ from re import compile as Re from dnssec_py.common import DNSSEC_PY_MARK +from isctest.algorithms import Algorithm from isctest.template import NS2, NS3, zones -from isctest.vars.algorithms import Algorithm from isctest.zone import Zone, configure_root import isctest diff --git a/bin/tests/system/isctest/__init__.py b/bin/tests/system/isctest/__init__.py index 30256087b3..326b77f0d4 100644 --- a/bin/tests/system/isctest/__init__.py +++ b/bin/tests/system/isctest/__init__.py @@ -10,6 +10,7 @@ # information regarding copyright ownership. from . import ( # pylint: disable=redefined-builtin + algorithms, check, hypothesis, instance, @@ -29,6 +30,7 @@ from . import ( # pylint: disable=redefined-builtin # instead. __all__ = [ + "algorithms", "check", "hypothesis", "instance", diff --git a/bin/tests/system/isctest/algorithms.py b/bin/tests/system/isctest/algorithms.py new file mode 100644 index 0000000000..0950f16c63 --- /dev/null +++ b/bin/tests/system/isctest/algorithms.py @@ -0,0 +1,51 @@ +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +from typing import NamedTuple + +import os + + +class Algorithm(NamedTuple): + name: str + number: int + bits: int + + @classmethod + def default(cls): + return cls( + os.environ["DEFAULT_ALGORITHM"], + int(os.environ["DEFAULT_ALGORITHM_NUMBER"]), + int(os.environ["DEFAULT_BITS"]), + ) + + +RSASHA1 = Algorithm("RSASHA1", 5, 2048) +NSEC3RSASHA1 = Algorithm("NSEC3RSASHA1", 7, 2048) +RSASHA256 = Algorithm("RSASHA256", 8, 2048) +RSASHA512 = Algorithm("RSASHA512", 10, 2048) +ECDSAP256SHA256 = Algorithm("ECDSAP256SHA256", 13, 256) +ECDSAP384SHA384 = Algorithm("ECDSAP384SHA384", 14, 384) +ED25519 = Algorithm("ED25519", 15, 256) +ED448 = Algorithm("ED448", 16, 456) + +ALL_ALGORITHMS = [ + RSASHA1, + NSEC3RSASHA1, + RSASHA256, + RSASHA512, + ECDSAP256SHA256, + ECDSAP384SHA384, + ED25519, + ED448, +] + +ALL_ALGORITHMS_BY_NUM = {alg.number: alg for alg in ALL_ALGORITHMS} diff --git a/bin/tests/system/isctest/kasp.py b/bin/tests/system/isctest/kasp.py index a566b39615..ba7975c811 100644 --- a/bin/tests/system/isctest/kasp.py +++ b/bin/tests/system/isctest/kasp.py @@ -28,8 +28,8 @@ import dns.rdatatype import dns.tsig import dns.zone +from isctest.algorithms import ALL_ALGORITHMS_BY_NUM, ECDSAP256SHA256, Algorithm from isctest.instance import NamedInstance -from isctest.vars.algorithms import ALL_ALGORITHMS_BY_NUM, ECDSAP256SHA256, Algorithm from isctest.zone import FileZoneKey import isctest.log diff --git a/bin/tests/system/isctest/vars/algorithms.py b/bin/tests/system/isctest/vars/algorithms.py index 63b574965f..6a37546bfd 100644 --- a/bin/tests/system/isctest/vars/algorithms.py +++ b/bin/tests/system/isctest/vars/algorithms.py @@ -19,6 +19,16 @@ import tempfile import time from .. import log +from ..algorithms import ( + ALL_ALGORITHMS, + ECDSAP256SHA256, + ECDSAP384SHA384, + ED448, + ED25519, + RSASHA256, + RSASHA512, + Algorithm, +) from .basic import BASIC_VARS # Algorithms are selected randomly at runtime from a list of supported @@ -52,20 +62,6 @@ STABLE_PERIOD = 3600 * 3 """number of secs during which algorithm selection remains stable""" -class Algorithm(NamedTuple): - name: str - number: int - bits: int - - @classmethod - def default(cls): - return cls( - os.environ["DEFAULT_ALGORITHM"], - int(os.environ["DEFAULT_ALGORITHM_NUMBER"]), - int(os.environ["DEFAULT_BITS"]), - ) - - class AlgorithmSet(NamedTuple): """Collection of DEFAULT, ALTERNATIVE and DISABLED algorithms""" @@ -81,28 +77,6 @@ class AlgorithmSet(NamedTuple): "disable-algorithms" configuration option.""" -RSASHA1 = Algorithm("RSASHA1", 5, 2048) -NSEC3RSASHA1 = Algorithm("NSEC3RSASHA1", 7, 2048) -RSASHA256 = Algorithm("RSASHA256", 8, 2048) -RSASHA512 = Algorithm("RSASHA512", 10, 2048) -ECDSAP256SHA256 = Algorithm("ECDSAP256SHA256", 13, 256) -ECDSAP384SHA384 = Algorithm("ECDSAP384SHA384", 14, 384) -ED25519 = Algorithm("ED25519", 15, 256) -ED448 = Algorithm("ED448", 16, 456) - -ALL_ALGORITHMS = [ - RSASHA1, - NSEC3RSASHA1, - RSASHA256, - RSASHA512, - ECDSAP256SHA256, - ECDSAP384SHA384, - ED25519, - ED448, -] - -ALL_ALGORITHMS_BY_NUM = {alg.number: alg for alg in ALL_ALGORITHMS} - ALGORITHM_SETS = { "stable": AlgorithmSet( default=ECDSAP256SHA256, alternative=RSASHA256, disabled=ECDSAP384SHA384 diff --git a/bin/tests/system/isctest/zone.py b/bin/tests/system/isctest/zone.py index 8f5a886627..359d0f2707 100644 --- a/bin/tests/system/isctest/zone.py +++ b/bin/tests/system/isctest/zone.py @@ -30,10 +30,7 @@ import dns.rdatatype import dns.rrset import dns.zonefile -from .log import debug -from .run import EnvCmd -from .template import NS1, Nameserver, TemplateEngine, TrustAnchor -from .vars.algorithms import ( +from .algorithms import ( ALL_ALGORITHMS_BY_NUM, ECDSAP256SHA256, ECDSAP384SHA384, @@ -41,6 +38,9 @@ from .vars.algorithms import ( ED25519, Algorithm, ) +from .log import debug +from .run import EnvCmd +from .template import NS1, Nameserver, TemplateEngine, TrustAnchor KEYDIR = "keys" DNSKEY_TTL = 3600 diff --git a/bin/tests/system/kasp/tests_kasp.py b/bin/tests/system/kasp/tests_kasp.py index c4ce8f738c..63d8477692 100644 --- a/bin/tests/system/kasp/tests_kasp.py +++ b/bin/tests/system/kasp/tests_kasp.py @@ -25,9 +25,9 @@ import dns.tsig import dns.update import pytest +from isctest.algorithms import ECDSAP256SHA256, ECDSAP384SHA384, Algorithm from isctest.kasp import KeyProperties, KeyTimingMetadata from isctest.util import param -from isctest.vars.algorithms import ECDSAP256SHA256, ECDSAP384SHA384, Algorithm import isctest import isctest.mark diff --git a/bin/tests/system/ksr/tests_ksr.py b/bin/tests/system/ksr/tests_ksr.py index e05172e103..19e7e94321 100644 --- a/bin/tests/system/ksr/tests_ksr.py +++ b/bin/tests/system/ksr/tests_ksr.py @@ -18,8 +18,8 @@ import time import pytest +from isctest.algorithms import Algorithm from isctest.kasp import KeyTimingMetadata -from isctest.vars.algorithms import Algorithm from rollover.common import TIMEDELTA import isctest diff --git a/bin/tests/system/migrate2kasp/tests_migrate2kasp.py b/bin/tests/system/migrate2kasp/tests_migrate2kasp.py index 3e4150ee7f..750eee509b 100644 --- a/bin/tests/system/migrate2kasp/tests_migrate2kasp.py +++ b/bin/tests/system/migrate2kasp/tests_migrate2kasp.py @@ -15,7 +15,7 @@ import os import pytest -from isctest.vars.algorithms import Algorithm +from isctest.algorithms import Algorithm import isctest diff --git a/bin/tests/system/nsec3/tests_nsec3_change.py b/bin/tests/system/nsec3/tests_nsec3_change.py index b8a8b066e3..564a670d63 100644 --- a/bin/tests/system/nsec3/tests_nsec3_change.py +++ b/bin/tests/system/nsec3/tests_nsec3_change.py @@ -17,7 +17,7 @@ import dns.rdataclass import dns.rdatatype import pytest -from isctest.vars.algorithms import Algorithm +from isctest.algorithms import Algorithm from nsec3.common import NSEC3_MARK, check_nsec3_case import isctest diff --git a/bin/tests/system/nsec3/tests_nsec3_initial.py b/bin/tests/system/nsec3/tests_nsec3_initial.py index 0cc53c81aa..7038dc6ab0 100644 --- a/bin/tests/system/nsec3/tests_nsec3_initial.py +++ b/bin/tests/system/nsec3/tests_nsec3_initial.py @@ -15,7 +15,7 @@ import dns.rcode import dns.update import pytest -from isctest.vars.algorithms import RSASHA1, Algorithm +from isctest.algorithms import RSASHA1, Algorithm from nsec3.common import NSEC3_MARK, check_nsec3_case import isctest diff --git a/bin/tests/system/nsec3/tests_nsec3_reconfig.py b/bin/tests/system/nsec3/tests_nsec3_reconfig.py index 9efc486791..5dbb294d41 100644 --- a/bin/tests/system/nsec3/tests_nsec3_reconfig.py +++ b/bin/tests/system/nsec3/tests_nsec3_reconfig.py @@ -18,7 +18,7 @@ import dns.rdataclass import dns.rdatatype import pytest -from isctest.vars.algorithms import RSASHA1, Algorithm +from isctest.algorithms import RSASHA1, Algorithm from nsec3.common import NSEC3_MARK, check_nsec3_case import isctest diff --git a/bin/tests/system/nsec3/tests_nsec3_restart.py b/bin/tests/system/nsec3/tests_nsec3_restart.py index ca6ebef811..aed7c41781 100644 --- a/bin/tests/system/nsec3/tests_nsec3_restart.py +++ b/bin/tests/system/nsec3/tests_nsec3_restart.py @@ -14,7 +14,7 @@ import os import dns.rdatatype import pytest -from isctest.vars.algorithms import Algorithm +from isctest.algorithms import Algorithm from nsec3.common import NSEC3_MARK, check_nsec3_case, check_nsec3param import isctest diff --git a/bin/tests/system/nsec3/tests_nsec3_retransfer.py b/bin/tests/system/nsec3/tests_nsec3_retransfer.py index 6fd2e86080..fcd36c5e8d 100644 --- a/bin/tests/system/nsec3/tests_nsec3_retransfer.py +++ b/bin/tests/system/nsec3/tests_nsec3_retransfer.py @@ -16,7 +16,7 @@ import os import dns.rcode import dns.rdatatype -from isctest.vars.algorithms import RSASHA256 +from isctest.algorithms import RSASHA256 from nsec3.common import NSEC3_MARK, check_auth_nsec3, check_nsec3param import isctest diff --git a/bin/tests/system/rollover/setup.py b/bin/tests/system/rollover/setup.py index c71b871562..4aa11025ed 100644 --- a/bin/tests/system/rollover/setup.py +++ b/bin/tests/system/rollover/setup.py @@ -13,10 +13,10 @@ from pathlib import Path import shutil +from isctest.algorithms import Algorithm from isctest.kasp import private_type_record from isctest.run import EnvCmd from isctest.template import NS2, NS3, TrustAnchor, Zone -from isctest.vars.algorithms import Algorithm import isctest diff --git a/bin/tests/system/rollover/tests_rollover_manual.py b/bin/tests/system/rollover/tests_rollover_manual.py index 17d446fcc9..240de4fd8a 100644 --- a/bin/tests/system/rollover/tests_rollover_manual.py +++ b/bin/tests/system/rollover/tests_rollover_manual.py @@ -11,10 +11,10 @@ from datetime import timedelta +from isctest.algorithms import Algorithm from isctest.kasp import Ipub, Iret, KeyTimingMetadata, private_type_record from isctest.run import EnvCmd from isctest.template import NS3, Zone -from isctest.vars.algorithms import Algorithm from rollover.setup import configure_root, configure_tld import isctest