Skip to content

Commit

Permalink
[6.15.z] Check ipa command failure reason, improve logging. Logout fi…
Browse files Browse the repository at this point in the history
…rst before attempting login. (#16134)

Check ipa command failure reason, improve logging. Logout first before attempting login. (#16109)

(cherry picked from commit 15bc243)

Co-authored-by: Lukáš Hellebrandt <[email protected]>
  • Loading branch information
Satellite-QE and lhellebr authored Sep 4, 2024
1 parent 660d160 commit 0555175
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions robottelo/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2698,8 +2698,10 @@ def find_user(self, username):
def add_user_to_usergroup(self, member_username, member_group):
self._kinit_admin()
result = self.execute(f'ipa group-add-member {member_group} --users={member_username}')
if result.status != 0:
raise IPAHostError('Failed to add the user to usergroup')
if result.status != 0 and 'This entry is already a member' not in result.stdout:
raise IPAHostError(
f'Failed to add the user to usergroup.\nSTDOUT: {result.stdout}\nSTDERR: {result.stderr}'
)

def remove_user_from_usergroup(self, member_username, member_group):
self._kinit_admin()
Expand Down
1 change: 1 addition & 0 deletions tests/foreman/cli/test_ldapauthsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def test_usergroup_sync_with_refresh(self, default_ipa_host, module_target_sat):
assert ext_user_group['auth-source'] == auth_source['server']['name']
user_group = module_target_sat.cli.UserGroup.info({'id': user_group['id']})
assert len(user_group['users']) == 0
module_target_sat.cli.Auth.logout()
result = module_target_sat.cli.Auth.with_user(
username=member_username, password=default_ipa_host.ldap_user_passwd
).status()
Expand Down

0 comments on commit 0555175

Please sign in to comment.