mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-08-14 06:54:55 -05:00
ui_tests: add function to run cmd on UI host
Run shell command on the UI system using "admin" user's passwd from conf. https://pagure.io/freeipa/issue/7441 Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
committed by
Christian Heimes
parent
95de6f061c
commit
18e8c964f5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user