summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2012-12-10 05:50:05 +1000
committerAmitay Isaacs <amitay@gmail.com>2013-05-16 21:40:35 +1000
commit4364a3faf64fc9a022bc8870e2817573b94a4d0c (patch)
tree1e62254b01a6df7f826e3750dcfb5dbf029d8789 /python
parent2e9cf99bcef81d5e0b25221956a79e5f2fee1bf0 (diff)
downloadsamba-4364a3faf64fc9a022bc8870e2817573b94a4d0c.tar.gz
samba-4364a3faf64fc9a022bc8870e2817573b94a4d0c.tar.bz2
samba-4364a3faf64fc9a022bc8870e2817573b94a4d0c.zip
dns: Add support for MX queries
Due to an oversight, the internal DNS server supports MX record updates, but not MX record queries. Add support for MX queries and tests. This should fix bug #9485 Signed-off-by: Kai Blin <kai@samba.org> Reviewed-By: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/dns.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/python/samba/tests/dns.py b/python/samba/tests/dns.py
index 49d699edb7..a29025d324 100644
--- a/python/samba/tests/dns.py
+++ b/python/samba/tests/dns.py
@@ -510,6 +510,49 @@ class TestDNSUpdates(DNSTest):
response = self.dns_transaction_udp(p)
self.assert_dns_rcode_equals(response, dns.DNS_RCODE_NXDOMAIN)
+ def test_update_add_mx_record(self):
+ "test adding MX records works"
+ p = self.make_name_packet(dns.DNS_OPCODE_UPDATE)
+ updates = []
+
+ name = self.get_dns_domain()
+
+ u = self.make_name_question(name, dns.DNS_QTYPE_SOA, dns.DNS_QCLASS_IN)
+ updates.append(u)
+ self.finish_name_packet(p, updates)
+
+ updates = []
+ r = dns.res_rec()
+ r.name = "%s" % self.get_dns_domain()
+ r.rr_type = dns.DNS_QTYPE_MX
+ r.rr_class = dns.DNS_QCLASS_IN
+ r.ttl = 900
+ r.length = 0xffff
+ rdata = dns.mx_record()
+ rdata.preference = 10
+ rdata.exchange = 'mail.%s' % self.get_dns_domain()
+ r.rdata = rdata
+ updates.append(r)
+ p.nscount = len(updates)
+ p.nsrecs = updates
+
+ response = self.dns_transaction_udp(p)
+ self.assert_dns_rcode_equals(response, dns.DNS_RCODE_OK)
+
+ p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
+ questions = []
+
+ name = "%s" % self.get_dns_domain()
+ q = self.make_name_question(name, dns.DNS_QTYPE_MX, dns.DNS_QCLASS_IN)
+ 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.assertEqual(response.ancount, 1)
+ self.assertEqual(response.answers[0].rdata.preference, 10)
+ self.assertEqual(response.answers[0].rdata.exchange, 'mail.%s' % self.get_dns_domain())
+
class TestComplexQueries(DNSTest):