From a3c648bd926224c53f96602ea3ec7213a3caa22d Mon Sep 17 00:00:00 2001 From: Florence Blanc-Renaud Date: Mon, 22 Jun 2020 09:42:02 +0200 Subject: [PATCH] ipatests: fix the method adding ifp to sssd.conf The test TestCertsInIDOverrides enables the ifp service in sssd.conf by a sed command. If the service is already enabled, the ifp service appears multiple times in the section [sssd] services = ..ifp...ifp and sssd fails to start. Use tasks.remote_sssd_config to properly configure the services as this API properly handles the case when the service is already configured. Fixes: https://pagure.io/freeipa/issue/8371 Reviewed-By: Anuja More Reviewed-By: Rob Crittenden --- ipatests/test_integration/test_idviews.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ipatests/test_integration/test_idviews.py b/ipatests/test_integration/test_idviews.py index f063d4b30..670ba5532 100644 --- a/ipatests/test_integration/test_idviews.py +++ b/ipatests/test_integration/test_idviews.py @@ -7,6 +7,7 @@ from __future__ import absolute_import import os import re import string +from SSSDConfig import ServiceAlreadyExists from ipatests.pytest_ipa.integration import tasks from ipatests.test_integration.base import IntegrationTest from ipatests.pytest_ipa.integration.env_config import get_global_config @@ -40,13 +41,15 @@ class TestCertsInIDOverrides(IntegrationTest): # A setup for test_dbus_user_lookup master.run_command(['dnf', 'install', '-y', 'sssd-dbus'], raiseonerr=False) - # The tasks.modify_sssd_conf way did not work because - # sssd_domain.set_option knows nothing about 'services' parameter of - # the sssd config file. Therefore I am using sed approach - master.run_command( - "sed -i '/^services/ s/$/, ifp/' %s" % paths.SSSD_CONF) master.run_command( "sed -i 's/= 7/= 0xFFF0/' %s" % paths.SSSD_CONF, raiseonerr=False) + with tasks.remote_sssd_config(master) as sssd_config: + try: + sssd_config.new_service('ifp') + except ServiceAlreadyExists: + pass + sssd_config.activate_service('ifp') + master.run_command(['systemctl', 'restart', 'sssd.service']) # End of setup for test_dbus_user_lookup