tests/dns: Check you cannot add empty CNAME
authorGarming Sam <garming@catalyst.net.nz>
Wed, 7 Dec 2016 03:42:38 +0000 (16:42 +1300)
committerGarming Sam <garming@samba.org>
Mon, 12 Dec 2016 07:46:25 +0000 (08:46 +0100)
This exercises the dns_check_name case in the DNS server. Directly
attempting to add an invalid name with leading . or double .. cannot be
done due to ndr_pull_component forcing the check on the client side
(leading to a CNAME name of NUL and unexpected data of the actual name).

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Pair-programmed-with: Bob Campbell <bobcampbell@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Garming Sam <garming@samba.org>
Autobuild-Date(master): Mon Dec 12 08:46:26 CET 2016 on sn-devel-144

python/samba/tests/dns.py

index 79db4de1dfde12f3ca9e81b9965777bbfe2cd240..66198b5ac42f1a4f0c1197483abf2d1b71b5331e 100644 (file)
@@ -865,6 +865,15 @@ class TestComplexQueries(DNSTest):
         self.assertEquals(response.answers[2].rdata,
                           self.server_ip)
 
+    def test_invalid_empty_cname(self):
+        name0 = "cnamedotprefix0.%s" % self.get_dns_domain()
+        try:
+            self.make_dns_update(name0, "", dns.DNS_QTYPE_CNAME)
+        except AssertionError as e:
+            pass
+        else:
+            self.fail("Successfully added empty CNAME, which is invalid.")
+
     def test_cname_two_chain_not_matching_qtype(self):
         name0 = "cnamechain0.%s" % self.get_dns_domain()
         name1 = "cnamechain1.%s" % self.get_dns_domain()