bbecb6
From a6cb905de74da38d62f9c3bd7957018924282521 Mon Sep 17 00:00:00 2001
bbecb6
From: Anuja More <amore@redhat.com>
bbecb6
Date: Mon, 30 Jan 2023 19:27:49 +0530
bbecb6
Subject: [PATCH] Add test for SSH with GSSAPI auth.
bbecb6
bbecb6
Added test for aduser with GSSAPI authentication.
bbecb6
bbecb6
Related : https://pagure.io/freeipa/issue/9316
bbecb6
bbecb6
Signed-off-by: Anuja More <amore@redhat.com>
bbecb6
Reviewed-By: Rafael Guterres Jeffman <rjeffman@redhat.com>
bbecb6
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
bbecb6
---
bbecb6
 ipatests/test_integration/test_trust.py | 46 +++++++++++++++++++++++++
bbecb6
 1 file changed, 46 insertions(+)
bbecb6
bbecb6
diff --git a/ipatests/test_integration/test_trust.py b/ipatests/test_integration/test_trust.py
bbecb6
index c4b3b99ce1abbc16817b6530939fd9bae3f9500a..0d5b71cb0277a79eed7c34eb7e3d7eb6c09faa5e 100644
bbecb6
--- a/ipatests/test_integration/test_trust.py
bbecb6
+++ b/ipatests/test_integration/test_trust.py
bbecb6
@@ -527,6 +527,35 @@ class TestTrust(BaseTestTrust):
bbecb6
                    .format(self.ad_domain, subordinate_suffix))
bbecb6
             self.ad.run_command(['powershell', '-c', cmd])
bbecb6
 
bbecb6
+    def test_ssh_aduser(self):
bbecb6
+        """Test ssh with GSSAPI is working with aduser
bbecb6
+
bbecb6
+        When kerberos ticket is obtained for child domain user
bbecb6
+        and ssh with this ticket should be successful
bbecb6
+        with no password prompt.
bbecb6
+
bbecb6
+        Related : https://pagure.io/freeipa/issue/9316
bbecb6
+        """
bbecb6
+        testuser = 'testuser@{0}'.format(self.ad_domain)
bbecb6
+        testusersub = 'subdomaintestuser@{0}'.format(self.ad_subdomain)
bbecb6
+
bbecb6
+        def sshuser(host, user):
bbecb6
+            tasks.kdestroy_all(host)
bbecb6
+            try:
bbecb6
+                tasks.kinit_as_user(host, user,
bbecb6
+                                    host.config.ad_admin_password
bbecb6
+                                    )
bbecb6
+                ssh_cmd = "ssh -q -K -l {user} {host} hostname"
bbecb6
+                valid_ssh = host.run_command(
bbecb6
+                    ssh_cmd.format(user=user, host=host.hostname)
bbecb6
+                )
bbecb6
+                assert host.hostname in valid_ssh.stdout_text
bbecb6
+            finally:
bbecb6
+                tasks.kdestroy_all(host)
bbecb6
+
bbecb6
+        sshuser(self.master, testuser)
bbecb6
+        sshuser(self.master, testusersub)
bbecb6
+
bbecb6
     def test_remove_nonposix_trust(self):
bbecb6
         self.remove_trust(self.ad)
bbecb6
         tasks.unconfigure_dns_for_trust(self.master, self.ad)
bbecb6
@@ -785,6 +814,23 @@ class TestTrust(BaseTestTrust):
bbecb6
         assert re.search(
bbecb6
             testuser_regex, result.stdout_text), result.stdout_text
bbecb6
 
bbecb6
+    def test_ssh_adtreeuser(self):
bbecb6
+        testuser = 'treetestuser@{0}'.format(self.ad_treedomain)
bbecb6
+        self.master.run_command(["id", testuser])
bbecb6
+        tasks.clear_sssd_cache(self.master)
bbecb6
+        tasks.kdestroy_all(self.master)
bbecb6
+        try:
bbecb6
+            tasks.kinit_as_user(self.master, testuser,
bbecb6
+                                password="Secret123456"
bbecb6
+                                )
bbecb6
+            ssh_cmd = "ssh -q -K -l {user} {host} hostname"
bbecb6
+            valid_ssh = self.master.run_command(
bbecb6
+                ssh_cmd.format(user=testuser, host=self.master.hostname)
bbecb6
+            )
bbecb6
+            assert self.master.hostname in valid_ssh.stdout_text
bbecb6
+        finally:
bbecb6
+            tasks.kdestroy_all(self.master)
bbecb6
+
bbecb6
     def test_remove_external_treedomain_trust(self):
bbecb6
         self.remove_trust(self.tree_ad)
bbecb6
         tasks.unconfigure_dns_for_trust(self.master, self.ad, self.tree_ad)
bbecb6
-- 
bbecb6
2.39.1
bbecb6