mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-07-29 23:58:23 -05:00
IPA-EPN: Test that EPN can be install, uninstalled and re-installed
Verify that no cruft is left over that will prevent reinstallation if it is uninstalled. Reviewed-By: Francois Cami <fcami@redhat.com> Reviewed-By: Alexander Bokovoy <abbra@users.noreply.github.com>
This commit is contained in:
committed by
Florence Blanc-Renaud
parent
f7a6c468ca
commit
af5138c2aa
@@ -37,6 +37,7 @@ from pipes import quote
|
||||
import configparser
|
||||
from contextlib import contextmanager
|
||||
from pkg_resources import parse_version
|
||||
import uuid
|
||||
|
||||
import dns
|
||||
from ldif import LDIFWriter
|
||||
@@ -2197,7 +2198,6 @@ def install_packages(host, pkgs):
|
||||
:param pkgs: packages to install, provided as a list of strings
|
||||
"""
|
||||
platform = get_platform(host)
|
||||
# Only supports RHEL 8+ and Fedora for now
|
||||
if platform in ('rhel', 'fedora'):
|
||||
install_cmd = ['/usr/bin/dnf', 'install', '-y']
|
||||
elif platform in ('ubuntu'):
|
||||
@@ -2207,6 +2207,31 @@ def install_packages(host, pkgs):
|
||||
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
|
||||
:param pkgs: packages to install, provided as a list of strings
|
||||
|
||||
A package can't be downloaded that is already installed.
|
||||
|
||||
Returns the temporary directory where the packages are.
|
||||
The caller is responsible for cleanup.
|
||||
"""
|
||||
platform = get_platform(host)
|
||||
tmpdir = os.path.join('/tmp', str(uuid.uuid4()))
|
||||
# Only supports RHEL 8+ and Fedora for now
|
||||
if platform in ('rhel', 'fedora'):
|
||||
install_cmd = ['/usr/bin/dnf', '-y',
|
||||
'--downloaddir', tmpdir,
|
||||
'--downloadonly',
|
||||
'install']
|
||||
else:
|
||||
raise ValueError('install_packages: unknown platform %s' % platform)
|
||||
host.run_command(['mkdir', tmpdir])
|
||||
host.run_command(install_cmd + pkgs)
|
||||
return tmpdir
|
||||
|
||||
|
||||
def uninstall_packages(host, pkgs):
|
||||
"""Uninstall packages on a remote host.
|
||||
:param host: the host where the uninstallation takes place
|
||||
@@ -2220,7 +2245,7 @@ def uninstall_packages(host, pkgs):
|
||||
install_cmd = ['apt-get', 'remove', '-y']
|
||||
else:
|
||||
raise ValueError('install_packages: unknown platform %s' % platform)
|
||||
host.run_command(install_cmd + pkgs)
|
||||
host.run_command(install_cmd + pkgs, raiseonerr=False)
|
||||
|
||||
|
||||
def wait_for_request(host, request_id, timeout=120):
|
||||
|
||||
@@ -29,6 +29,7 @@ import datetime
|
||||
import email
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import pytest
|
||||
import textwrap
|
||||
|
||||
@@ -202,6 +203,26 @@ class TestEPN(IntegrationTest):
|
||||
|
||||
@classmethod
|
||||
def install(cls, mh):
|
||||
# External DNS is only available before install so cache a copy
|
||||
# of the *ipa-epn-client package so we can experimentally remove
|
||||
# it later.
|
||||
#
|
||||
# Notes:
|
||||
# - A package can't be downloaded that is already installed so we
|
||||
# have to remove it first.
|
||||
# - dnf cleans up previously downloaded locations so make a copy it
|
||||
# doesn't know about.
|
||||
# - Adds a class variable, pkg, containing the package name of
|
||||
# the downloaded *ipa-client-epn rpm.
|
||||
tasks.uninstall_packages(cls.clients[0],EPN_PKG)
|
||||
pkgdir = tasks.download_packages(cls.clients[0], EPN_PKG)
|
||||
pkg = cls.clients[0].run_command(r'ls -1 {}'.format(pkgdir))
|
||||
cls.pkg = pkg.stdout_text.strip()
|
||||
cls.clients[0].run_command(['cp',
|
||||
os.path.join(pkgdir, cls.pkg),
|
||||
'/tmp'])
|
||||
cls.clients[0].run_command(r'rm -rf {}'.format(pkgdir))
|
||||
|
||||
tasks.install_packages(cls.master, EPN_PKG)
|
||||
tasks.install_packages(cls.master, ["postfix"])
|
||||
tasks.install_packages(cls.clients[0], EPN_PKG)
|
||||
@@ -628,3 +649,28 @@ class TestEPN(IntegrationTest):
|
||||
self.master, dry_run=True
|
||||
)
|
||||
assert "uid=admin" in stderr_text
|
||||
|
||||
@pytest.mark.skip_if_platform(
|
||||
"debian", reason="Don't know how to download-only pkgs in Debian"
|
||||
)
|
||||
def test_EPN_reinstall(self):
|
||||
"""Test that EPN can be installed, uninstalled and reinstalled.
|
||||
|
||||
Since post-install we no longer have access to the repos
|
||||
the package is downloaded and stored prior to server
|
||||
installation.
|
||||
"""
|
||||
tasks.uninstall_packages(self.clients[0], EPN_PKG)
|
||||
tasks.install_packages(self.clients[0],
|
||||
[os.path.join('/tmp', self.pkg)])
|
||||
self.clients[0].run_command(r'rm -f /tmp/{}'.format(self.pkg))
|
||||
|
||||
# re-installing will create a new epn.conf so any execution
|
||||
# of ipa-epn will verify the reinstall was ok. Since the previous
|
||||
# test would have failed this one should be ok with new config.
|
||||
|
||||
# Re-run the admin user expected failure
|
||||
(unused, stderr_text, _unused) = self._check_epn_output(
|
||||
self.master, dry_run=True
|
||||
)
|
||||
assert "uid=admin" in stderr_text
|
||||
|
||||
Reference in New Issue
Block a user