summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2011-11-24 12:09:58 +0100
committerKai Blin <kai@samba.org>2011-11-24 12:35:08 +0100
commit1a599da550fb54fd6fb4cc2db827e7ea435ad51d (patch)
tree0de0593797e2885892f5f3a2181b8e90a71982b5
parent12123e751eb1eb87f0595b90a775094b5c810f87 (diff)
downloadsamba-1a599da550fb54fd6fb4cc2db827e7ea435ad51d.tar.gz
samba-1a599da550fb54fd6fb4cc2db827e7ea435ad51d.tar.bz2
samba-1a599da550fb54fd6fb4cc2db827e7ea435ad51d.zip
s4 dns: Move dns_transaction_udp to other helper functions
-rw-r--r--source4/scripting/python/samba/tests/dns.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/source4/scripting/python/samba/tests/dns.py b/source4/scripting/python/samba/tests/dns.py
index 25505d9463..97c7c02125 100644
--- a/source4/scripting/python/samba/tests/dns.py
+++ b/source4/scripting/python/samba/tests/dns.py
@@ -66,6 +66,20 @@ class DNSTest(TestCase):
"Helper to get dns domain"
return os.getenv('REALM', 'example.com').lower()
+ def dns_transaction_udp(self, packet, host=os.getenv('DC_SERVER_IP')):
+ "send a DNS query and read the reply"
+ s = None
+ try:
+ send_packet = ndr.ndr_pack(packet)
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
+ s.connect((host, 53))
+ s.send(send_packet, 0)
+ recv_packet = s.recv(2048, 0)
+ return ndr.ndr_unpack(dns.name_packet, recv_packet)
+ finally:
+ if s is not None:
+ s.close()
+
def test_one_a_query(self):
"create a query packet containing one query record"
p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
@@ -98,19 +112,6 @@ class DNSTest(TestCase):
response = self.dns_transaction_udp(p)
self.assert_dns_rcode_equals(response, dns.DNS_RCODE_FORMERR)
- def dns_transaction_udp(self, packet, host=os.getenv('DC_SERVER_IP')):
- "send a DNS query and read the reply"
- s = None
- try:
- send_packet = ndr.ndr_pack(packet)
- s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
- s.connect((host, 53))
- s.send(send_packet, 0)
- recv_packet = s.recv(2048, 0)
- return ndr.ndr_unpack(dns.name_packet, recv_packet)
- finally:
- if s is not None:
- s.close()
if __name__ == "__main__":
import unittest