From 312ffc2e0508d6f91154f82aa5dae571170d8eff Mon Sep 17 00:00:00 2001 From: Peter Ondrejka Date: Fri, 18 Nov 2022 13:37:59 +0100 Subject: [PATCH] fix in alternate directory rex test --- robottelo/hosts.py | 5 ++++- .../destructive/test_remoteexecution.py | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/robottelo/hosts.py b/robottelo/hosts.py index 3928490112b..cc824478f10 100644 --- a/robottelo/hosts.py +++ b/robottelo/hosts.py @@ -524,6 +524,7 @@ def register( insecure=True, username=settings.server.admin_username, password=settings.server.admin_password, + port='9090', ): """Registers content host to the Satellite or Capsule server using a global registration template. @@ -548,6 +549,7 @@ def register( :param insecure: Don't verify server authenticity. :param username: Satellite admin username :param password: Satellite admin password + :param port: Capsule port, if unset template is pulled straight from Satellite :return: SSHCommandResult instance filled with the result of the registration. """ @@ -586,11 +588,12 @@ def register( if repo_gpg_key_url is not None else '' ) + port = f':{port}' if port is not None else '' cmd = ( 'curl -sS ' f'-u {username}:{password} ' f'{"--insecure " if insecure else ""}' - f"'https://{target.hostname}:9090/register?" + f"'https://{target.hostname}{port}/register?" f'activation_keys={activation_keys}' f'&organization_id={org.id}' f'&location_id={loc.id}' diff --git a/tests/foreman/destructive/test_remoteexecution.py b/tests/foreman/destructive/test_remoteexecution.py index 921abb3d02e..cb5ccd1e175 100644 --- a/tests/foreman/destructive/test_remoteexecution.py +++ b/tests/foreman/destructive/test_remoteexecution.py @@ -78,8 +78,11 @@ def test_negative_run_capsule_upgrade_playbook_on_satellite(target_sat): assert 'This playbook cannot be executed on a Satellite server.' in response.text -@pytest.mark.rhel_ver_list([7]) -def test_positive_use_alternate_directory(rex_contenthost, target_sat): +@pytest.mark.no_containers +@pytest.mark.rhel_ver_list([8]) +def test_positive_use_alternate_directory( + rhel_contenthost, target_sat, default_org, default_location +): """Use alternate working directory on client to execute rex jobs :id: a0181f18-d3dc-4bd9-a2a6-430c2a49809e @@ -90,7 +93,17 @@ def test_positive_use_alternate_directory(rex_contenthost, target_sat): :parametrized: yes """ - client = rex_contenthost + client = rhel_contenthost + ak = target_sat.cli_factory.make_activation_key( + { + 'lifecycle-environment': 'Library', + 'content-view': 'Default Organization View', + 'organization-id': default_org.id, + 'auto-attach': False, + } + ) + result = client.register(target_sat, default_org, default_location, ak.name, port=None) + assert result.status == 0, f'Failed to register host: {result.stderr}' testdir = gen_string('alpha') result = client.run(f'mkdir /{testdir}') assert result.status == 0