]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dns: Extend DNS tests to check the SOA record is always returned
authorSamuel Cabrero <scabrero@samba.org>
Tue, 8 Oct 2019 11:29:28 +0000 (13:29 +0200)
committerSamuel Cabrero <scabrero@sn-devel-184>
Fri, 8 Nov 2019 11:01:29 +0000 (11:01 +0000)
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
python/samba/tests/dns.py

index 275d4fcd692142ae409d2d2de65faba2adb51e94..1dd1f549a33b20eb0b8c66ee2e7738b44730196a 100644 (file)
@@ -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)