Skip to content

Commit

Permalink
Test for candlepin testing in sca only
Browse files Browse the repository at this point in the history
  • Loading branch information
ColeHiggins2 committed Mar 21, 2024
1 parent b05da4e commit e396869
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions tests/upgrades/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,84 @@ def test_post_subscription_scenario_auto_attach(self, request, target_sat, pre_u
manifester = Manifester(manifest_category=settings.manifest.entitlement)
request.addfinalizer(manifester.delete_subscription_allocation)
manifester.allocation_uuid = pre_upgrade_data.allocation_uuid

@pytest.mark.rhel_ver_list([7, 8, 9])
@pytest.mark.no_containers
@pytest.mark.pre_upgrade
def test_pre_sca_only(
self,
target_sat,
save_test_data,
rhel_contenthost,
upgrade_entitlement_manifest_org,
upgrade_entitlement_manifest,
):
""" """
_, manifester = upgrade_entitlement_manifest
org = upgrade_entitlement_manifest_org
rhel_contenthost._skip_context_checkin = True
lce = target_sat.api.LifecycleEnvironment(organization=org).create()
product = target_sat.api.Product(organization=org).create()
custom_repo = target_sat.api.Repository(
content_type='yum', product=product, url=settings.repos.module_stream_1.url
).create()
custom_repo.sync()
if rhel_contenthost.os_version.major > 7:
rh_repo_id = target_sat.api_factory.enable_sync_redhat_repo(
constants.REPOS[f'rhel{rhel_contenthost.os_version.major}_bos'], org.id
)
else:
rh_repo_id = target_sat.api_factory.enable_sync_redhat_repo(
constants.REPOS[f'rhel{rhel_contenthost.os_version.major}'], org.id
)
rh_repo = target_sat.api.Repository(id=rh_repo_id).read()
assert rh_repo.content_counts['rpm'] >= 1
repo_list = [custom_repo, rh_repo]
content_view = target_sat.publish_content_view(org, repo_list)
content_view.version[-1].promote(data={'environment_ids': lce.id})
subscription = target_sat.api.Subscription(organization=org.id).search(
query={'search': f'name="{constants.DEFAULT_SUBSCRIPTION_NAME}"'}
)
assert len(subscription)
activation_key = target_sat.api.ActivationKey(
content_view=content_view,
organization=org,
environment=lce,
).create()
all_content = activation_key.product_content(data={'content_access_mode_all': '1'})[
'results'
]
for content in all_content:
if content['name'] == custom_repo.name:
custom_content_label = content['label']
if content['repositories'][0]['id'] == rh_repo_id:
rh_content_label = content['label']
activation_key.content_override(
data={'content_overrides': [{'content_label': custom_content_label, 'value': '1'}]}
)
rhel_contenthost.install_katello_ca(target_sat)
rhel_contenthost.register_contenthost(org=org.name, activation_key=activation_key.name)
enabled = rhel_contenthost.execute("subscription-manager repos --list-enabled")
assert rh_content_label in enabled.stdout
sca_access = target_sat.execute(
f'echo "Organization.find({org.id}).simple_content_access?" | foreman-rake console'
)
assert 'false' in sca_access.stdout
sca_mode = target_sat.execute(
f'echo "Organization.find({org.id}).content_access_mode" | foreman-rake console'
)
assert 'entitlement' in sca_mode.stdout
sca_list = target_sat.execute(
f'echo "Organization.find({org.id}).content_access_mode_list" | foreman-rake console'
)
assert 'entitlement' in sca_list.stdout
assert rhel_contenthost.subscribed
save_test_data(
{
'rhel_client': rhel_contenthost.hostname,
'org_id': org.id,
'activation_key': activation_key.name,
'rh_repo': rh_repo.name,
'custom_repo': custom_repo.name,
}
)

0 comments on commit e396869

Please sign in to comment.