mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-10 17:27:33 -04: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.
(cherry picked from commit 989e64b9b0)
This commit is contained in:
parent
c92a6b85fe
commit
01ec550099
3 changed files with 20 additions and 26 deletions
|
|
@ -10,7 +10,6 @@
|
|||
# information regarding copyright ownership.
|
||||
|
||||
from . import check
|
||||
from . import dnssec
|
||||
from . import instance
|
||||
from . import query
|
||||
from . import name
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
|
|
@ -74,3 +74,23 @@ def udp(*args, **kwargs) -> Any:
|
|||
|
||||
def tcp(*args, **kwargs) -> Any:
|
||||
return generic_query(dns.query.tcp, *args, **kwargs)
|
||||
|
||||
|
||||
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…
Reference in a new issue