diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py index f8b53039e..1c66f1b6c 100644 --- a/ipatests/test_webui/ui_driver.py +++ b/ipatests/test_webui/ui_driver.py @@ -30,6 +30,7 @@ import re import os from functools import wraps import unittest +import paramiko # pylint: disable=import-error from six.moves.urllib.error import URLError @@ -1643,6 +1644,33 @@ class UI_driver(object): self.find(ssh_pub, By.CSS_SELECTOR).click() self.facet_button_click('save') + def run_cmd_on_ui_host(self, cmd): + """ + Run "shell" command on the UI system using "admin" user's passwd from + conf. + Use only where API does not fit. + + cmd (str): command to run + """ + + 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() + def has_class(self, el, cls): """ Check if el has CSS class