From 989e64b9b0e2a65b8b4b0f2bc75b1f2e2a327272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicki=20K=C5=99=C3=AD=C5=BEek?= Date: Fri, 25 Jul 2025 10:30:54 +0200 Subject: [PATCH] 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. --- bin/tests/system/isctest/__init__.py | 1 - bin/tests/system/isctest/dnssec.py | 25 ------------------------- bin/tests/system/isctest/query.py | 20 ++++++++++++++++++++ 3 files changed, 20 insertions(+), 26 deletions(-) delete mode 100644 bin/tests/system/isctest/dnssec.py diff --git a/bin/tests/system/isctest/__init__.py b/bin/tests/system/isctest/__init__.py index caef57f5ae..fb04a2a1e8 100644 --- a/bin/tests/system/isctest/__init__.py +++ b/bin/tests/system/isctest/__init__.py @@ -10,7 +10,6 @@ # information regarding copyright ownership. from . import check -from . import dnssec from . import instance from . import query from . import kasp diff --git a/bin/tests/system/isctest/dnssec.py b/bin/tests/system/isctest/dnssec.py deleted file mode 100644 index 209671150a..0000000000 --- a/bin/tests/system/isctest/dnssec.py +++ /dev/null @@ -1,25 +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 dns import flags, message - - -def msg(qname: str, qtype: str, **kwargs): - headerflags = flags.RD - # "ad" is on by default - if "ad" not in kwargs or not kwargs["ad"]: - headerflags |= flags.AD - # "cd" is off by default - if "cd" in kwargs and kwargs["cd"]: - headerflags |= flags.CD - return message.make_query( - qname, qtype, use_edns=True, want_dnssec=True, flags=headerflags - ) diff --git a/bin/tests/system/isctest/query.py b/bin/tests/system/isctest/query.py index 6e7bee285e..e18b2001de 100644 --- a/bin/tests/system/isctest/query.py +++ b/bin/tests/system/isctest/query.py @@ -99,3 +99,23 @@ def tls(*args, **kwargs) -> Any: raise RuntimeError( "dnspython 2.5.0 or newer is required for isctest.query.tls()" ) from e + + +def create( + qname, + qtype, + qclass=dns.rdataclass.IN, + dnssec: bool = True, + cd: bool = False, + ad: bool = True, +) -> dns.message.Message: + """Create DNS query with defaults suitable for our tests.""" + msg = dns.message.make_query( + qname, qtype, qclass, use_edns=True, want_dnssec=dnssec + ) + msg.flags = dns.flags.RD + if ad: + msg.flags |= dns.flags.AD + if cd: + msg.flags |= dns.flags.CD + return msg