Skip to content

Commit

Permalink
Fix username for AD and IDM. Fix session contexts. (#16382)
Browse files Browse the repository at this point in the history
* Fix username for AD and IDM. Fix session contexts.

* Additional tests fixed to use the correct user shown name
  • Loading branch information
lhellebr authored Oct 3, 2024
1 parent 65d7c33 commit 9664b16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions pytest_fixtures/component/satellite_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def _ad_data(version='2019'):
if version in supported_server_versions:
ad_server_details = {
'ldap_user_name': settings.ldap.username,
'ldap_user_shown_name': settings.ldap.user_shown_name,
'ldap_user_cn': settings.ldap.username,
'ldap_user_passwd': settings.ldap.password,
'base_dn': settings.ldap.basedn,
Expand All @@ -77,6 +78,7 @@ def _ad_data(version='2019'):
def ipa_data():
return {
'ldap_user_name': settings.ipa.user,
'ldap_user_shown_name': settings.ipa.user_shown_name,
'ldap_user_cn': settings.ipa.username,
'ipa_otp_username': settings.ipa.otp_user,
'ldap_user_passwd': settings.ipa.password,
Expand All @@ -94,6 +96,7 @@ def ipa_data():
def open_ldap_data():
return {
'ldap_user_name': settings.open_ldap.open_ldap_user,
'ldap_user_shown_name': settings.open_ldap.user_shown_name,
'ldap_user_cn': settings.open_ldap.username,
'ldap_hostname': settings.open_ldap.hostname,
'ldap_user_passwd': settings.open_ldap.password,
Expand Down
14 changes: 7 additions & 7 deletions tests/foreman/ui/test_ldap_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def test_positive_update_external_roles(
session.activationkey.create({'name': ak_name})
assert session.activationkey.search(ak_name)[0]['Name'] == ak_name
current_user = session.activationkey.read(ak_name, 'current_user')['current_user']
assert ldap_data['ldap_user_name'] in current_user
assert ldap_data['ldap_user_shown_name'] == current_user


@pytest.mark.parametrize('ldap_auth_source', ['AD', 'IPA'], indirect=True)
Expand Down Expand Up @@ -480,13 +480,13 @@ def test_positive_update_external_user_roles(
)
with target_sat.ui_session(
test_name, ldap_data['ldap_user_name'], ldap_data['ldap_user_passwd']
) as session:
) as ldapsession:
with pytest.raises(NavigationTriesExceeded):
ldapsession.architecture.search('')
session.activationkey.create({'name': ak_name})
assert session.activationkey.search(ak_name)[0]['Name'] == ak_name
current_user = session.activationkey.read(ak_name, 'current_user')['current_user']
assert ldap_data['ldap_user_name'] in current_user
ldapsession.activationkey.create({'name': ak_name})
assert ldapsession.activationkey.search(ak_name)[0]['Name'] == ak_name
current_user = ldapsession.activationkey.read(ak_name, 'current_user')['current_user']
assert ldap_data['ldap_user_shown_name'] == current_user


@pytest.mark.parametrize('ldap_auth_source', ['AD', 'IPA'], indirect=True)
Expand Down Expand Up @@ -541,7 +541,7 @@ def test_positive_add_admin_role_with_org_loc(
session.location.create({'name': location_name})
assert session.location.search(location_name)[0]['Name'] == location_name
location = session.location.read(location_name, ['current_user', 'primary'])
assert ldap_data['ldap_user_name'] in location['current_user']
assert ldap_data['ldap_user_shown_name'] in location['current_user']
assert location['primary']['name'] == location_name
session.organization.select(module_org.name)
session.activationkey.create({'name': ak_name})
Expand Down

0 comments on commit 9664b16

Please sign in to comment.