From a9f055787ac389e4164f3de5369bade1d4b218b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= Date: Mon, 27 Jul 2020 09:49:59 +0200 Subject: [PATCH] ipatests: ui_driver: convert run_cmd_on_ui_host to tasks.py::run_ssh_cmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Paramiko is not compatible with FIPS. Migrate run_cmd_on_ui_host to the OpenSSH CLI SSH(1) using tasks.py's run_ssh_cmd. Rationale: this is exactly what clients use. Fixes: https://pagure.io/freeipa/issue/8129 Signed-off-by: François Cami Reviewed-By: Mohammad Rizwan Reviewed-By: Michal Polovka --- ipatests/test_webui/ui_driver.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py index 70e8e7b25..dc02a0eaa 100644 --- a/ipatests/test_webui/ui_driver.py +++ b/ipatests/test_webui/ui_driver.py @@ -32,7 +32,6 @@ import os from functools import wraps from urllib.error import URLError -import paramiko import pytest try: @@ -61,7 +60,9 @@ except ImportError: NO_YAML = True from ipaplatform.paths import paths -from ipaplatform.tasks import tasks + +from ipatests.pytest_ipa.integration import tasks + ENV_MAP = { 'MASTER': 'ipa_server', @@ -1972,26 +1973,16 @@ class UI_driver: cmd (str): command to run """ - if tasks.is_fips_enabled(): - pytest.skip("paramiko is not compatible with FIPS mode") login = self.config.get('ipa_admin') hostname = self.config.get('ipa_server') password = self.config.get('ipa_password') - try: - ssh = paramiko.SSHClient() - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect(hostname=hostname, username=login, password=password) - ssh.exec_command(cmd) - except paramiko.AuthenticationException: - self.skip('Authentication to server {} failed'.format(hostname)) - except paramiko.SSHException as e: - self.skip('Unable to establish SSH connection: {}'.format(e)) - except Exception as e: - self.skip('Unable to proceed: {}'.format(e)) - finally: - ssh.close() + tasks.run_ssh_cmd( + to_host=hostname, username=login, + auth_method="password", password=password, + cmd=cmd + ) @dismiss_unexpected_alert def has_class(self, el, cls):