mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipatests: fix modify_sssd_conf()
The method modify_sssd_conf() is copying a remote sssd.conf file to the test controller then uses sssd python API to modify the config file. When the test controller does not have sssd-common package installed, SSSDConfig() call fails because the API needs sssd schema in order to properly parse the config file, and the schema files are provided by sssd-common pkg. The fix also downloads the files representing sssd schema and calls SSSDConfig() with those files. Using the schema from the test machine is ensuring that config is consistent with the schema (if the sssd version differs between controller and test machine for instance). Note: we currently don't see any issue in the nightly tests because the test controller is installed with sssd-common package but if you run the tests as specified in https://www.freeipa.org/page/Testing with a controller missing sssd-common, you will see the issue. Reviewed-By: Sergey Orlov <sorlov@redhat.com>
This commit is contained in:
@@ -28,6 +28,7 @@ import textwrap
|
|||||||
import re
|
import re
|
||||||
import collections
|
import collections
|
||||||
import itertools
|
import itertools
|
||||||
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
from pipes import quote
|
from pipes import quote
|
||||||
@@ -820,7 +821,30 @@ def modify_sssd_conf(host, domain, mod_dict, provider='ipa',
|
|||||||
with open(temp_config_file, 'wb') as f:
|
with open(temp_config_file, 'wb') as f:
|
||||||
f.write(current_config)
|
f.write(current_config)
|
||||||
|
|
||||||
sssd_config = SSSDConfig()
|
# In order to use SSSDConfig() locally we need to import the schema
|
||||||
|
# Create a tar file with /usr/share/sssd.api.conf and
|
||||||
|
# /usr/share/sssd/sssd.api.d
|
||||||
|
tmpname = create_temp_file(host)
|
||||||
|
host.run_command(
|
||||||
|
['tar', 'cJvf', tmpname,
|
||||||
|
'sssd.api.conf',
|
||||||
|
'sssd.api.d'],
|
||||||
|
log_stdout=False, cwd="/usr/share/sssd")
|
||||||
|
# fetch tar file
|
||||||
|
tar_dir = tempfile.mkdtemp()
|
||||||
|
tarname = os.path.join(tar_dir, "sssd_schema.tar.xz")
|
||||||
|
with open(tarname, 'wb') as f:
|
||||||
|
f.write(host.get_file_contents(tmpname))
|
||||||
|
# delete from remote
|
||||||
|
host.run_command(['rm', '-f', tmpname])
|
||||||
|
# Unpack on the local side
|
||||||
|
ipautil.run([paths.TAR, 'xJvf', tarname], cwd=tar_dir)
|
||||||
|
os.unlink(tarname)
|
||||||
|
|
||||||
|
# Use the imported schema
|
||||||
|
sssd_config = SSSDConfig(
|
||||||
|
schemafile=os.path.join(tar_dir, "sssd.api.conf"),
|
||||||
|
schemaplugindir=os.path.join(tar_dir, "sssd.api.d"))
|
||||||
sssd_config.import_config(temp_config_file)
|
sssd_config.import_config(temp_config_file)
|
||||||
sssd_domain = sssd_config.get_domain(domain)
|
sssd_domain = sssd_config.get_domain(domain)
|
||||||
|
|
||||||
@@ -837,6 +861,7 @@ def modify_sssd_conf(host, domain, mod_dict, provider='ipa',
|
|||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
os.remove(temp_config_file)
|
os.remove(temp_config_file)
|
||||||
|
shutil.rmtree(tar_dir)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user