mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipatests: fix TestInstalDNSSECFirst::test_resolvconf logic
The test test_dnssec.py::TestInstallDNSSECFirst::test_resolvconf checks that /etc/resolv.conf points to the localhost and fails on fedora33 because systemd-resolved is in place (and /etc/resolv.conf contains 127.0.0.53). The test logic needs to be adapted. When systemd-resolved is used, the test can check the output of "resolvectl dns". Fixes: https://pagure.io/freeipa/issue/8695 Signed-off-by: Florence Blanc-Renaud <flo@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Sergey Orlov <sorlov@redhat.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import abc
|
||||
import logging
|
||||
import re
|
||||
import textwrap
|
||||
import time
|
||||
|
||||
@@ -131,6 +132,16 @@ class Resolver(abc.ABC):
|
||||
:param state: internal state object specific to subclass implementaion
|
||||
"""
|
||||
|
||||
def uses_localhost_as_dns(self):
|
||||
"""Return true if the localhost is set as DNS server.
|
||||
|
||||
Default implementation checks the content of /etc/resolv.conf
|
||||
"""
|
||||
resolvconf = self.host.get_file_contents(paths.RESOLV_CONF, 'utf-8')
|
||||
patterns = [r"^\s*nameserver\s+127\.0\.0\.1\s*$",
|
||||
r"^\s*nameserver\s+::1\s*$"]
|
||||
return any(re.search(p, resolvconf, re.MULTILINE) for p in patterns)
|
||||
|
||||
|
||||
class ResolvedResolver(Resolver):
|
||||
RESOLVED_RESOLV_CONF = {
|
||||
@@ -192,6 +203,17 @@ class ResolvedResolver(Resolver):
|
||||
self.RESOLVED_CONF_FILE, state['resolved_config'])
|
||||
self._restart_resolved()
|
||||
|
||||
def uses_localhost_as_dns(self):
|
||||
"""Return true if the localhost is set as DNS server.
|
||||
|
||||
When systemd-resolved is in use, the DNS can be found using
|
||||
the command resolvectldns.
|
||||
"""
|
||||
dnsconf = self.host.run_command(['resolvectl', 'dns']).stdout_text
|
||||
patterns = [r"^Global:.*\s+127.0.0.1\s+.*$",
|
||||
r"^Global:.*\s+::1\s+.*$"]
|
||||
return any(re.search(p, dnsconf, re.MULTILINE) for p in patterns)
|
||||
|
||||
|
||||
class PlainFileResolver(Resolver):
|
||||
IPATESTS_RESOLVER_COMMENT = '# created by ipatests'
|
||||
|
@@ -462,11 +462,10 @@ class TestInstallDNSSECFirst(IntegrationTest):
|
||||
self.master.run_command(args)
|
||||
self.replicas[0].run_command(args)
|
||||
|
||||
def test_resolvconf(self):
|
||||
# check that resolv.conf contains IP address for localhost
|
||||
def test_servers_use_localhost_as_dns(self):
|
||||
# check that localhost is set as DNS server
|
||||
for host in [self.master, self.replicas[0]]:
|
||||
resolvconf = host.get_file_contents(paths.RESOLV_CONF, 'utf-8')
|
||||
assert any(ip in resolvconf for ip in ('127.0.0.1', '::1'))
|
||||
assert host.resolver.uses_localhost_as_dns()
|
||||
|
||||
|
||||
class TestMigrateDNSSECMaster(IntegrationTest):
|
||||
|
Reference in New Issue
Block a user