From 8dbb8643499c495474f28071750cbfc2da5b60f0 Mon Sep 17 00:00:00 2001 From: Samuel Cabrero Date: Tue, 8 Oct 2019 13:29:28 +0200 Subject: dns: Extend DNS tests to check the SOA record is always returned Signed-off-by: Samuel Cabrero Reviewed-by: Andreas Schneider --- python/samba/tests/dns.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/python/samba/tests/dns.py b/python/samba/tests/dns.py index 275d4fcd692..1dd1f549a33 100644 --- a/python/samba/tests/dns.py +++ b/python/samba/tests/dns.py @@ -264,6 +264,25 @@ class TestSimpleQueries(DNSTest): # But we do respond with an authority section self.assertEqual(response.nscount, 1) + def test_soa_unknown_hostname_query(self): + "create a SOA query for an unknown hostname" + p = self.make_name_packet(dns.DNS_OPCODE_QUERY) + questions = [] + + name = "foobar.%s" % (self.get_dns_domain()) + q = self.make_name_question(name, dns.DNS_QTYPE_SOA, dns.DNS_QCLASS_IN) + questions.append(q) + + self.finish_name_packet(p, questions) + (response, response_packet) =\ + self.dns_transaction_udp(p, host=server_ip) + self.assert_dns_rcode_equals(response, dns.DNS_RCODE_NXDOMAIN) + self.assert_dns_opcode_equals(response, dns.DNS_OPCODE_QUERY) + # We don't get SOA records for single hosts + self.assertEquals(response.ancount, 0) + # But we do respond with an authority section + self.assertEqual(response.nscount, 1) + def test_soa_domain_query(self): "create a SOA query for a domain" p = self.make_name_packet(dns.DNS_OPCODE_QUERY) -- cgit v1.2.1