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