def do_query(server, qname, qtype, tcp=False):
- msg = dns.message.make_query(qname, qtype, use_edns=True, want_dnssec=True)
+ msg = isctest.query.create(qname, qtype)
query_func = isctest.query.tcp if tcp else isctest.query.udp
response = query_func(msg, server.ip, expected_rcode=dns.rcode.NOERROR)
return response
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-import isctest
+import dns
-import dns.message
+import isctest
def test_database(servers, templates):
- msg = dns.message.make_query("database.", "SOA")
+ msg = isctest.query.create("database.", "SOA")
# checking pre reload zone
res = isctest.query.tcp(msg, "10.53.0.1")
import isctest
import pytest
-import dns.message
-
pytest.importorskip("dns", minversion="2.0.0")
+import dns.rrset
pytestmark = pytest.mark.extra_artifacts(
[
def test_dnstap_dispatch_socket_addresses():
# Send some query to ns3 so that it records something in its dnstap file.
- msg = dns.message.make_query("mail.example.", "A")
+ msg = isctest.query.create("mail.example.", "A")
res = isctest.query.tcp(msg, "10.53.0.2", expected_rcode=dns.rcode.NOERROR)
assert res.answer == [
dns.rrset.from_text("mail.example.", 300, "IN", "A", "10.0.0.2")
pytest.importorskip("dns")
import dns.exception
-import dns.message
import dns.name
import dns.rdataclass
import dns.rdatatype
+import isctest
+
pytestmark = pytest.mark.extra_artifacts(
[
"gnutls-cli.*",
def test_gnutls_cli_query(gnutls_cli_executable, named_tlsport):
# Prepare the example/SOA query which will be sent over TLS.
- query = dns.message.make_query("example.", dns.rdatatype.SOA)
+ query = isctest.query.create("example.", dns.rdatatype.SOA)
query_wire = query.to_wire()
query_with_length = struct.pack(">H", len(query_wire)) + query_wire
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-import dns.message
+import dns.flags
import pytest
import isctest
def test_dsdigest_good():
"""Check that validation with enabled digest types works"""
- msg = dns.message.make_query("a.good.", "A", want_dnssec=True)
+ msg = isctest.query.create("a.good.", "A")
res = isctest.query.tcp(
msg,
"10.53.0.3",
def test_dsdigest_insecure():
"""Check that validation with not supported digest algorithms is insecure"""
- msg_ds = dns.message.make_query("bad.", "DS", want_dnssec=True)
+ msg_ds = isctest.query.create("bad.", "DS")
res_ds = isctest.query.tcp(
msg_ds,
"10.53.0.4",
isctest.check.noerror(res_ds)
assert res_ds.flags & dns.flags.AD
- msg_a = dns.message.make_query("a.bad.", "A", want_dnssec=True)
+ msg_a = isctest.query.create("a.bad.", "A")
res_a = isctest.query.tcp(
msg_a,
"10.53.0.4",
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-import dns.message
-
import isctest
ns1.rndc("reload")
templates.render("ns1/named.conf", {"automatic_empty_zones": True})
ns1.rndc("reload")
- msg = dns.message.make_query("version.bind", "TXT", "CH")
+ msg = isctest.query.create("version.bind", "TXT", "CH")
res = isctest.query.tcp(msg, "10.53.0.1")
isctest.check.noerror(res)
# check that allow-transfer { none; } works
- msg = dns.message.make_query("10.in-addr.arpa", "AXFR")
+ msg = isctest.query.create("10.in-addr.arpa", "AXFR")
res = isctest.query.tcp(msg, "10.53.0.1")
isctest.check.refused(res)
# information regarding copyright ownership.
+import dns.flags
import dns.message
import pytest
def test_glue_full_glue_set():
"""test that a ccTLD referral gets a full glue set from the root zone"""
- msg = dns.message.make_query("foo.bar.fi", "A")
+ msg = isctest.query.create("foo.bar.fi", "A")
msg.flags &= ~dns.flags.RD
res = isctest.query.udp(msg, "10.53.0.1")
def test_glue_no_glue_set():
"""test that out-of-zone glue is not found"""
- msg = dns.message.make_query("example.net.", "A")
+ msg = isctest.query.create("example.net.", "A")
msg.flags &= ~dns.flags.RD
res = isctest.query.udp(msg, "10.53.0.1")
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-import pytest
import isctest
-pytest.importorskip("dns")
-import dns.message
-
def test_async_hook():
- msg = dns.message.make_query("example.com.", "A")
+ msg = isctest.query.create("example.com.", "A")
res = isctest.query.udp(msg, "10.53.0.1")
# the test-async plugin changes the status of any positive answer to NOTIMP
isctest.check.notimp(res)
import os
-import isctest
+import dns.rrset
import pytest
-import dns.message
+import isctest
@pytest.mark.parametrize(
],
)
def test_include_multiplecfg(qname):
- msg = dns.message.make_query(qname, "A")
+ msg = isctest.query.create(qname, "A")
res = isctest.query.tcp(msg, "10.53.0.2")
isctest.check.noerror(res)
from typing import Optional
import dns.flags
-import dns.rcode
import dns.message
+import dns.rcode
import dns.zone
import isctest.log
assert executable is not None, errmsg
+def named_alive(named_proc, resolver_ip):
+ assert named_proc.poll() is None, "named isn't running"
+ msg = isctest.query.create("version.bind", "TXT", "CH")
+ isctest.query.tcp(msg, resolver_ip, expected_rcode=dns_rcode.NOERROR)
+
+
+def notauth(message: dns.message.Message) -> None:
+ rcode(message, dns.rcode.NOTAUTH)
+
+
def nxdomain(message: dns.message.Message) -> None:
rcode(message, dns.rcode.NXDOMAIN)
import isctest
import pytest
-import dns.message
-
# Everything from getting a big answer to creating an RR set with thousands
# of records takes minutes of CPU and real time with dnspython < 2.0.0.
pytest.importorskip("dns", minversion="2.0.0")
+import dns.rrset
@pytest.mark.parametrize(
],
)
def test_limits(name, limit):
- msg_query = dns.message.make_query(f"{name}.example.", "A")
+ msg_query = isctest.query.create(f"{name}.example.", "A")
res = isctest.query.tcp(msg_query, "10.53.0.1", log_response=False)
iplist = [
def test_limit_exceeded():
- msg_query = dns.message.make_query("5000.example.", "A")
+ msg_query = isctest.query.create("5000.example.", "A")
res = isctest.query.tcp(msg_query, "10.53.0.1", log_response=False)
assert res.flags & dns.flags.TC, "TC flag was not set"
def test_masterfile_include_semantics():
"""Test master file $INCLUDE semantics"""
- msg_axfr = dns.message.make_query("include.", "AXFR")
+ msg_axfr = isctest.query.create("include.", "AXFR")
res_axfr = isctest.query.tcp(msg_axfr, "10.53.0.1")
axfr_include_semantics = """;ANSWER
include. 300 IN SOA ns.include. hostmaster.include. 1 3600 1800 1814400 3600
def test_masterfile_bind_8_compat_semantics():
"""Test master file BIND 8 TTL and $TTL semantics compatibility"""
- msg_axfr = dns.message.make_query("ttl1.", "AXFR")
+ msg_axfr = isctest.query.create("ttl1.", "AXFR")
res_axfr = isctest.query.tcp(msg_axfr, "10.53.0.1")
axfr_ttl_semantics = """;ANSWER
ttl1. 3 IN SOA ns.ttl1. hostmaster.ttl1. 1 3600 1800 1814400 3
def test_masterfile_rfc_1035_semantics():
"""Test master file RFC1035 TTL and $TTL semantics"""
- msg_axfr = dns.message.make_query("ttl2.", "AXFR")
+ msg_axfr = isctest.query.create("ttl2.", "AXFR")
res_axfr = isctest.query.tcp(msg_axfr, "10.53.0.1")
axfr_ttl_semantics = """;ANSWER
ttl2. 1 IN SOA ns.ttl2. hostmaster.ttl2. 1 3600 1800 1814400 3
def test_masterfile_missing_master_file():
"""Test nameserver running with a missing master file"""
- msg_soa = dns.message.make_query("example.", "SOA")
+ msg_soa = isctest.query.create("example.", "SOA")
res_soa = isctest.query.tcp(msg_soa, "10.53.0.2")
expected_soa_rr = """;ANSWER
example. 300 IN SOA mname1. . 2010042407 20 20 1814400 3600
def test_masterfile_missing_master_file_servfail():
"""Test nameserver returning SERVFAIL for a missing master file"""
- msg_soa = dns.message.make_query("missing.", "SOA")
+ msg_soa = isctest.query.create("missing.", "SOA")
res_soa = isctest.query.tcp(msg_soa, "10.53.0.2")
isctest.check.servfail(res_soa)
pytest.importorskip("dns", minversion="2.7.0")
-
-import dns.message
import isctest
# about twice as large as the answer with compression enabled, while
# maintaining identical content.
def test_names():
- msg = dns.message.make_query("example.", "MX")
+ msg = isctest.query.create("example.", "MX")
# Getting message size with compression enabled
res_enabled = isctest.query.tcp(msg, ip="10.53.0.1", source="10.53.0.1")
# Getting message size with compression disabled
import time
import pytest
+
import isctest
-pytest.importorskip("dns")
-import dns.message
pytestmark = pytest.mark.extra_artifacts(
[
# Wait for named to (possibly) crash
time.sleep(10)
- msg = dns.message.make_query("version.bind", "TXT", "CH")
+ msg = isctest.query.create("version.bind", "TXT", "CH")
res = isctest.query.udp(msg, "10.53.0.2")
isctest.check.noerror(res)
# information regarding copyright ownership.
import os
+
import pytest
pytest.importorskip("dns", minversion="2.0.0")
+import dns.rcode
+import dns.rrset
+
import isctest
from isctest.compat import dns_rcode
-import dns.message
pytestmark = pytest.mark.extra_artifacts(
[
)
def test_rpz_multiple_views(qname, source, rcode):
# Wait for the rpz-external.local zone transfer
- msg = dns.message.make_query("rpz-external.local", "SOA")
+ msg = isctest.query.create("rpz-external.local", "SOA")
isctest.query.tcp(
msg,
ip="10.53.0.3",
expected_rcode=dns_rcode.NOERROR,
)
- msg = dns.message.make_query(qname, "A")
+ msg = isctest.query.create(qname, "A")
res = isctest.query.udp(msg, "10.53.0.3", source=source, expected_rcode=rcode)
if rcode == dns.rcode.NOERROR:
assert res.answer == [dns.rrset.from_text(qname, 300, "IN", "A", "10.53.0.2")]
resolver_ip = "10.53.0.3"
# Should generate a log entry into rpz_passthru.txt
- msg_allowed = dns.message.make_query("allowed.", "A")
+ msg_allowed = isctest.query.create("allowed.", "A")
res_allowed = isctest.query.udp(
msg_allowed, resolver_ip, source="10.53.0.1", expected_rcode=dns.rcode.NOERROR
)
# baddomain.com isn't allowed (CNAME .), should return NXDOMAIN
# Should generate a log entry into rpz.txt
- msg_not_allowed = dns.message.make_query("baddomain.", "A")
+ msg_not_allowed = isctest.query.create("baddomain.", "A")
res_not_allowed = isctest.query.udp(
msg_not_allowed,
resolver_ip,
)
qname = relname + ".test"
- msg = dns.message.make_query(qname, "A")
+ msg = isctest.query.create(qname, "A")
futures[
executor.submit(
isctest.query.udp, msg, resolver_ip, timeout=1, attempts=1
rrset = dns.rrset.from_rdata(dns.name.root, dns.rdatatype.TKEY, rdata)
# Prepare complete TKEY query to send
- self.msg = dns.message.make_query(
+ self.msg = isctest.query.create(
dns.name.root, dns.rdatatype.TKEY, dns.rdataclass.ANY
)
self.msg.additional.append(rrset)
import isctest
-pytest.importorskip("dns")
-import dns.message
-
@pytest.mark.parametrize(
"qname,rdtype,expected_ttl",
],
)
def test_cache_ttl(qname, rdtype, expected_ttl):
- msg = dns.message.make_query(qname, rdtype)
+ msg = isctest.query.create(qname, rdtype)
response = isctest.query.udp(msg, "10.53.0.2")
for rr in response.answer + response.authority:
assert rr.ttl == expected_ttl
# See RFC 4592 section 2.2.1.
assume(name == SUFFIX or name.labels[-len(SUFFIX) - 1] != b"*")
- query_msg = dns.message.make_query(name, rdtype)
+ query_msg = isctest.query.create(name, rdtype)
response_msg = isctest.query.tcp(query_msg, IP_ADDR, named_port, timeout=TIMEOUT)
isctest.check.is_response_to(response_msg, query_msg)
# See RFC 4592 section 2.2.1.
assume(name.labels[-len(SUFFIX) - 1] != b"*")
- query_msg = dns.message.make_query(name, WILDCARD_RDTYPE)
+ query_msg = isctest.query.create(name, WILDCARD_RDTYPE)
response_msg = isctest.query.tcp(query_msg, IP_ADDR, named_port, timeout=TIMEOUT)
isctest.check.is_response_to(response_msg, query_msg)
name: dns.name.Name, named_port: int
) -> None:
"""RFC 4592 section 2.2.1 ghost.*.example."""
- query_msg = dns.message.make_query(name, WILDCARD_RDTYPE)
+ query_msg = isctest.query.create(name, WILDCARD_RDTYPE)
response_msg = isctest.query.tcp(query_msg, IP_ADDR, named_port, timeout=TIMEOUT)
isctest.check.is_response_to(response_msg, query_msg)
or name.labels[-len(NESTED_SUFFIX) - 1] != b"*"
)
- query_msg = dns.message.make_query(name, WILDCARD_RDTYPE)
+ query_msg = isctest.query.create(name, WILDCARD_RDTYPE)
response_msg = isctest.query.tcp(query_msg, IP_ADDR, named_port, timeout=TIMEOUT)
isctest.check.is_response_to(response_msg, query_msg)
`foo.*.*.*.nestedwild.test. A` must not be synthesized.
"""
- query_msg = dns.message.make_query(name, WILDCARD_RDTYPE)
+ query_msg = isctest.query.create(name, WILDCARD_RDTYPE)
response_msg = isctest.query.tcp(query_msg, IP_ADDR, named_port, timeout=TIMEOUT)
isctest.check.is_response_to(response_msg, query_msg)
isctest.run.retry_with_timeout(check_line_count, timeout=360)
- axfr_msg = dns.message.make_query("zone000099.example.", "AXFR")
- a_msg = dns.message.make_query("a.changing.", "A")
+ axfr_msg = isctest.query.create("zone000099.example.", "AXFR")
+ a_msg = isctest.query.create("a.changing.", "A")
def query_and_compare(msg):
ns1response = isctest.query.tcp(msg, "10.53.0.1")