ipatests: add test for ticket 9610

Test scenario:
- ensure there is no /etc/ssh/ssh_config.orig file
- force ipa-client package reinstallation
- ensure no backup file is created in /etc/ssh/ssh_config.orig

Related: https://pagure.io/freeipa/issue/9610
Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
This commit is contained in:
Florence Blanc-Renaud 2024-06-20 08:13:27 +02:00
parent 09e66dc936
commit 4d51446bd3
2 changed files with 29 additions and 0 deletions

View File

@ -2550,6 +2550,21 @@ def install_packages(host, pkgs):
host.run_command(install_cmd + pkgs)
def reinstall_packages(host, pkgs):
"""Install packages on a remote host.
:param host: the host where the installation takes place
:param pkgs: packages to install, provided as a list of strings
"""
platform = get_platform(host)
if platform in {'rhel', 'fedora'}:
install_cmd = ['/usr/bin/dnf', 'reinstall', '-y']
elif platform in {'debian', 'ubuntu'}:
install_cmd = ['apt-get', '--reinstall', 'install', '-y']
else:
raise ValueError('install_packages: unknown platform %s' % platform)
host.run_command(install_cmd + pkgs)
def download_packages(host, pkgs):
"""Download packages on a remote host.
:param host: the host where the download takes place

View File

@ -477,3 +477,17 @@ class TestUpgrade(IntegrationTest):
self.master.run_command(['ipa-server-upgrade'])
assert self.master.transport.file_exists(
paths.SYSTEMD_PKI_TOMCAT_IPA_CONF)
def test_ssh_config(self):
"""Test that pkg upgrade does not create /etc/ssh/ssh_config.orig
Test for ticket 9610
The upgrade of ipa-client package should not create a backup file
/etc/ssh/ssh_config.orig if no change is applied.
"""
# Ensure there is no backup file before the test
self.master.run_command(["rm", "-f", paths.SSH_CONFIG + ".orig"])
# Force client package reinstallation to trigger %post scriptlet
tasks.reinstall_packages(self.master, ['*ipa-client'])
assert not self.master.transport.file_exists(
paths.SSH_CONFIG + ".orig")