From c9660e625e8f2cf5218ed0763bb431c997e3020c Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <flo@redhat.com>
Date: Tue, 7 Sep 2021 09:59:02 +0200
Subject: [PATCH] ipatests: fix logic waiting for repl in TestIPACommand

The logic of test_reset_password_unlock is twisted.
Currently it's doing:
- reset password on replicas[0]
- wait for replication on master
- kinit on master

The call to wait_for_replication should be done on
replicas[0], not on master, according to the method doc:
    Note that this waits for updates originating on this host, not those
    coming from other hosts.

Fixes: https://pagure.io/freeipa/issue/8975

Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
---
 ipatests/test_integration/test_commands.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ipatests/test_integration/test_commands.py b/ipatests/test_integration/test_commands.py
index fd5d1b47264..a5c4a86d4f6 100644
--- a/ipatests/test_integration/test_commands.py
+++ b/ipatests/test_integration/test_commands.py
@@ -1375,7 +1375,9 @@ def test_reset_password_unlock(self):
             stdin_text='{0}\n{0}\n'.format(original_passwd)
         )
 
-        ldap = self.master.ldap_connect()
+        # Wait for the password update to be replicated from replicas[0]
+        # to other servers
+        ldap = self.replicas[0].ldap_connect()
         tasks.wait_for_replication(ldap)
 
         # The user can log in again
