]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Refactor and move query helper to isctest.query.create
authorNicki Křížek <nicki@isc.org>
Fri, 25 Jul 2025 08:30:54 +0000 (10:30 +0200)
committerEvan Hunt <each@isc.org>
Tue, 29 Jul 2025 19:12:44 +0000 (12:12 -0700)
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
bin/tests/system/isctest/dnssec.py [deleted file]
bin/tests/system/isctest/query.py

index caef57f5ae825d4c633c2db2ca660016c6b73fe9..fb04a2a1e85841136663e122a352cd9ed4993238 100644 (file)
@@ -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 (file)
index 2096711..0000000
+++ /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
-    )
index 6e7bee285eea386f6d8137fc5e1bfeb951643d57..e18b2001de115457de1f51aab6f53a25b27d8568 100644 (file)
@@ -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