Skip to content

Commit 05b34f8

Browse files
authored
Use the hostname shortened for AD. (#20735)
Use the hostname shortened for AD. Otherwise, the Service ticket won't be obtained because the client won't be found by the unshortened hostname. Remember, AD can only count to 15.
1 parent 7bb320c commit 05b34f8

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

pytest_fixtures/component/satellite_auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,12 @@ def rhsso_setting_setup_with_timeout(module_target_sat, rhsso_setting_setup):
441441

442442
@pytest.fixture(scope='module')
443443
def module_enroll_ad_and_configure_external_auth(ad_data, module_target_sat):
444-
module_target_sat.enroll_ad_and_configure_external_auth(ad_data)
444+
return module_target_sat.enroll_ad_and_configure_external_auth(ad_data)
445445

446446

447447
@pytest.fixture
448448
def func_enroll_ad_and_configure_external_auth(ad_data, target_sat):
449-
target_sat.enroll_ad_and_configure_external_auth(ad_data)
449+
return target_sat.enroll_ad_and_configure_external_auth(ad_data)
450450

451451

452452
@pytest.fixture

robottelo/hosts.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,6 +2486,7 @@ def enroll_ad_and_configure_external_auth(self, ad_data):
24862486
24872487
:param ad_data: Callable method that returns AD server details
24882488
:type ad_data: Callable
2489+
:return: New Satellite hostname if hostname changed, otherwise None
24892490
"""
24902491
ad_data = ad_data()
24912492
version_dependent = (
@@ -2529,6 +2530,7 @@ def enroll_ad_and_configure_external_auth(self, ad_data):
25292530
# if this is an IPv6 machine, we'll probably get a hostname
25302531
# that is TOOOO LOOOONG for Active Directory which can only count to 15
25312532
hostname_changed = False
2533+
new_fqdn = None
25322534
if self.network_type == NetworkType.IPV6:
25332535
original_shortname = self.execute('hostname -s').stdout.strip()
25342536
if len(original_shortname) > 15:
@@ -2652,6 +2654,8 @@ def enroll_ad_and_configure_external_auth(self, ad_data):
26522654
self.execute('systemctl daemon-reload && systemctl restart httpd.service').status == 0
26532655
)
26542656

2657+
return new_fqdn
2658+
26552659
def generate_inventory_report(self, org, disconnected='false'):
26562660
"""Function to perform inventory upload."""
26572661
generate_report_task = 'ForemanInventoryUpload::Async::HostInventoryReportJob'

tests/foreman/destructive/test_ldap_authentication.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,16 @@ def test_single_sign_on_ldap_ad_server(
254254
255255
:BZ: 1941997
256256
"""
257+
if func_enroll_ad_and_configure_external_auth is not None:
258+
url = f'{settings.server.scheme}://{func_enroll_ad_and_configure_external_auth}'
259+
else:
260+
url = target_sat.url
257261
# create the kerberos ticket for authentication
258262
result = target_sat.execute(f'echo {settings.ldap.password} | kinit {settings.ldap.username}')
259263
assert result.status == 0
260-
result = target_sat.execute(f'curl -k -u : --negotiate {target_sat.url}/users/extlogin/')
264+
result = target_sat.execute(f'curl -k -u : --negotiate {url}/users/extlogin/')
261265
assert 'redirected' in result.stdout
262-
assert f'{target_sat.url}/new/hosts' in result.stdout
266+
assert f'{url}/new/hosts' in result.stdout
263267

264268

265269
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)