ipatests: test_commands: test_ssh_from_controller: refactor

test_ssh_from_controller does not use methods provided by tasks.py.
Refactor using those methods.

Related: https://pagure.io/freeipa/issue/8129
Signed-off-by: François Cami <fcami@redhat.com>

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-24 13:26:47 +02:00
parent 5cc7a2b703
commit 27ed8260ba

View File

@ -902,12 +902,14 @@ class TestIPACommand(IntegrationTest):
if sssd_version < platform_tasks.parse_ipa_version('2.2.0'): if sssd_version < platform_tasks.parse_ipa_version('2.2.0'):
pytest.xfail(reason="sssd 2.2.0 unavailable in F29 nightly") pytest.xfail(reason="sssd 2.2.0 unavailable in F29 nightly")
username = "testuser" + str(random.randint(200000, 9999999))
# add ldap_deref_threshold=0 to /etc/sssd/sssd.conf # add ldap_deref_threshold=0 to /etc/sssd/sssd.conf
sssd_conf_backup = tasks.FileBackup(self.master, paths.SSSD_CONF) sssd_conf_backup = tasks.FileBackup(self.master, paths.SSSD_CONF)
with tasks.remote_sssd_config(self.master) as sssd_config: with tasks.remote_sssd_config(self.master) as sssd_config:
sssd_config.edit_domain( sssd_config.edit_domain(
self.master.domain, 'ldap_deref_threshold', 0) self.master.domain, 'ldap_deref_threshold', 0)
test_user = "testuser" + str(random.randint(200000, 9999999))
password = "Secret123"
try: try:
self.master.run_command(['systemctl', 'restart', 'sssd.service']) self.master.run_command(['systemctl', 'restart', 'sssd.service'])
@ -915,22 +917,20 @@ class TestIPACommand(IntegrationTest):
tasks.kinit_admin(self.master) tasks.kinit_admin(self.master)
# add ipa user # add ipa user
cmd = ['ipa', 'user-add', tasks.create_active_user(
'--first', username, self.master, test_user, password=password
'--last', username, )
'--password', username] tasks.kdestroy_all(self.master)
input_passwd = 'Secret123\nSecret123\n' tasks.kinit_as_user(
cmd_output = self.master.run_command(cmd, stdin_text=input_passwd) self.master, test_user, password
assert 'Added user "%s"' % username in cmd_output.stdout_text )
input_passwd = 'Secret123\nSecret123\nSecret123\n' tasks.kdestroy_all(self.master)
self.master.run_command(['kinit', username],
stdin_text=input_passwd)
client = paramiko.SSHClient() client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(self.master.hostname, client.connect(self.master.hostname,
username=username, username=test_user,
password='Secret123') password=password)
client.close() client.close()
finally: finally:
sssd_conf_backup.restore() sssd_conf_backup.restore()