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:
Florence Blanc-Renaud committed 2021-03-17 16:28:19 +01:00
1 parent a9b4ed4f52
commit fb107b9180
2 files changed
+25 -4

No files matched your search

@@ -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'