7e1b55
From 8ea8f8b68b5a7217518f68065a5fc1df16126314 Mon Sep 17 00:00:00 2001
7e1b55
From: Rob Crittenden <rcritten@redhat.com>
7e1b55
Date: Mon, 19 Jul 2021 21:54:22 -0400
7e1b55
Subject: [PATCH] ipatests: test removing last KRA when it is not running
7e1b55
7e1b55
Use the new role-based mechanism, one that doesn't rely
7e1b55
on direct communication to the server, to determine whether
7e1b55
the server being removed by `ipa server-del` contains the
7e1b55
last KRA server.
7e1b55
7e1b55
https://pagure.io/freeipa/issue/8397
7e1b55
7e1b55
Signed-off-by: Rob Crittenden <rcritten@redhat.com>
7e1b55
Reviewed-By: Francois Cami <fcami@redhat.com>
7e1b55
---
7e1b55
 ipatests/test_integration/test_server_del.py | 17 +++++++++++++++++
7e1b55
 1 file changed, 17 insertions(+)
7e1b55
7e1b55
diff --git a/ipatests/test_integration/test_server_del.py b/ipatests/test_integration/test_server_del.py
7e1b55
index 5e627d5db..9d7f5ef7a 100644
7e1b55
--- a/ipatests/test_integration/test_server_del.py
7e1b55
+++ b/ipatests/test_integration/test_server_del.py
7e1b55
@@ -302,6 +302,23 @@ class TestLastServices(ServerDelBase):
7e1b55
             1
7e1b55
         )
7e1b55
 
7e1b55
+    def test_removal_of_server_raises_error_about_last_kra(self):
7e1b55
+        """
7e1b55
+        test that removal of server fails on the last KRA
7e1b55
+
7e1b55
+        We shut it down to verify that it can be removed if it failed.
7e1b55
+        """
7e1b55
+        tasks.install_kra(self.master)
7e1b55
+        self.master.run_command(['ipactl', 'stop'])
7e1b55
+        tasks.assert_error(
7e1b55
+            tasks.run_server_del(self.replicas[0], self.master.hostname),
7e1b55
+            "Deleting this server is not allowed as it would leave your "
7e1b55
+            "installation without a KRA.",
7e1b55
+            1
7e1b55
+        )
7e1b55
+        # Restarting the server we stopped is not necessary as it will
7e1b55
+        # be removed in the next test.
7e1b55
+
7e1b55
     def test_forced_removal_of_master(self):
7e1b55
         """
7e1b55
         Tests that we can still force remove the master using
7e1b55
-- 
7e1b55
2.26.3
7e1b55