Commit d843ac16 authored by Daniel Salzman's avatar Daniel Salzman

tests-extra: add Test.hostname property

parent 41120c00
......@@ -3,7 +3,6 @@
'''Test for server identification over CH/TXT'''
from dnstest.test import Test
import socket
t = Test()
......@@ -25,12 +24,7 @@ resp.check('"' + name + '"')
# 2) FQDN hostname.
resp = server2.dig("id.server", "TXT", "CH")
try:
addrinfo = socket.getaddrinfo(socket.gethostname(), 0, socket.AF_UNSPEC,
socket.SOCK_DGRAM, 0, socket.AI_CANONNAME)
resp.check(addrinfo[0][3])
except:
resp.check(socket.gethostname())
resp.check(t.hostname)
# 3) Explicitly disabled.
resp = server3.dig("id.server", "TXT", "CH")
......
......@@ -3,7 +3,6 @@
'''Test for EDNS0/NSID identification'''
from dnstest.test import Test
import socket
t = Test()
......@@ -30,12 +29,7 @@ resp.check_edns(nsid=name)
# 2) FQDN hostname.
resp = server2.dig("example.com", "SOA", nsid=True)
try:
addrinfo = socket.getaddrinfo(socket.gethostname(), 0, socket.AF_UNSPEC,
socket.SOCK_DGRAM, 0, socket.AI_CANONNAME)
resp.check_edns(nsid=addrinfo[0][3])
except:
resp.check_edns(nsid=socket.gethostname())
resp.check_edns(nsid=t.hostname)
# 3) Explicitly disabled.
resp = server3.dig("example.com", "SOA", nsid=True)
......
......@@ -88,6 +88,13 @@ class Test(object):
Test.last_port = port
return port
@property
def hostname(self):
hostname = socket.gethostname()
addrinfo = socket.getaddrinfo(hostname, 0, socket.AF_UNSPEC,
socket.SOCK_DGRAM, 0, socket.AI_CANONNAME)
return addrinfo[0][3] if addrinfo else hostname
def server(self, server, nsid=None, ident=None, version=None, \
valgrind=None):
if server == "knot":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment