From 20ef79c02cf321f3d35c0408b9bf5887c04b11fe Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 28 Nov 2019 13:27:15 +0100 Subject: [PATCH] Remove FIPS noise from SSHd When a system is in FIPS mode, SSHd can prints some noise to stderr: FIPS mode initialized\r\n This noise causes interference and breakage of some tests. Remove the noise from stderr_bytes, which automatically fixes stderr_text, too. Signed-off-by: Christian Heimes Reviewed-By: Francisco Trivino --- ipatests/pytest_ipa/integration/host.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ipatests/pytest_ipa/integration/host.py b/ipatests/pytest_ipa/integration/host.py index 33f7c732a..dca28e584 100644 --- a/ipatests/pytest_ipa/integration/host.py +++ b/ipatests/pytest_ipa/integration/host.py @@ -18,6 +18,7 @@ # along with this program. If not, see . """Host class for integration testing""" +import re import subprocess import tempfile @@ -31,6 +32,8 @@ from .fips import ( is_fips_enabled, enable_userspace_fips, disable_userspace_fips ) +FIPS_NOISE_RE = re.compile(br"FIPS mode initialized\r?\n?") + class LDAPClientWithoutCertCheck(ipaldap.LDAPClient): """Adds an option to disable certificate check for TLS connection @@ -176,6 +179,9 @@ class Host(pytest_multihost.host.Host): log_stdout=log_stdout, raiseonerr=False, cwd=cwd, bg=bg, encoding=encoding ) + # in FIPS mode SSH may print noise to stderr, remove the string + # "FIPS mode initialized" + optional newline. + result.stderr_bytes = FIPS_NOISE_RE.sub(b'', result.stderr_bytes) try: result_ok = result.returncode in ok_returncode except TypeError: