Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AK for errata CLI tests #16742

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pytest_fixtures/component/activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ def function_activation_key(function_sca_manifest_org, target_sat):


@pytest.fixture(scope='module')
def module_ak(module_lce, module_org, module_target_sat):
def module_ak(module_org, module_target_sat):
return module_target_sat.api.ActivationKey(
environment=module_lce,
organization=module_org,
).create()

Expand Down
8 changes: 5 additions & 3 deletions robottelo/host_helpers/api_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,19 +608,21 @@ def register_host_and_needed_setup(
# updated entities after promoting
entities = {k: v.read() for k, v in entities.items()}

updates = []
if ( # assign env to ak if not present
entities['ActivationKey'].environment is None
or entities['ActivationKey'].environment.id != entities['LifecycleEnvironment'].id
):
entities['ActivationKey'].environment = entities['LifecycleEnvironment']
entities['ActivationKey'].update(['environment'])
entities = {k: v.read() for k, v in entities.items()}
updates.append('environment')
if ( # assign cv to ak if not present
entities['ActivationKey'].content_view is None
or entities['ActivationKey'].content_view.id != entities['ContentView'].id
):
entities['ActivationKey'].content_view = entities['ContentView']
entities['ActivationKey'].update(['content_view'])
updates.append('content_view')
if updates:
entities['ActivationKey'].update(['content_view', 'environment']) # both needed anyway

entities = {k: v.read() for k, v in entities.items()}
if enable_repos:
Expand Down
14 changes: 12 additions & 2 deletions robottelo/host_helpers/cli_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,12 @@ def setup_org_for_a_custom_repo(self, options=None):
# Associate activation key with CV just to be sure
try:
self._satellite.cli.ActivationKey.update(
{'content-view-id': cv_id, 'id': activationkey_id, 'organization-id': org_id}
{
'id': activationkey_id,
'organization-id': org_id,
'content-view-id': cv_id,
'lifecycle-environment-id': env_id,
}
)
except CLIReturnCodeError as err:
raise CLIFactoryError(
Expand Down Expand Up @@ -818,7 +823,12 @@ def _setup_org_for_a_rh_repo(self, options=None, force=False):
# Associate activation key with CV just to be sure
try:
self._satellite.cli.ActivationKey.update(
{'id': activationkey_id, 'organization-id': org_id, 'content-view-id': cv_id}
{
'id': activationkey_id,
'organization-id': org_id,
'content-view-id': cv_id,
'lifecycle-environment-id': env_id,
}
)
except CLIReturnCodeError as err:
raise CLIFactoryError(
Expand Down
1 change: 1 addition & 0 deletions tests/foreman/cli/test_errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,7 @@ def new_module_ak(
):
new_module_ak = module_target_sat.api.ActivationKey(
environment=module_lce_library,
content_view=module_sca_manifest_org.default_content_view,
organization=module_sca_manifest_org,
).create()
# Ensure tools repo is enabled in the activation key
Expand Down