-- 
Oleg Fayans
Quality Engineer
FreeIPA team
RedHat.
From a4f0bdbe3a8646070119ccb668ad0bfb8cfb269b Mon Sep 17 00:00:00 2001
From: Oleg Fayans <ofay...@redhat.com>
Date: Mon, 21 Mar 2016 13:27:19 +0100
Subject: [PATCH] Added 5 more tests to Replica Promotion testsuite

https://fedorahosted.org/freeipa/ticket/5723
---
 .../test_integration/test_replica_promotion.py     | 113 ++++++++++++++++++++-
 1 file changed, 112 insertions(+), 1 deletion(-)

diff --git a/ipatests/test_integration/test_replica_promotion.py b/ipatests/test_integration/test_replica_promotion.py
index 9686c8f4931b1c8c40e60a7087c27380188d0d64..47e69c2ea8af349bd2955a32bc7f2a0275637628 100644
--- a/ipatests/test_integration/test_replica_promotion.py
+++ b/ipatests/test_integration/test_replica_promotion.py
@@ -170,6 +170,18 @@ class TestReplicaPromotionLevel1(ReplicaPromotionBase):
                              " to generate replica file\n"
                              "is supported only in 0-level IPA domain", 1)
 
+    @replicas_cleanup
+    def test_one_command_installation(self):
+        """
+        TestCase:
+        http://www.freeipa.org/page/V4/Replica_Promotion/Test_plan
+        #Test_case:_Replica_can_be_installed_using_one_command
+        """
+        self.replicas[0].run_command(['ipa-replica-install', '-p',
+                                     self.master.config.admin_password,
+                                     '-n', self.master.domain.name,
+                                     '-r', self.master.domain.realm])
+
 
 class TestReplicaManageCommands(IntegrationTest):
     topology = "star"
@@ -207,7 +219,7 @@ class TestReplicaManageCommands(IntegrationTest):
                               ' deprecated with managed IPA replication'
                               ' topology. Please use `ipa topologysegment-*`'
                               ' commands to manage the topology', 1)
-        tasks.create_segment(master, replica1, replica2)
+        segment = tasks.create_segment(master, replica1, replica2)
         result4 = master.run_command(["ipa-replica-manage",
                                       "disconnect",
                                       replica1.hostname,
@@ -217,3 +229,102 @@ class TestReplicaManageCommands(IntegrationTest):
                               ' deprecated with managed IPA replication'
                               ' topology. Please use `ipa topologysegment-*`'
                               ' commands to manage the topology', 1)
+
+        # http://www.freeipa.org/page/V4/Replica_Promotion/Test_plan
+        #Test_case:_ipa-csreplica-manage_connect_is_deprecated
+        #_in_domain_level_1
+
+        tasks.destroy_segment(master, segment[0]['name'])
+        result5 = master.run_command(["ipa-csreplica-manage",
+                                      "connect",
+                                      replica1.hostname,
+                                      replica2.hostname,
+                                      '-p', master.config.dirman_password],
+                                     raiseonerr=False)
+        assert_error(result5, "Creation of IPA CS replication agreement is"
+                              " deprecated with managed IPA replication"
+                              " topology", 1)
+        tasks.create_segment(master, replica1, replica2)
+        result6 = master.run_command(["ipa-csreplica-manage",
+                                      "disconnect",
+                                      replica1.hostname,
+                                      replica2.hostname,
+                                      '-p', master.config.dirman_password],
+                                     raiseonerr=False)
+        assert_error(result6, "Removal of IPA CS replication agreement is"
+                              " deprecated with managed IPA"
+                              " replication topology", 1)
+
+
+class TestUnprivilegedUserPermissions(IntegrationTest):
+    num_replicas = 1
+    domain_level = DOMAIN_LEVEL_1
+
+    @classmethod
+    def install(cls, mh):
+        tasks.install_master(cls.master, domain_level=cls.domain_level)
+
+    def test_unprivileged(self):
+        """
+        TestCase:
+        http://www.freeipa.org/page/V4/Replica_Promotion/Test_plan
+        #Test_case:_Unprivileged_users_are_not_allowed_to_enroll
+        _and_promote_clients
+        """
+        password = self.master.config.dirman_password
+        new_password = '$ome0therPaaS'
+        replica = self.replicas[0]
+        adduser_stdin_text = "%s\n%s\n" % (self.master.config.admin_password,
+                                           self.master.config.admin_password)
+        user_kinit_stdin_text = "%s\n%s\n%s\n" % (password, new_password,
+                                                  new_password)
+        tasks.kinit_admin(self.master)
+        self.master.run_command(['ipa', 'user-add', 'testuser', '--password',
+                                 '--first', 'John', '--last', 'Donn'],
+                                stdin_text=adduser_stdin_text)
+        # Now we need to change the password for the user
+        self.master.run_command(['kinit', 'testuser'],
+                                stdin_text=user_kinit_stdin_text)
+        # And again kinit admin
+        tasks.kinit_admin(self.master)
+        result1 = replica.run_command(['ipa-client-install', '-p', 'testuser',
+                                       '-w', new_password,
+                                       '--domain', replica.domain.name,
+                                       '--realm', replica.domain.realm, '-U'],
+                                      raiseonerr=False)
+        assert_error(result1, "No permission to join this host", 1)
+        tasks.install_client(self.master, replica)
+        result2 = replica.run_command(['ipa-replica-install', '-P', 'testuser',
+                                       '-p', new_password,
+                                       '-n', self.master.domain.name,
+                                       '-r', self.master.domain.realm],
+                                      raiseonerr=False)
+        assert_error(result2,
+                     "Insufficient privileges to promote the server", 1)
+        self.master.run_command(['ipa', 'group-add-member', 'admins',
+                                 '--users=testuser'])
+
+        replica.run_command(['ipa-replica-install', '-P', 'testuser',
+                             '-p', new_password,
+                             '-n', self.master.domain.name,
+                             '-r', self.master.domain.realm])
+
+
+class TestProhibitReplicaUninstallation(IntegrationTest):
+    topology = 'line'
+    num_replicas = 2
+    domain_level = DOMAIN_LEVEL_1
+
+    def test_replica_uninstallation_prohibited(self):
+        """
+        http://www.freeipa.org/page/V4/Replica_Promotion/Test_plan
+        #Test_case:_Prohibit_ipa_server_uninstallation_from_disconnecting
+        _topology_segment
+        """
+        result = self.replicas[0].run_command(['ipa-server-install',
+                                               '--uninstall', '-U'],
+                                              raiseonerr=False)
+        assert("Uninstallation leads to disconnected topology"
+               in result.stderr_text)
+        self.replicas[0].run_command(['ipa-server-install', '--uninstall',
+                                      '-U', '--ignore-topology-disconnect'])
-- 
1.8.3.1

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to