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 <aslaikov@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Felipe Barreto 2018-01-12 09:14:35 -02:00 committed by Tibor Dudlák
parent e55969f7e0
commit cd660d1922
No known key found for this signature in database
GPG Key ID: 12B8BD343576CDF5

View File

@ -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