mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
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.
This commit is contained in:
parent
efd60348b9
commit
989e64b9b0
@ -10,7 +10,6 @@
|
||||
# information regarding copyright ownership.
|
||||
|
||||
from . import check
|
||||
from . import dnssec
|
||||
from . import instance
|
||||
from . import query
|
||||
from . import kasp
|
||||
|
@ -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
|
||||
)
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user