mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
networkd-test: use a complete domain name in test_route_only_dns()
Since version 241 (commit ea4678?), querying MX type records for single-label domains does not actually forward the query to the DNS server any more. Use "example.com" instead, which is the recommended test domain anyway.
This commit is contained in:
parent
6592c9c850
commit
ca56805c8d
|
@ -655,52 +655,52 @@ Domains= ~company ~lab''')
|
||||||
'''resolved queries to /etc/hosts'''
|
'''resolved queries to /etc/hosts'''
|
||||||
|
|
||||||
# FIXME: -t MX query fails with enabled DNSSEC (even when using
|
# FIXME: -t MX query fails with enabled DNSSEC (even when using
|
||||||
# the known negative trust anchor .internal instead of .example)
|
# the known negative trust anchor .internal instead of .example.com)
|
||||||
conf = '/run/systemd/resolved.conf.d/test-disable-dnssec.conf'
|
conf = '/run/systemd/resolved.conf.d/test-disable-dnssec.conf'
|
||||||
os.makedirs(os.path.dirname(conf), exist_ok=True)
|
os.makedirs(os.path.dirname(conf), exist_ok=True)
|
||||||
with open(conf, 'w') as f:
|
with open(conf, 'w') as f:
|
||||||
f.write('[Resolve]\nDNSSEC=no\nLLMNR=no\nMulticastDNS=no\n')
|
f.write('[Resolve]\nDNSSEC=no\nLLMNR=no\nMulticastDNS=no\n')
|
||||||
self.addCleanup(os.remove, conf)
|
self.addCleanup(os.remove, conf)
|
||||||
|
|
||||||
# create /etc/hosts bind mount which resolves my.example for IPv4
|
# create /etc/hosts bind mount which resolves my.example.com for IPv4
|
||||||
hosts = os.path.join(self.workdir, 'hosts')
|
hosts = os.path.join(self.workdir, 'hosts')
|
||||||
with open(hosts, 'w') as f:
|
with open(hosts, 'w') as f:
|
||||||
f.write('172.16.99.99 my.example\n')
|
f.write('172.16.99.99 my.example.com\n')
|
||||||
subprocess.check_call(['mount', '--bind', hosts, '/etc/hosts'])
|
subprocess.check_call(['mount', '--bind', hosts, '/etc/hosts'])
|
||||||
self.addCleanup(subprocess.call, ['umount', '/etc/hosts'])
|
self.addCleanup(subprocess.call, ['umount', '/etc/hosts'])
|
||||||
subprocess.check_call(['systemctl', 'stop', 'systemd-resolved.service'])
|
subprocess.check_call(['systemctl', 'stop', 'systemd-resolved.service'])
|
||||||
|
|
||||||
# note: different IPv4 address here, so that it's easy to tell apart
|
# note: different IPv4 address here, so that it's easy to tell apart
|
||||||
# what resolved the query
|
# what resolved the query
|
||||||
self.create_iface(dnsmasq_opts=['--host-record=my.example,172.16.99.1,2600::99:99',
|
self.create_iface(dnsmasq_opts=['--host-record=my.example.com,172.16.99.1,2600::99:99',
|
||||||
'--host-record=other.example,172.16.0.42,2600::42',
|
'--host-record=other.example.com,172.16.0.42,2600::42',
|
||||||
'--mx-host=example,mail.example'],
|
'--mx-host=example.com,mail.example.com'],
|
||||||
ipv6=True)
|
ipv6=True)
|
||||||
self.do_test(coldplug=None, ipv6=True)
|
self.do_test(coldplug=None, ipv6=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# family specific queries
|
# family specific queries
|
||||||
out = subprocess.check_output(['resolvectl', 'query', '-4', 'my.example'])
|
out = subprocess.check_output(['resolvectl', 'query', '-4', 'my.example.com'])
|
||||||
self.assertIn(b'my.example: 172.16.99.99', out)
|
self.assertIn(b'my.example.com: 172.16.99.99', out)
|
||||||
# we don't expect an IPv6 answer; if /etc/hosts has any IP address,
|
# we don't expect an IPv6 answer; if /etc/hosts has any IP address,
|
||||||
# it's considered a sufficient source
|
# it's considered a sufficient source
|
||||||
self.assertNotEqual(subprocess.call(['resolvectl', 'query', '-6', 'my.example']), 0)
|
self.assertNotEqual(subprocess.call(['resolvectl', 'query', '-6', 'my.example.com']), 0)
|
||||||
# "any family" query; IPv4 should come from /etc/hosts
|
# "any family" query; IPv4 should come from /etc/hosts
|
||||||
out = subprocess.check_output(['resolvectl', 'query', 'my.example'])
|
out = subprocess.check_output(['resolvectl', 'query', 'my.example.com'])
|
||||||
self.assertIn(b'my.example: 172.16.99.99', out)
|
self.assertIn(b'my.example.com: 172.16.99.99', out)
|
||||||
# IP → name lookup; again, takes the /etc/hosts one
|
# IP → name lookup; again, takes the /etc/hosts one
|
||||||
out = subprocess.check_output(['resolvectl', 'query', '172.16.99.99'])
|
out = subprocess.check_output(['resolvectl', 'query', '172.16.99.99'])
|
||||||
self.assertIn(b'172.16.99.99: my.example', out)
|
self.assertIn(b'172.16.99.99: my.example.com', out)
|
||||||
|
|
||||||
# non-address RRs should fall back to DNS
|
# non-address RRs should fall back to DNS
|
||||||
out = subprocess.check_output(['resolvectl', 'query', '--type=MX', 'example'])
|
out = subprocess.check_output(['resolvectl', 'query', '--type=MX', 'example.com'])
|
||||||
self.assertIn(b'example IN MX 1 mail.example', out)
|
self.assertIn(b'example.com IN MX 1 mail.example.com', out)
|
||||||
|
|
||||||
# other domains query DNS
|
# other domains query DNS
|
||||||
out = subprocess.check_output(['resolvectl', 'query', 'other.example'])
|
out = subprocess.check_output(['resolvectl', 'query', 'other.example.com'])
|
||||||
self.assertIn(b'172.16.0.42', out)
|
self.assertIn(b'172.16.0.42', out)
|
||||||
out = subprocess.check_output(['resolvectl', 'query', '172.16.0.42'])
|
out = subprocess.check_output(['resolvectl', 'query', '172.16.0.42'])
|
||||||
self.assertIn(b'172.16.0.42: other.example', out)
|
self.assertIn(b'172.16.0.42: other.example.com', out)
|
||||||
except (AssertionError, subprocess.CalledProcessError):
|
except (AssertionError, subprocess.CalledProcessError):
|
||||||
self.show_journal('systemd-resolved.service')
|
self.show_journal('systemd-resolved.service')
|
||||||
self.print_server_log()
|
self.print_server_log()
|
||||||
|
|
Loading…
Reference in a new issue