s4:dns.py: reproducer for (bug #9184)
authorStefan Metzmacher <metze@samba.org>
Fri, 21 Sep 2012 21:06:13 +0000 (23:06 +0200)
committerStefan Metzmacher <metze@samba.org>
Sat, 22 Sep 2012 04:08:04 +0000 (06:08 +0200)
metze

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Sat Sep 22 06:08:05 CEST 2012 on sn-devel-104

source4/scripting/python/samba/tests/dns.py

index 3eee306d43445b2ca45ac365c2e37cb357aebe4e..327e166314a56b43afc3a6a783a12f3fd5749f87 100644 (file)
@@ -547,6 +547,35 @@ class TestComplexQueries(DNSTest):
         self.assertEquals(response.answers[1].rdata,
                           os.getenv('SERVER_IP'))
 
+class TestInvalidQueries(DNSTest):
+
+    def test_one_a_query(self):
+        "send 0 bytes follows by create a query packet containing one query record"
+
+        s = None
+        try:
+            s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
+            s.connect((os.getenv('SERVER_IP'), 53))
+            s.send("", 0)
+        finally:
+            if s is not None:
+                s.close()
+
+        p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
+        questions = []
+
+        name = "%s.%s" % (os.getenv('SERVER'), self.get_dns_domain())
+        q = self.make_name_question(name, dns.DNS_QTYPE_A, dns.DNS_QCLASS_IN)
+        print "asking for ", q.name
+        questions.append(q)
+
+        self.finish_name_packet(p, questions)
+        response = self.dns_transaction_udp(p)
+        self.assert_dns_rcode_equals(response, dns.DNS_RCODE_OK)
+        self.assert_dns_opcode_equals(response, dns.DNS_OPCODE_QUERY)
+        self.assertEquals(response.ancount, 1)
+        self.assertEquals(response.answers[0].rdata,
+                          os.getenv('SERVER_IP'))
 
 if __name__ == "__main__":
     import unittest