From 262a7121046132fbb7bb101ecf7d595814757819 Mon Sep 17 00:00:00 2001 From: François Cami Date: Jul 30 2020 16:02:19 +0000 Subject: 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 Signed-off-by: François Cami Reviewed-By: Mohammad Rizwan Reviewed-By: Michal Polovka Reviewed-By: Mohammad Rizwan Reviewed-By: Michal Polovka --- diff --git a/ipatests/test_integration/test_commands.py b/ipatests/test_integration/test_commands.py index e18a126..f358962 100644 --- a/ipatests/test_integration/test_commands.py +++ b/ipatests/test_integration/test_commands.py @@ -902,12 +902,14 @@ class TestIPACommand(IntegrationTest): if sssd_version < platform_tasks.parse_ipa_version('2.2.0'): 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 sssd_conf_backup = tasks.FileBackup(self.master, paths.SSSD_CONF) with tasks.remote_sssd_config(self.master) as sssd_config: sssd_config.edit_domain( self.master.domain, 'ldap_deref_threshold', 0) + + test_user = "testuser" + str(random.randint(200000, 9999999)) + password = "Secret123" try: self.master.run_command(['systemctl', 'restart', 'sssd.service']) @@ -915,22 +917,20 @@ class TestIPACommand(IntegrationTest): tasks.kinit_admin(self.master) # add ipa user - cmd = ['ipa', 'user-add', - '--first', username, - '--last', username, - '--password', username] - input_passwd = 'Secret123\nSecret123\n' - cmd_output = self.master.run_command(cmd, stdin_text=input_passwd) - assert 'Added user "%s"' % username in cmd_output.stdout_text - input_passwd = 'Secret123\nSecret123\nSecret123\n' - self.master.run_command(['kinit', username], - stdin_text=input_passwd) + tasks.create_active_user( + self.master, test_user, password=password + ) + tasks.kdestroy_all(self.master) + tasks.kinit_as_user( + self.master, test_user, password + ) + tasks.kdestroy_all(self.master) client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(self.master.hostname, - username=username, - password='Secret123') + username=test_user, + password=password) client.close() finally: sssd_conf_backup.restore()