From: Nicki Křížek Date: Tue, 30 Dec 2025 13:29:51 +0000 (+0100) Subject: Remove compatibility hacks for dnspython<2.7.0 X-Git-Tag: v9.21.18~21^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ce385d8100b9dfc14b6233453ea7dbcf0db56b3b;p=thirdparty%2Fbind9.git Remove compatibility hacks for dnspython<2.7.0 The minimum required dnspython version is now 2.7.0 and those compatibility hacks can be dropped. --- diff --git a/bin/tests/system/bailiwick/tests_bailiwick.py b/bin/tests/system/bailiwick/tests_bailiwick.py index 7245c71bce2..bd844bd71a3 100644 --- a/bin/tests/system/bailiwick/tests_bailiwick.py +++ b/bin/tests/system/bailiwick/tests_bailiwick.py @@ -17,9 +17,6 @@ import dns.message import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - import isctest from isctest.instance import NamedInstance diff --git a/bin/tests/system/chain/ans3/ans.py b/bin/tests/system/chain/ans3/ans.py index 2b0c41ccb73..f10387fbf44 100755 --- a/bin/tests/system/chain/ans3/ans.py +++ b/bin/tests/system/chain/ans3/ans.py @@ -28,13 +28,6 @@ from isctest.asyncserver import ( ResponseAction, ) -try: - dns_namerelation_equal = dns.name.NameRelation.EQUAL - dns_namerelation_subdomain = dns.name.NameRelation.SUBDOMAIN -except AttributeError: # dnspython < 2.3.0 compat - dns_namerelation_equal = dns.name.NAMERELN_EQUAL # type: ignore - dns_namerelation_subdomain = dns.name.NAMERELN_SUBDOMAIN # type: ignore - def get_dname_rrset_at_name( zone: dns.zone.Zone, name: dns.name.Name @@ -94,11 +87,11 @@ class Cve202125215(DomainHandler): relation, _, _ = qctx.qname.fullcompare(self_example_dname) - if relation in (dns_namerelation_equal, dns_namerelation_subdomain): + if relation in (dns.name.NameRelation.EQUAL, dns.name.NameRelation.SUBDOMAIN): del qctx.response.authority[:] qctx.response.set_rcode(dns.rcode.NOERROR) - if relation == dns_namerelation_subdomain: + if relation == dns.name.NameRelation.SUBDOMAIN: qctx.response.answer.append(dname_rrset) cname_rrset = dns.rrset.from_text( qctx.qname, diff --git a/bin/tests/system/chain/tests_sh_chain.py b/bin/tests/system/chain/tests_sh_chain.py index 5aa86d9082f..f7d7ac3b015 100644 --- a/bin/tests/system/chain/tests_sh_chain.py +++ b/bin/tests/system/chain/tests_sh_chain.py @@ -11,9 +11,6 @@ import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - pytestmark = pytest.mark.extra_artifacts( [ "dig.out.*", diff --git a/bin/tests/system/checkds/tests_checkds.py b/bin/tests/system/checkds/tests_checkds.py index 8be24a830bc..9cf46a3843d 100755 --- a/bin/tests/system/checkds/tests_checkds.py +++ b/bin/tests/system/checkds/tests_checkds.py @@ -21,7 +21,6 @@ import time import isctest import pytest -pytest.importorskip("dns", minversion="2.0.0") import dns.exception import dns.message import dns.name diff --git a/bin/tests/system/cipher-suites/tests_cipher_suites.py b/bin/tests/system/cipher-suites/tests_cipher_suites.py index 86adc29da11..782a24509f9 100644 --- a/bin/tests/system/cipher-suites/tests_cipher_suites.py +++ b/bin/tests/system/cipher-suites/tests_cipher_suites.py @@ -13,8 +13,6 @@ from re import compile as Re import pytest -pytest.importorskip("dns", minversion="2.5.0") - import dns.message import isctest diff --git a/bin/tests/system/cookie/tests_sh_cookie.py b/bin/tests/system/cookie/tests_sh_cookie.py index d5f88dedebd..1c9e8280f5d 100644 --- a/bin/tests/system/cookie/tests_sh_cookie.py +++ b/bin/tests/system/cookie/tests_sh_cookie.py @@ -11,9 +11,6 @@ import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - pytestmark = pytest.mark.extra_artifacts( [ "dig.out.*", diff --git a/bin/tests/system/digdelv/tests_sh_digdelv.py b/bin/tests/system/digdelv/tests_sh_digdelv.py index 3ed7811c1cb..2b3a72644b7 100644 --- a/bin/tests/system/digdelv/tests_sh_digdelv.py +++ b/bin/tests/system/digdelv/tests_sh_digdelv.py @@ -11,9 +11,6 @@ import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - pytestmark = pytest.mark.extra_artifacts( [ "delv.out.*", diff --git a/bin/tests/system/dispatch/tests_connreset.py b/bin/tests/system/dispatch/tests_connreset.py index 6c7f7140a60..01a1bbc5c09 100644 --- a/bin/tests/system/dispatch/tests_connreset.py +++ b/bin/tests/system/dispatch/tests_connreset.py @@ -14,9 +14,6 @@ import pytest import isctest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - import dns.message pytestmark = pytest.mark.extra_artifacts( diff --git a/bin/tests/system/dnssec-malformed-dnskey/tests_malformed_dnskey.py b/bin/tests/system/dnssec-malformed-dnskey/tests_malformed_dnskey.py index b83edf18739..d66644ce7b2 100644 --- a/bin/tests/system/dnssec-malformed-dnskey/tests_malformed_dnskey.py +++ b/bin/tests/system/dnssec-malformed-dnskey/tests_malformed_dnskey.py @@ -16,9 +16,6 @@ import os import pytest pytest.importorskip("cryptography") -pytest.importorskip( - "dns", minversion="2.7.0" -) # dns.dnssec.sign_zone(deterministic=...) needed from cryptography.hazmat.primitives.asymmetric import ec diff --git a/bin/tests/system/dnssec/tests_badkey.py b/bin/tests/system/dnssec/tests_badkey.py index 6c318c9936c..ca80734d4d7 100644 --- a/bin/tests/system/dnssec/tests_badkey.py +++ b/bin/tests/system/dnssec/tests_badkey.py @@ -16,9 +16,6 @@ import pytest import isctest from isctest.util import param -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/dnssec/tests_badkey_broken.py b/bin/tests/system/dnssec/tests_badkey_broken.py index ae7050e02e6..1471ad0ca29 100644 --- a/bin/tests/system/dnssec/tests_badkey_broken.py +++ b/bin/tests/system/dnssec/tests_badkey_broken.py @@ -9,14 +9,10 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. -import pytest from dns import flags import isctest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - def bootstrap(): return { diff --git a/bin/tests/system/dnssec/tests_badkey_revoked.py b/bin/tests/system/dnssec/tests_badkey_revoked.py index 473c4479722..cb137b26ab1 100644 --- a/bin/tests/system/dnssec/tests_badkey_revoked.py +++ b/bin/tests/system/dnssec/tests_badkey_revoked.py @@ -10,10 +10,6 @@ # information regarding copyright ownership. import isctest -import pytest - -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") def bootstrap(): diff --git a/bin/tests/system/dnssec/tests_delv.py b/bin/tests/system/dnssec/tests_delv.py index 5c24abb2cf2..436c869d869 100644 --- a/bin/tests/system/dnssec/tests_delv.py +++ b/bin/tests/system/dnssec/tests_delv.py @@ -17,9 +17,6 @@ import pytest import isctest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/dnssec/tests_policy.py b/bin/tests/system/dnssec/tests_policy.py index 51801d5d86c..28612b3a484 100644 --- a/bin/tests/system/dnssec/tests_policy.py +++ b/bin/tests/system/dnssec/tests_policy.py @@ -18,9 +18,6 @@ import pytest import isctest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/dnssec/tests_signing.py b/bin/tests/system/dnssec/tests_signing.py index 955f7f98ad4..01ccff164c6 100644 --- a/bin/tests/system/dnssec/tests_signing.py +++ b/bin/tests/system/dnssec/tests_signing.py @@ -20,7 +20,6 @@ from dns import dnssec, name, rdataclass, rdatatype, update import pytest -pytest.importorskip("dns", minversion="2.0.0") from isctest.kasp import SettimeOptions import isctest diff --git a/bin/tests/system/dnssec/tests_tat.py b/bin/tests/system/dnssec/tests_tat.py index 543207a117d..6fdfe36992a 100644 --- a/bin/tests/system/dnssec/tests_tat.py +++ b/bin/tests/system/dnssec/tests_tat.py @@ -18,9 +18,6 @@ import pytest import isctest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/dnssec/tests_validation.py b/bin/tests/system/dnssec/tests_validation.py index 2e8d94395a0..9a74873392f 100644 --- a/bin/tests/system/dnssec/tests_validation.py +++ b/bin/tests/system/dnssec/tests_validation.py @@ -15,16 +15,14 @@ import shutil import time from dns import flags, name, rdataclass, rdatatype +from dns.edns import EDECode import pytest import isctest -from isctest.compat import EDECode import isctest.mark from isctest.util import param -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/dnssec/tests_validation_accept_expired.py b/bin/tests/system/dnssec/tests_validation_accept_expired.py index d8f97f227b1..409ecfe444a 100644 --- a/bin/tests/system/dnssec/tests_validation_accept_expired.py +++ b/bin/tests/system/dnssec/tests_validation_accept_expired.py @@ -13,11 +13,6 @@ from dns import flags import isctest -import pytest - -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - def bootstrap(): return { diff --git a/bin/tests/system/dnssec/tests_validation_managed_keys.py b/bin/tests/system/dnssec/tests_validation_managed_keys.py index 3cef4d67c96..082400b0001 100644 --- a/bin/tests/system/dnssec/tests_validation_managed_keys.py +++ b/bin/tests/system/dnssec/tests_validation_managed_keys.py @@ -14,11 +14,6 @@ import shutil import isctest -import pytest - -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - def bootstrap(): assert not os.path.exists("ns4/managed-keys.bind.jnl") diff --git a/bin/tests/system/dnssec/tests_validation_many_anchors.py b/bin/tests/system/dnssec/tests_validation_many_anchors.py index a9865db2dce..85be391e865 100644 --- a/bin/tests/system/dnssec/tests_validation_many_anchors.py +++ b/bin/tests/system/dnssec/tests_validation_many_anchors.py @@ -10,15 +10,12 @@ # information regarding copyright ownership. +from dns.edns import EDECode import pytest import isctest -from isctest.compat import EDECode from isctest.util import param -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - def bootstrap(): return { diff --git a/bin/tests/system/dnssec/tests_validation_multiview.py b/bin/tests/system/dnssec/tests_validation_multiview.py index e22f1d420b2..26a8fb450e8 100644 --- a/bin/tests/system/dnssec/tests_validation_multiview.py +++ b/bin/tests/system/dnssec/tests_validation_multiview.py @@ -14,11 +14,6 @@ from re import compile as Re import isctest -import pytest - -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - def bootstrap(): return { diff --git a/bin/tests/system/dnstap/tests_dnstap.py b/bin/tests/system/dnstap/tests_dnstap.py index aec43785eaa..67061ab9a5c 100644 --- a/bin/tests/system/dnstap/tests_dnstap.py +++ b/bin/tests/system/dnstap/tests_dnstap.py @@ -18,7 +18,6 @@ import isctest import isctest.mark import pytest -pytest.importorskip("dns", minversion="2.0.0") import dns.rrset pytestmark = [ diff --git a/bin/tests/system/doth/tests_gnutls.py b/bin/tests/system/doth/tests_gnutls.py index 9c897714efe..42ef3f6973e 100644 --- a/bin/tests/system/doth/tests_gnutls.py +++ b/bin/tests/system/doth/tests_gnutls.py @@ -18,7 +18,7 @@ import time import pytest -pytest.importorskip("dns") +import dns import dns.exception import dns.name import dns.rdataclass diff --git a/bin/tests/system/ede24/common.py b/bin/tests/system/ede24/common.py index 069ddd2ef59..d7dd983e720 100644 --- a/bin/tests/system/ede24/common.py +++ b/bin/tests/system/ede24/common.py @@ -9,8 +9,9 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. +from dns.edns import EDECode + import isctest -from isctest.compat import EDECode def check_soa_noerror(): diff --git a/bin/tests/system/fetchlimit/tests_sh_fetchlimit.py b/bin/tests/system/fetchlimit/tests_sh_fetchlimit.py index 26bdff7fc24..b996c60aa8e 100644 --- a/bin/tests/system/fetchlimit/tests_sh_fetchlimit.py +++ b/bin/tests/system/fetchlimit/tests_sh_fetchlimit.py @@ -11,8 +11,6 @@ import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/forward/tests_sh_forward.py b/bin/tests/system/forward/tests_sh_forward.py index 458928b0bc8..0d30b8c3ad3 100644 --- a/bin/tests/system/forward/tests_sh_forward.py +++ b/bin/tests/system/forward/tests_sh_forward.py @@ -11,8 +11,6 @@ import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/glue/tests_glue.py b/bin/tests/system/glue/tests_glue.py index 517781c7e22..b015f56f236 100644 --- a/bin/tests/system/glue/tests_glue.py +++ b/bin/tests/system/glue/tests_glue.py @@ -16,7 +16,6 @@ import pytest import isctest -pytest.importorskip("dns", minversion="2.0.0") pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/hooks/tests_hooks.py b/bin/tests/system/hooks/tests_hooks.py index 6c721c31dd8..e50720f218e 100644 --- a/bin/tests/system/hooks/tests_hooks.py +++ b/bin/tests/system/hooks/tests_hooks.py @@ -17,7 +17,6 @@ import dns import pytest import isctest -pytest.importorskip("dns") pytestmark = pytest.mark.extra_artifacts(["conf/*.conf"]) diff --git a/bin/tests/system/isctest/asyncserver.py b/bin/tests/system/isctest/asyncserver.py index 85254800e9a..add1ab07ba4 100644 --- a/bin/tests/system/isctest/asyncserver.py +++ b/bin/tests/system/isctest/asyncserver.py @@ -114,7 +114,6 @@ class AsyncServer: tcp_handler: Optional[_TcpHandler], pidfile: Optional[str] = None, ) -> None: - self._abort_if_on_dnspython_version_less_than_2_0_0() logging.basicConfig( format="%(asctime)s %(levelname)8s %(message)s", level=os.environ.get("ANS_LOG_LEVEL", "INFO").upper(), @@ -142,14 +141,6 @@ class AsyncServer: self._pidfile: Optional[str] = pidfile self._work_done: Optional[asyncio.Future] = None - @classmethod - def _abort_if_on_dnspython_version_less_than_2_0_0(cls) -> None: - if dns.version.MAJOR < 2: - error = f"Using {cls.__name__} requires dnspython >= 2.0.0; " - error += 'add `pytest.importorskip("dns", minversion="2.0.0")` ' - error += "to the test module to skip this test." - raise RuntimeError(error) - def _get_ipv4_address_from_directory_name(self) -> str: containing_directory = pathlib.Path().absolute().stem match_result = re.match(r"ans(?P\d+)", containing_directory) diff --git a/bin/tests/system/isctest/check.py b/bin/tests/system/isctest/check.py index 7ca7779a3d3..f7a1f12a849 100644 --- a/bin/tests/system/isctest/check.py +++ b/bin/tests/system/isctest/check.py @@ -15,13 +15,13 @@ import os from typing import cast, List, Optional import dns.edns +from dns.edns import EDECode, EDEOption import dns.flags import dns.message import dns.rcode import dns.zone import isctest.log -from isctest.compat import dns_rcode, EDECode, EDEOption def rcode(message: dns.message.Message, expected_rcode) -> None: @@ -29,19 +29,19 @@ def rcode(message: dns.message.Message, expected_rcode) -> None: def noerror(message: dns.message.Message) -> None: - rcode(message, dns_rcode.NOERROR) + rcode(message, dns.rcode.NOERROR) def notimp(message: dns.message.Message) -> None: - rcode(message, dns_rcode.NOTIMP) + rcode(message, dns.rcode.NOTIMP) def refused(message: dns.message.Message) -> None: - rcode(message, dns_rcode.REFUSED) + rcode(message, dns.rcode.REFUSED) def servfail(message: dns.message.Message) -> None: - rcode(message, dns_rcode.SERVFAIL) + rcode(message, dns.rcode.SERVFAIL) def adflag(message: dns.message.Message) -> None: @@ -84,10 +84,6 @@ def _extract_ede_options( def noede(message: dns.message.Message) -> None: """Check that message contains no EDE option.""" - if not hasattr(dns.edns, "EDECode"): - # dnspython<2.2.0 doesn't support EDE, skip check - return - ede_options = _extract_ede_options(message) assert not ede_options, f"unexpected EDE options {ede_options} in {message}" @@ -96,10 +92,6 @@ def ede( message: dns.message.Message, code: EDECode, text: Optional[str] = None ) -> None: """Check if message contains expected EDE code (and its text).""" - if not hasattr(dns.edns, "EDECode"): - # dnspython<2.2.0 doesn't support EDE, skip check - return - msg_opts = _extract_ede_options(message) matching_opts = [opt for opt in msg_opts if opt.code == code] @@ -206,7 +198,7 @@ def is_executable(cmd: str, errmsg: str) -> None: def named_alive(named_proc, resolver_ip): assert named_proc.poll() is None, "named isn't running" msg = isctest.query.create("version.bind", "TXT", "CH") - isctest.query.tcp(msg, resolver_ip, expected_rcode=dns_rcode.NOERROR) + isctest.query.tcp(msg, resolver_ip, expected_rcode=dns.rcode.NOERROR) def notauth(message: dns.message.Message) -> None: diff --git a/bin/tests/system/isctest/compat.py b/bin/tests/system/isctest/compat.py deleted file mode 100644 index ae6b157c0d4..00000000000 --- a/bin/tests/system/isctest/compat.py +++ /dev/null @@ -1,70 +0,0 @@ -# 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 Any, TYPE_CHECKING - -import dns.edns -import dns.rcode - -# compatiblity with dnspython<2.0.0 -try: - # In dnspython>=2.0.0, dns.rcode.Rcode class is available - # pylint: disable=invalid-name - dns_rcode = dns.rcode.Rcode # type: Any -except AttributeError: - # In dnspython<2.0.0, selected rcodes are available as integers directly - # from dns.rcode - dns_rcode = dns.rcode - - -if TYPE_CHECKING: - EDECode = dns.edns.EDECode - EDEOption = dns.edns.EDEOption -else: - try: # compatiblity with dnspython<2.2.0 - EDECode = dns.edns.EDECode - except AttributeError: - # In dnspython<2.2.0, the dns.edns.EDECode doesn't exist. - # - # The primary use-case is for us to use existing EDECode objects from the - # class, e.g. EDECode.FILTERED. To mimick this behavior, use a string - # factory that just turns the attribute name into a string. - # - # The used compatibility hack doesn't really matter (as long as EDECode.xxx - # doesn't raise exception), as with dnspython versions prior to 2.2.0, any - # EDE checking will be skipped anyway. - class _CompatEDECode: - def __getattr__(self, name: str) -> str: - return name - - EDECode = _CompatEDECode() - try: - EDEOption = dns.edns.EDEOption - except AttributeError: - # In dnspython<2.2.0, the dns.edns.EDEOption doesn't exist, so we stub it to be - # able to use it in type annotations. - class EDEOption: - def __new__(cls, *args, **kwargs): - raise RuntimeError("Using EDEOption requires dnspython>=2.2.0") - - -# pylint: disable=unused-import -try: - from dns.dnssec import DSDigest -except ImportError: # dnspython<2.0.0 - import enum - - class DSDigest(enum.IntEnum): # type: ignore - """DNSSEC Delgation Signer Digest Algorithm""" - - SHA1 = 1 - SHA256 = 2 - SHA384 = 4 diff --git a/bin/tests/system/isctest/hypothesis/strategies.py b/bin/tests/system/isctest/hypothesis/strategies.py index a3f9eac2b27..e8badc6802b 100644 --- a/bin/tests/system/isctest/hypothesis/strategies.py +++ b/bin/tests/system/isctest/hypothesis/strategies.py @@ -143,13 +143,8 @@ def dns_names( RDATACLASS_MAX = RDATATYPE_MAX = 65535 -try: - dns_rdataclasses = builds(dns.rdataclass.RdataClass, integers(0, RDATACLASS_MAX)) - dns_rdatatypes = builds(dns.rdatatype.RdataType, integers(0, RDATATYPE_MAX)) -except AttributeError: - # In old dnspython versions, RDataTypes and RDataClasses are int and not enums. - dns_rdataclasses = integers(0, RDATACLASS_MAX) # type: ignore - dns_rdatatypes = integers(0, RDATATYPE_MAX) # type: ignore +dns_rdataclasses = builds(dns.rdataclass.RdataClass, integers(0, RDATACLASS_MAX)) +dns_rdatatypes = builds(dns.rdatatype.RdataType, integers(0, RDATATYPE_MAX)) dns_rdataclasses_without_meta = dns_rdataclasses.filter(dns.rdataclass.is_metaclass) # NOTE: This should really be `dns_rdatatypes_without_meta = dns_rdatatypes_without_meta.filter(dns.rdatatype.is_metatype()`, diff --git a/bin/tests/system/isctest/instance.py b/bin/tests/system/isctest/instance.py index 83bd51ffa5f..5e4d77517ad 100644 --- a/bin/tests/system/isctest/instance.py +++ b/bin/tests/system/isctest/instance.py @@ -17,7 +17,7 @@ import os from pathlib import Path import re -import dns.message +import dns.update import dns.rcode from .log import debug, WatchLogFromStart, WatchLogFromHere @@ -116,14 +116,11 @@ class NamedInstance: return self._rndc(command, timeout=timeout, **kwargs) def nsupdate( - self, update_msg: dns.message.Message, expected_rcode=dns.rcode.NOERROR + self, update_msg: dns.update.UpdateMessage, expected_rcode=dns.rcode.NOERROR ): """ Issue a dynamic update to a server's zone. """ - # FUTURE update_msg is actually dns.update.UpdateMessage, but it not - # typed properly here in order to support use of this module with - # dnspython<2.0.0 zone = str(update_msg.zone[0].name) # type: ignore[attr-defined] try: response = udp( diff --git a/bin/tests/system/isctest/kasp.py b/bin/tests/system/isctest/kasp.py index 9b718920307..255a5832ccd 100644 --- a/bin/tests/system/isctest/kasp.py +++ b/bin/tests/system/isctest/kasp.py @@ -26,12 +26,9 @@ import dns.rdatatype import dns.rrset import dns.tsig -import pytest - import isctest.log import isctest.query import isctest.util -from isctest.compat import DSDigest from isctest.instance import NamedInstance from isctest.template import TrustAnchor from isctest.run import EnvCmd @@ -511,7 +508,6 @@ class Key: @property def dnskey(self) -> dns.rrset.RRset: - pytest.importorskip("dns", minversion="2.2.0") # dns.zonefile.read_rrsets with open(self.keyfile, "r", encoding="utf-8") as file: rrsets = dns.zonefile.read_rrsets( file.read(), @@ -526,7 +522,7 @@ class Key: ), f"DNSKEY not found in {self.keyfile}" return dnskey_rr - def into_ta(self, ta_type: str, dsdigest=DSDigest.SHA256) -> TrustAnchor: + def into_ta(self, ta_type: str, dsdigest=dns.dnssec.DSDigest.SHA256) -> TrustAnchor: dnskey = self.dnskey if ta_type in ["static-ds", "initial-ds"]: ds = dns.dnssec.make_ds(dnskey.name, dnskey[0], dsdigest) diff --git a/bin/tests/system/isctest/name.py b/bin/tests/system/isctest/name.py index a2fe3ac4242..cc836f85db5 100644 --- a/bin/tests/system/isctest/name.py +++ b/bin/tests/system/isctest/name.py @@ -59,7 +59,6 @@ class ZoneAnalyzer: return cls(zonedb) def __init__(self, zone: dns.zone.Zone): - self._abort_on_old_dnspython() self.zone = zone assert self.zone.origin # mypy hack # based on individual nodes but not relationship between nodes @@ -85,14 +84,6 @@ class ZoneAnalyzer: .union(self.reachable_dnames) ) - def _abort_on_old_dnspython(self): - if not hasattr(dns.name, "NameRelation"): - raise RuntimeError( - "ZoneAnalyzer requires dnspython>=2.3.0 for dns.name.NameRelation support. " - "Use pytest.importorskip('dns', minversion='2.3.0') to the test module to " - "skip this test." - ) - def get_names_with_type(self, rdtype) -> FrozenSet[Name]: return frozenset( name for name in self.zone if self.zone.get_rdataset(name, rdtype) diff --git a/bin/tests/system/isctest/query.py b/bin/tests/system/isctest/query.py index e18b2001de1..daa8ade0142 100644 --- a/bin/tests/system/isctest/query.py +++ b/bin/tests/system/isctest/query.py @@ -17,7 +17,6 @@ import dns.query import dns.message import isctest.log -from isctest.compat import dns_rcode QUERY_TIMEOUT = 10 @@ -30,7 +29,7 @@ def generic_query( source: Optional[str] = None, timeout: int = QUERY_TIMEOUT, attempts: int = 10, - expected_rcode: dns_rcode = None, + expected_rcode: Optional[dns.rcode.Rcode] = None, verify: bool = False, log_query: bool = True, log_response: bool = True, @@ -77,9 +76,9 @@ def generic_query( time.sleep(1) if expected_rcode is not None: - last_rcode = dns_rcode.to_text(res.rcode()) if res else None + last_rcode = dns.rcode.to_text(res.rcode()) if res else None isctest.log.debug( - f"isc.query.{query_func.__name__}(): expected rcode={dns_rcode.to_text(expected_rcode)}, last rcode={last_rcode}" + f"isc.query.{query_func.__name__}(): expected rcode={dns.rcode.to_text(expected_rcode)}, last rcode={last_rcode}" ) raise dns.exception.Timeout diff --git a/bin/tests/system/ixfr/tests_sh_ixfr.py b/bin/tests/system/ixfr/tests_sh_ixfr.py index a8b8143bfc7..171a0c6d2db 100644 --- a/bin/tests/system/ixfr/tests_sh_ixfr.py +++ b/bin/tests/system/ixfr/tests_sh_ixfr.py @@ -11,9 +11,6 @@ import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - pytestmark = pytest.mark.extra_artifacts( [ "dig.out*", diff --git a/bin/tests/system/kasp/tests_kasp.py b/bin/tests/system/kasp/tests_kasp.py index 018b975d5b2..f5a02152dca 100644 --- a/bin/tests/system/kasp/tests_kasp.py +++ b/bin/tests/system/kasp/tests_kasp.py @@ -20,7 +20,6 @@ import dns import dns.update import pytest -pytest.importorskip("dns", minversion="2.0.0") import isctest import isctest.mark from isctest.kasp import ( diff --git a/bin/tests/system/limits/tests_limits.py b/bin/tests/system/limits/tests_limits.py index ca7214a9de4..6949838ec74 100644 --- a/bin/tests/system/limits/tests_limits.py +++ b/bin/tests/system/limits/tests_limits.py @@ -14,9 +14,6 @@ import itertools import isctest import pytest -# Everything from getting a big answer to creating an RR set with thousands -# of records takes minutes of CPU and real time with dnspython < 2.0.0. -pytest.importorskip("dns", minversion="2.0.0") import dns.rrset diff --git a/bin/tests/system/migrate2kasp/tests_migrate2kasp.py b/bin/tests/system/migrate2kasp/tests_migrate2kasp.py index 426ef6d32a8..cb5f6e20516 100644 --- a/bin/tests/system/migrate2kasp/tests_migrate2kasp.py +++ b/bin/tests/system/migrate2kasp/tests_migrate2kasp.py @@ -10,12 +10,10 @@ # information regarding copyright ownership. import os - from datetime import timedelta import pytest -pytest.importorskip("dns", minversion="2.0.0") import isctest import isctest.mark diff --git a/bin/tests/system/multisigner/tests_multisigner.py b/bin/tests/system/multisigner/tests_multisigner.py index 15726f1eb14..a7587972ec5 100644 --- a/bin/tests/system/multisigner/tests_multisigner.py +++ b/bin/tests/system/multisigner/tests_multisigner.py @@ -15,7 +15,6 @@ from re import compile as Re import pytest -pytest.importorskip("dns", minversion="2.0.0") import dns import dns.update diff --git a/bin/tests/system/names/tests_names.py b/bin/tests/system/names/tests_names.py index b72fcbec980..38fc983d089 100644 --- a/bin/tests/system/names/tests_names.py +++ b/bin/tests/system/names/tests_names.py @@ -9,10 +9,6 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. -import pytest - -pytest.importorskip("dns", minversion="2.7.0") - import isctest diff --git a/bin/tests/system/nsec3-answer/tests_nsec3.py b/bin/tests/system/nsec3-answer/tests_nsec3.py index 785f574f426..c3ca0f645f7 100755 --- a/bin/tests/system/nsec3-answer/tests_nsec3.py +++ b/bin/tests/system/nsec3-answer/tests_nsec3.py @@ -18,7 +18,6 @@ from typing import Container, Iterable, Optional, Set, Tuple import pytest -pytest.importorskip("dns", minversion="2.5.0") import dns.dnssec import dns.message import dns.name diff --git a/bin/tests/system/nsec3/tests_nsec3_change.py b/bin/tests/system/nsec3/tests_nsec3_change.py index 4ebb2be2bc6..6da20aaf7ff 100644 --- a/bin/tests/system/nsec3/tests_nsec3_change.py +++ b/bin/tests/system/nsec3/tests_nsec3_change.py @@ -15,10 +15,10 @@ import os import shutil import time +import dns import dns.update import pytest -pytest.importorskip("dns", minversion="2.0.0") import isctest import isctest.mark from isctest.vars.algorithms import RSASHA1 diff --git a/bin/tests/system/nsec3/tests_nsec3_initial.py b/bin/tests/system/nsec3/tests_nsec3_initial.py index b890bf9cbdc..9795cf04cb8 100644 --- a/bin/tests/system/nsec3/tests_nsec3_initial.py +++ b/bin/tests/system/nsec3/tests_nsec3_initial.py @@ -13,10 +13,10 @@ import os +import dns import dns.update import pytest -pytest.importorskip("dns", minversion="2.0.0") import isctest import isctest.mark from isctest.vars.algorithms import RSASHA1 diff --git a/bin/tests/system/nsec3/tests_nsec3_reconfig.py b/bin/tests/system/nsec3/tests_nsec3_reconfig.py index c1edd67fc73..dd29443050b 100644 --- a/bin/tests/system/nsec3/tests_nsec3_reconfig.py +++ b/bin/tests/system/nsec3/tests_nsec3_reconfig.py @@ -15,10 +15,10 @@ import os import shutil import time +import dns import dns.update import pytest -pytest.importorskip("dns", minversion="2.0.0") import isctest import isctest.mark from isctest.vars.algorithms import RSASHA1 diff --git a/bin/tests/system/nsec3/tests_nsec3_reload.py b/bin/tests/system/nsec3/tests_nsec3_reload.py index b3fb860288d..0e0daa884d1 100644 --- a/bin/tests/system/nsec3/tests_nsec3_reload.py +++ b/bin/tests/system/nsec3/tests_nsec3_reload.py @@ -15,9 +15,9 @@ import os import shutil import time +import dns import pytest -pytest.importorskip("dns", minversion="2.0.0") import isctest from nsec3.common import ( ALGORITHM, diff --git a/bin/tests/system/nsec3/tests_nsec3_restart.py b/bin/tests/system/nsec3/tests_nsec3_restart.py index e1e76c4f98a..3505e8a5629 100644 --- a/bin/tests/system/nsec3/tests_nsec3_restart.py +++ b/bin/tests/system/nsec3/tests_nsec3_restart.py @@ -13,10 +13,10 @@ import os +import dns import dns.update import pytest -pytest.importorskip("dns", minversion="2.0.0") import isctest import isctest.mark from nsec3.common import ( diff --git a/bin/tests/system/nsec3/tests_nsec3_retransfer.py b/bin/tests/system/nsec3/tests_nsec3_retransfer.py index 7ba4a44845d..f9a3ca2e509 100644 --- a/bin/tests/system/nsec3/tests_nsec3_retransfer.py +++ b/bin/tests/system/nsec3/tests_nsec3_retransfer.py @@ -11,15 +11,14 @@ # pylint: disable=redefined-outer-name,unused-import +from datetime import timedelta import os import shutil -from datetime import timedelta - +import dns import dns.update import pytest -pytest.importorskip("dns", minversion="2.0.0") import isctest import isctest.mark from isctest.vars.algorithms import RSASHA256 diff --git a/bin/tests/system/nsupdate/tests_sh_nsupdate.py b/bin/tests/system/nsupdate/tests_sh_nsupdate.py index e91d9e5206f..2159a6a7dc9 100644 --- a/bin/tests/system/nsupdate/tests_sh_nsupdate.py +++ b/bin/tests/system/nsupdate/tests_sh_nsupdate.py @@ -13,9 +13,6 @@ import platform import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - pytestmark = pytest.mark.extra_artifacts( [ "Kxxx*", diff --git a/bin/tests/system/optout/tests_optout.py b/bin/tests/system/optout/tests_optout.py index 3f0df0bb532..f004c1a89aa 100755 --- a/bin/tests/system/optout/tests_optout.py +++ b/bin/tests/system/optout/tests_optout.py @@ -19,7 +19,7 @@ import sys import isctest import pytest -pytest.importorskip("dns", minversion="2.0.0") +import dns import dns.exception import dns.message import dns.name diff --git a/bin/tests/system/qmin/tests_sh_qmin.py b/bin/tests/system/qmin/tests_sh_qmin.py index 4f5af7f56c1..0858b5cbf76 100644 --- a/bin/tests/system/qmin/tests_sh_qmin.py +++ b/bin/tests/system/qmin/tests_sh_qmin.py @@ -11,8 +11,6 @@ import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/rollover-multisigner/tests_rollover_multisigner.py b/bin/tests/system/rollover-multisigner/tests_rollover_multisigner.py index b4cd6a67778..b463028bcb4 100644 --- a/bin/tests/system/rollover-multisigner/tests_rollover_multisigner.py +++ b/bin/tests/system/rollover-multisigner/tests_rollover_multisigner.py @@ -16,7 +16,7 @@ import os import pytest -pytest.importorskip("dns", minversion="2.0.0") +import dns import dns.update import isctest diff --git a/bin/tests/system/rpzextra/tests_rpzextra.py b/bin/tests/system/rpzextra/tests_rpzextra.py index aa910f9f7cd..948d747f4a4 100644 --- a/bin/tests/system/rpzextra/tests_rpzextra.py +++ b/bin/tests/system/rpzextra/tests_rpzextra.py @@ -15,12 +15,11 @@ import os import pytest -pytest.importorskip("dns", minversion="2.0.0") +import dns import dns.rcode import dns.rrset import isctest -from isctest.compat import dns_rcode pytestmark = pytest.mark.extra_artifacts( @@ -78,13 +77,13 @@ def test_rpz_multiple_views(qname, source, rcode): msg, ip="10.53.0.3", source="10.53.0.2", - expected_rcode=dns_rcode.NOERROR, + expected_rcode=dns.rcode.NOERROR, ) isctest.query.tcp( msg, ip="10.53.0.3", source="10.53.0.5", - expected_rcode=dns_rcode.NOERROR, + expected_rcode=dns.rcode.NOERROR, ) msg = isctest.query.create(qname, "A") diff --git a/bin/tests/system/rpzrecurse/tests_sh_rpzrecurse.py b/bin/tests/system/rpzrecurse/tests_sh_rpzrecurse.py index 3798ed6ee67..27f95755b8a 100644 --- a/bin/tests/system/rpzrecurse/tests_sh_rpzrecurse.py +++ b/bin/tests/system/rpzrecurse/tests_sh_rpzrecurse.py @@ -11,8 +11,6 @@ import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/selftest/tests_zone_analyzer.py b/bin/tests/system/selftest/tests_zone_analyzer.py index 63798b5d676..35e014059b8 100755 --- a/bin/tests/system/selftest/tests_zone_analyzer.py +++ b/bin/tests/system/selftest/tests_zone_analyzer.py @@ -19,6 +19,7 @@ import collections import itertools from pathlib import Path +import dns import dns.name from dns.name import Name import pytest @@ -26,7 +27,6 @@ import pytest import isctest import isctest.name -pytest.importorskip("dns", minversion="2.3.0") # set of properies present in the tested zone - read by tests_zone_analyzer.py CATEGORIES = frozenset( diff --git a/bin/tests/system/sfcache/tests_sfcache.py b/bin/tests/system/sfcache/tests_sfcache.py index bed8b36da9d..aa68805d748 100644 --- a/bin/tests/system/sfcache/tests_sfcache.py +++ b/bin/tests/system/sfcache/tests_sfcache.py @@ -11,8 +11,9 @@ import time +from dns.edns import EDECode + import isctest -from isctest.compat import EDECode def check_sfcache_ede(ns, ede): diff --git a/bin/tests/system/shutdown/tests_shutdown.py b/bin/tests/system/shutdown/tests_shutdown.py index 6f5ecd538e9..2b5b9d52209 100755 --- a/bin/tests/system/shutdown/tests_shutdown.py +++ b/bin/tests/system/shutdown/tests_shutdown.py @@ -21,7 +21,7 @@ import time import pytest -pytest.importorskip("dns", minversion="2.0.0") +import dns import dns.exception import isctest diff --git a/bin/tests/system/statistics/tests_sh_statistics.py b/bin/tests/system/statistics/tests_sh_statistics.py index e34dd437a85..d7d87abb0a6 100644 --- a/bin/tests/system/statistics/tests_sh_statistics.py +++ b/bin/tests/system/statistics/tests_sh_statistics.py @@ -11,8 +11,6 @@ import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/statschannel/tests_json.py b/bin/tests/system/statschannel/tests_json.py index 6a2dbc9f966..f7ab476e1c0 100755 --- a/bin/tests/system/statschannel/tests_json.py +++ b/bin/tests/system/statschannel/tests_json.py @@ -14,13 +14,13 @@ from datetime import datetime import pytest +import requests import isctest.mark pytest.register_assert_rewrite("generic") import generic -requests = pytest.importorskip("requests") pytestmark = [ isctest.mark.with_json_c, diff --git a/bin/tests/system/statschannel/tests_xml.py b/bin/tests/system/statschannel/tests_xml.py index 59fbcf0b06c..187f0fb97e7 100755 --- a/bin/tests/system/statschannel/tests_xml.py +++ b/bin/tests/system/statschannel/tests_xml.py @@ -15,13 +15,13 @@ from datetime import datetime import xml.etree.ElementTree as ET import pytest +import requests import isctest.mark pytest.register_assert_rewrite("generic") import generic -requests = pytest.importorskip("requests") pytestmark = [ isctest.mark.with_libxml2, diff --git a/bin/tests/system/tcp/tests_tcp.py b/bin/tests/system/tcp/tests_tcp.py index 02c7d093bee..25ee0d0e1bf 100644 --- a/bin/tests/system/tcp/tests_tcp.py +++ b/bin/tests/system/tcp/tests_tcp.py @@ -19,7 +19,7 @@ import time import pytest -pytest.importorskip("dns", minversion="2.0.0") +import dns import dns.message import dns.query diff --git a/bin/tests/system/timeouts/tests_tcp_timeouts.py b/bin/tests/system/timeouts/tests_tcp_timeouts.py index cb8defa71ef..e25bba5a042 100644 --- a/bin/tests/system/timeouts/tests_tcp_timeouts.py +++ b/bin/tests/system/timeouts/tests_tcp_timeouts.py @@ -18,7 +18,7 @@ import time import pytest -pytest.importorskip("dns", minversion="2.0.0") +import dns import dns.edns import dns.message import dns.name diff --git a/bin/tests/system/tools/tests_tools_nsec3hash.py b/bin/tests/system/tools/tests_tools_nsec3hash.py index 19571882c15..93670bc48ca 100644 --- a/bin/tests/system/tools/tests_tools_nsec3hash.py +++ b/bin/tests/system/tools/tests_tools_nsec3hash.py @@ -19,7 +19,6 @@ from isctest.hypothesis.strategies import dns_names from hypothesis import strategies, given, settings -pytest.importorskip("dns.dnssectypes") from dns.dnssectypes import NSEC3Hash import dns.dnssec diff --git a/bin/tests/system/tsig/tests_badtime.py b/bin/tests/system/tsig/tests_badtime.py index 4f5a1b9f974..4c3a62c9d85 100644 --- a/bin/tests/system/tsig/tests_badtime.py +++ b/bin/tests/system/tsig/tests_badtime.py @@ -18,9 +18,6 @@ import time import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") - import dns.message import dns.query import dns.tsigkeyring diff --git a/bin/tests/system/tsig/tests_sh_tsig.py b/bin/tests/system/tsig/tests_sh_tsig.py index 23dad0ada48..4c0a800bb59 100644 --- a/bin/tests/system/tsig/tests_sh_tsig.py +++ b/bin/tests/system/tsig/tests_sh_tsig.py @@ -21,9 +21,6 @@ pytestmark = pytest.mark.extra_artifacts( ] ) -# TSIG queries not supported by isctest.asyncserver with old dnspython -pytest.importorskip("dns", minversion="2.0.0") - def test_tsig(run_tests_sh): run_tests_sh() diff --git a/bin/tests/system/tsig/tests_tsig_hypothesis.py b/bin/tests/system/tsig/tests_tsig_hypothesis.py index 06ff5452a02..791077ac35c 100644 --- a/bin/tests/system/tsig/tests_tsig_hypothesis.py +++ b/bin/tests/system/tsig/tests_tsig_hypothesis.py @@ -15,8 +15,6 @@ import time import pytest -pytest.importorskip("dns", minversion="2.7.0") # TSIG parsing without validation - import dns.exception import dns.message import dns.name diff --git a/bin/tests/system/tsiggss/tests_isc_spnego_flaws.py b/bin/tests/system/tsiggss/tests_isc_spnego_flaws.py index 38b424d4c59..7e960ba6e1c 100755 --- a/bin/tests/system/tsiggss/tests_isc_spnego_flaws.py +++ b/bin/tests/system/tsiggss/tests_isc_spnego_flaws.py @@ -24,7 +24,7 @@ import pytest import isctest -pytest.importorskip("dns") +import dns import dns.message import dns.name import dns.rdata diff --git a/bin/tests/system/upforwd/tests_sh_upforwd.py b/bin/tests/system/upforwd/tests_sh_upforwd.py index 28be6c4c2d7..3dfa290a316 100644 --- a/bin/tests/system/upforwd/tests_sh_upforwd.py +++ b/bin/tests/system/upforwd/tests_sh_upforwd.py @@ -11,8 +11,6 @@ import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/wildcard/tests_wildcard.py b/bin/tests/system/wildcard/tests_wildcard.py index 459e3397b35..b086fc0d136 100755 --- a/bin/tests/system/wildcard/tests_wildcard.py +++ b/bin/tests/system/wildcard/tests_wildcard.py @@ -29,7 +29,7 @@ Limitations - untested properties: import pytest -pytest.importorskip("dns", minversion="2.0.0") +import dns import dns.message import dns.name import dns.query diff --git a/bin/tests/system/xfer/tests_sh_xfer.py b/bin/tests/system/xfer/tests_sh_xfer.py index 5226cfc50b2..549fb241f5a 100644 --- a/bin/tests/system/xfer/tests_sh_xfer.py +++ b/bin/tests/system/xfer/tests_sh_xfer.py @@ -11,8 +11,6 @@ import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/zero/tests_sh_zero.py b/bin/tests/system/zero/tests_sh_zero.py index 50abfe0f2d6..a80a0d6ee70 100644 --- a/bin/tests/system/zero/tests_sh_zero.py +++ b/bin/tests/system/zero/tests_sh_zero.py @@ -11,8 +11,6 @@ import pytest -# isctest.asyncserver requires dnspython >= 2.0.0 -pytest.importorskip("dns", minversion="2.0.0") pytestmark = pytest.mark.extra_artifacts( [