+++ /dev/null
-# 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
- )
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