From cd660d192231674d8e7d7bd85a8eec68eea29bc7 Mon Sep 17 00:00:00 2001 From: Felipe Barreto Date: Fri, 12 Jan 2018 09:14:35 -0200 Subject: [PATCH] Fixing test_backup_and_restore assert to do not rely on the order Since we cannot assume that LDAP will return data in any ordered way, the test should be changed to do not rely on that. Instead of just comparing the output of the show-user command, this change first order the groups returned in the 'Member of Group' field before compare them. https://pagure.io/freeipa/issue/7339 Reviewed-By: Aleksei Slaikovskii Reviewed-By: Christian Heimes Reviewed-By: Alexander Bokovoy --- ipatests/test_integration/test_backup_and_restore.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ipatests/test_integration/test_backup_and_restore.py b/ipatests/test_integration/test_backup_and_restore.py index fbc882aa0..2e99376da 100644 --- a/ipatests/test_integration/test_backup_and_restore.py +++ b/ipatests/test_integration/test_backup_and_restore.py @@ -65,6 +65,15 @@ def check_admin_in_ldap(host): def check_admin_in_cli(host): result = host.run_command(['ipa', 'user-show', 'admin']) assert 'User login: admin' in result.stdout_text, result.stdout_text + + # LDAP do not guarantee any order, so the test cannot assume it. Based on + # that, the code bellow order the 'Member of groups' field to able to + # assert it latter. + data = dict(re.findall("\W*(.+):\W*(.+)\W*", result.stdout_text)) + data["Member of groups"] = ', '.join(sorted(data["Member of groups"] + .split(", "))) + result.stdout_text = ''.join([' {}: {}\n'.format(k, v) + for k, v in data.items()]) return result