ipatests: ui_driver: convert run_cmd_on_ui_host to tasks.py::run_ssh_cmd

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 <fcami@redhat.com>
Reviewed-By: Mohammad Rizwan <myusuf@redhat.com>
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
This commit is contained in:
François Cami
2020-07-29 13:53:52 +02:00
parent 326e13347c
commit a9f055787a
+8 -17
View File
@@ -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):