ipatests: do not manually modify /etc/resolv.conf in tests

Related to https://pagure.io/freeipa/issue/8703

Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Sergey Orlov
2021-02-15 18:54:18 +01:00
parent cd066ba887
commit 01f455f424
6 changed files with 6 additions and 69 deletions

View File

@@ -133,13 +133,7 @@ class TestACME(CALessBase):
tasks.install_master(cls.master, setup_dns=True)
tasks.install_client(cls.master, cls.clients[0])
tasks.config_host_resolvconf_with_master_data(
cls.master, cls.clients[0]
)
tasks.install_replica(cls.master, cls.replicas[0])
tasks.config_host_resolvconf_with_master_data(
cls.master, cls.replicas[0]
)
def certinstall(self, certfile=None, keyfile=None,
pin=None):
@@ -435,9 +429,6 @@ class TestACMECALess(IntegrationTest):
tasks.install_master(self.master, setup_dns=True)
tasks.install_replica(self.master, self.replicas[0], setup_ca=False)
tasks.config_host_resolvconf_with_master_data(
self.master, self.replicas[0]
)
yield
@@ -550,10 +541,4 @@ class TestACMEwithExternalCA(TestACME):
tasks.kinit_admin(cls.master)
tasks.install_client(cls.master, cls.clients[0])
tasks.config_host_resolvconf_with_master_data(
cls.master, cls.clients[0]
)
tasks.install_replica(cls.master, cls.replicas[0])
tasks.config_host_resolvconf_with_master_data(
cls.master, cls.replicas[0]
)

View File

@@ -522,15 +522,6 @@ class TestBackupAndRestoreWithReplica(IntegrationTest):
domain_level = cls.master.config.domain_level
else:
domain_level = cls.domain_level
# Configure /etc/resolv.conf on each replica to use the master as DNS
# Otherwise ipa-replica-manage re-initialize is unable to
# resolve the master name
tasks.config_host_resolvconf_with_master_data(
cls.master, cls.replica1
)
tasks.config_host_resolvconf_with_master_data(
cls.master, cls.replica2
)
# Configure only master and one replica.
# Replica is configured without CA
tasks.install_topo(

View File

@@ -60,15 +60,11 @@ def get_certmonger_request_value(host, requestid, state):
class TestInstallMasterClient(IntegrationTest):
num_clients = 1
topology = 'line'
@classmethod
def install(cls, mh):
tasks.install_master(cls.master, setup_dns=True)
# use master's DNS so nsupdate adds correct IP address for client
tasks.config_host_resolvconf_with_master_data(
cls.master, cls.clients[0]
)
tasks.install_client(cls.master, cls.clients[0])
super().install(mh)
# time to look into journal logs in
# test_certmonger_ipa_responder_jsonrpc

View File

@@ -59,6 +59,8 @@ class TestForcedClientReenrollment(IntegrationTest):
)
tasks.install_replica(cls.master, cls.replicas[0], setup_ca=False)
cls.clients[0].resolver.backup()
cls.clients[0].resolver.setup_resolver(cls.master.ip)
cls.BACKUP_KEYTAB = os.path.join(
cls.master.config.test_dir,
'krb5.keytab'
@@ -209,8 +211,6 @@ class TestForcedClientReenrollment(IntegrationTest):
server = self.replicas[0] if to_replica else self.master
client = self.clients[0]
self.fix_resolv_conf(client, server)
args = [
'ipa-client-install', '-U',
'--server', server.hostname,
@@ -302,25 +302,9 @@ class TestForcedClientReenrollment(IntegrationTest):
contents = self.master.get_file_contents(self.BACKUP_KEYTAB)
self.clients[0].put_file_contents(self.BACKUP_KEYTAB, contents)
@classmethod
def fix_resolv_conf(cls, client, server):
"""
Put server's ip address at the top of resolv.conf
"""
contents = client.get_file_contents(paths.RESOLV_CONF,
encoding='utf-8')
nameserver = 'nameserver %s\n' % server.ip
if not contents.startswith(nameserver):
contents = nameserver + contents.replace(nameserver, '')
client.put_file_contents(paths.RESOLV_CONF, contents)
@pytest.fixture()
def client(request):
# Here we call "fix_resolv_conf" method before every ipa-client-install so
# we get the client pointing to ipa master as DNS server.
request.cls.fix_resolv_conf(request.cls.clients[0], request.cls.master)
tasks.install_client(request.cls.master, request.cls.clients[0])
def teardown_client():

View File

@@ -42,23 +42,8 @@ config = get_global_config()
def create_broken_resolv_conf(master):
# Force a broken resolv.conf to simulate a bad response to
# reverse zone lookups
master.run_command([
'/bin/mv',
paths.RESOLV_CONF,
'%s.sav' % paths.RESOLV_CONF
])
contents = "# Set as broken by ipatests\nnameserver 127.0.0.2\n"
master.put_file_contents(paths.RESOLV_CONF, contents)
def restore_resolv_conf(master):
if os.path.exists('%s.sav' % paths.RESOLV_CONF):
master.run_command([
'/bin/mv',
'%s.sav' % paths.RESOLV_CONF,
paths.RESOLV_CONF
])
master.resolver.backup()
master.resolver.setup_resolver('127.0.0.2')
def server_install_setup(func):
@@ -69,7 +54,6 @@ def server_install_setup(func):
func(*args)
finally:
tasks.uninstall_master(master, clean=False)
restore_resolv_conf(master)
ipa_certs_cleanup(master)
return wrapped

View File

@@ -62,9 +62,6 @@ class TestSMB(IntegrationTest):
cls.smbclient = cls.clients[1]
cls.ad_user = '{}@{}'.format(cls.ad_user_login, cls.ad.domain.name)
for h in [cls.smbserver, cls.smbclient]:
tasks.config_host_resolvconf_with_master_data(cls.master, h)
tasks.install_adtrust(cls.master)
tasks.configure_dns_for_trust(cls.master, cls.ad)
tasks.configure_windows_dns_for_trust(cls.ad, cls.master)