Skip to content

Commit

Permalink
Fixing UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ColeHiggins2 committed Apr 22, 2024
1 parent 82b8426 commit 2a777d3
Showing 1 changed file with 35 additions and 121 deletions.
156 changes: 35 additions & 121 deletions tests/foreman/ui/test_activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_positive_end_to_end_crud(session, module_org, module_target_sat):
)
def test_positive_end_to_end_register(
session,
function_entitlement_manifest_org,
function_sca_manifest_org,
default_location,
repos_collection,
rhel7_contenthost,
Expand All @@ -86,7 +86,7 @@ def test_positive_end_to_end_register(
:CaseImportance: High
"""
org = function_entitlement_manifest_org
org = function_sca_manifest_org
lce = target_sat.api.LifecycleEnvironment(organization=org).create()
repos_collection.setup_content(org.id, lce.id, upload_manifest=False)
ak_name = repos_collection.setup_content_data['activation_key']['name']
Expand Down Expand Up @@ -398,7 +398,7 @@ def test_positive_update_cv(session, module_org, cv2_name, target_sat):

@pytest.mark.run_in_one_thread
@pytest.mark.tier2
def test_positive_update_rh_product(function_entitlement_manifest_org, session, target_sat):
def test_positive_update_rh_product(function_sca_manifest_org, session, target_sat):
"""Update Content View in an Activation key
:id: 9b0ac209-45de-4cc4-97e8-e191f3f37239
Expand Down Expand Up @@ -430,7 +430,7 @@ def test_positive_update_rh_product(function_entitlement_manifest_org, session,
'basearch': 'i386',
'releasever': constants.DEFAULT_RELEASE_VERSION,
}
org = function_entitlement_manifest_org
org = function_sca_manifest_org
repo1_id = target_sat.api_factory.enable_sync_redhat_repo(rh_repo1, org.id)
target_sat.api_factory.cv_publish_promote(cv1_name, env1_name, repo1_id, org.id)
repo2_id = target_sat.api_factory.enable_sync_redhat_repo(rh_repo2, org.id)
Expand All @@ -452,7 +452,7 @@ def test_positive_update_rh_product(function_entitlement_manifest_org, session,

@pytest.mark.run_in_one_thread
@pytest.mark.tier2
def test_positive_add_rh_product(function_entitlement_manifest_org, session, target_sat):
def test_positive_add_rh_product(function_sca_manifest_org, session, target_sat):
"""Test that RH product can be associated to Activation Keys
:id: d805341b-6d2f-4e16-8cb4-902de00b9a6c
Expand All @@ -469,7 +469,7 @@ def test_positive_add_rh_product(function_entitlement_manifest_org, session, tar
'basearch': constants.DEFAULT_ARCHITECTURE,
'releasever': constants.DEFAULT_RELEASE_VERSION,
}
org = function_entitlement_manifest_org
org = function_sca_manifest_org
# Helper function to create and promote CV to next environment
repo_id = target_sat.api_factory.enable_sync_redhat_repo(rh_repo, org.id)
target_sat.api_factory.cv_publish_promote(cv_name, env_name, repo_id, org.id)
Expand All @@ -479,10 +479,10 @@ def test_positive_add_rh_product(function_entitlement_manifest_org, session, tar
{'name': name, 'lce': {env_name: True}, 'content_view': cv_name}
)
assert session.activationkey.search(name)[0]['Name'] == name
session.activationkey.add_subscription(name, constants.DEFAULT_SUBSCRIPTION_NAME)
ak = session.activationkey.read(name, widget_names='subscriptions')
subs_name = ak['subscriptions']['resources']['assigned'][0]['Repository Name']
assert subs_name == constants.DEFAULT_SUBSCRIPTION_NAME
ak = session.activationkey.read(name, widget_names='repository sets')['repository sets'][
'table'
][0]
assert rh_repo['reposet'] == ak['Repository Name']


@pytest.mark.tier2
Expand All @@ -508,18 +508,16 @@ def test_positive_add_custom_product(session, module_org, target_sat):
{'name': name, 'lce': {env_name: True}, 'content_view': cv_name}
)
assert session.activationkey.search(name)[0]['Name'] == name
session.activationkey.add_subscription(name, product_name)
ak = session.activationkey.read(name, widget_names='subscriptions')
assigned_prod = ak['subscriptions']['resources']['assigned'][0]['Repository Name']
assert assigned_prod == product_name
ak = session.activationkey.read(name, widget_names='repository sets')['repository sets'][
'table'
][0]
assert product_name == ak['Product Name']


@pytest.mark.run_in_one_thread
@pytest.mark.tier2
@pytest.mark.upgrade
def test_positive_add_rh_and_custom_products(
target_sat, function_entitlement_manifest_org, session
):
def test_positive_add_rh_and_custom_products(target_sat, function_sca_manifest_org, session):
"""Test that RH/Custom product can be associated to Activation keys
:id: 3d8876fa-1412-47ca-a7a4-bce2e8baf3bc
Expand All @@ -542,7 +540,7 @@ def test_positive_add_rh_and_custom_products(
}
custom_product_name = gen_string('alpha')
repo_name = gen_string('alpha')
org = function_entitlement_manifest_org
org = function_sca_manifest_org
product = target_sat.api.Product(name=custom_product_name, organization=org).create()
repo = target_sat.api.Repository(name=repo_name, product=product).create()
rhel_repo_id = target_sat.api_factory.enable_rhrepo_and_fetchid(
Expand All @@ -565,20 +563,15 @@ def test_positive_add_rh_and_custom_products(
}
)
assert session.activationkey.search(name)[0]['Name'] == name
for subscription in (constants.DEFAULT_SUBSCRIPTION_NAME, custom_product_name):
session.activationkey.add_subscription(name, subscription)
ak = session.activationkey.read(name, widget_names='subscriptions')
subscriptions = [
subscription['Repository Name']
for subscription in ak['subscriptions']['resources']['assigned']
]
assert {constants.DEFAULT_SUBSCRIPTION_NAME, custom_product_name} == set(subscriptions)
ak = session.activationkey.read(name, widget_names='repository sets')
reposets = [reposet['Repository Name'] for reposet in ak['repository sets']['table']]
assert {repo_name, constants.REPOSET['rhva6']} == set(reposets)


@pytest.mark.run_in_one_thread
@pytest.mark.tier2
@pytest.mark.upgrade
def test_positive_fetch_product_content(target_sat, function_entitlement_manifest_org, session):
def test_positive_fetch_product_content(target_sat, function_sca_manifest_org, session):
"""Associate RH & custom product with AK and fetch AK's product content
:id: 4c37fb12-ea2a-404e-b7cc-a2735e8dedb6
Expand All @@ -588,7 +581,8 @@ def test_positive_fetch_product_content(target_sat, function_entitlement_manifes
:BZ: 1426386, 1432285
"""
org = function_entitlement_manifest_org
org = function_sca_manifest_org
lce = target_sat.api.LifecycleEnvironment(organization=org).create()
rh_repo_id = target_sat.api_factory.enable_rhrepo_and_fetchid(
basearch='x86_64',
org_id=org.id,
Expand All @@ -611,11 +605,11 @@ def test_positive_fetch_product_content(target_sat, function_entitlement_manifes
organization=org, repository=[rh_repo_id, custom_repo.id]
).create()
cv.publish()
ak = target_sat.api.ActivationKey(content_view=cv, organization=org).create()
cvv = cv.read().version[0].read()
cvv.promote(data={'environment_ids': lce.id, 'force': True})
ak = target_sat.api.ActivationKey(content_view=cv, organization=org, environment=lce).create()
with session:
session.organization.select(org.name)
for subscription in (constants.DEFAULT_SUBSCRIPTION_NAME, custom_product.name):
session.activationkey.add_subscription(ak.name, subscription)
ak = session.activationkey.read(ak.name, widget_names='repository_sets')
reposets = [reposet['Repository Name'] for reposet in ak['repository_sets']['table']]
assert {custom_repo.name, constants.REPOSET['rhst7']} == set(reposets)
Expand Down Expand Up @@ -883,7 +877,6 @@ def test_positive_delete_with_system(session, rhel6_contenthost, target_sat):
{'name': name, 'lce': {env_name: True}, 'content_view': cv_name}
)
assert session.activationkey.search(name)[0]['Name'] == name
session.activationkey.add_subscription(name, product_name)
rhel6_contenthost.install_katello_ca(target_sat)
rhel6_contenthost.register_contenthost(org.label, name)
assert rhel6_contenthost.subscribed
Expand Down Expand Up @@ -967,17 +960,13 @@ def test_positive_add_multiple_aks_to_system(session, module_org, rhel6_contenth
{'name': key_name, 'lce': {env_name: True}, 'content_view': cv_name}
)
assert session.activationkey.search(key_name)[0]['Name'] == key_name
session.activationkey.add_subscription(key_name, product_name)
ak = session.activationkey.read(key_name, widget_names='subscriptions')
subscriptions = [
subscription['Repository Name']
for subscription in ak['subscriptions']['resources']['assigned']
]
assert product_name in subscriptions
ak = session.activationkey.read(key_name, widget_names='repository sets')[
'repository sets'
]['table'][0]
assert product_name == ak['Product Name']
# Create VM
rhel6_contenthost.install_katello_ca(target_sat)
rhel6_contenthost.register_contenthost(module_org.label, ','.join([key_1_name, key_2_name]))
assert rhel6_contenthost.subscribed
# Assert the content-host association with activation keys
for key_name in [key_1_name, key_2_name]:
ak = session.activationkey.read(key_name, widget_names='content_hosts')
Expand Down Expand Up @@ -1035,7 +1024,7 @@ def test_positive_host_associations(session, target_sat):
@pytest.mark.tier3
@pytest.mark.skipif((not settings.robottelo.repos_hosting_url), reason='Missing repos_hosting_url')
def test_positive_service_level_subscription_with_custom_product(
session, function_entitlement_manifest_org, rhel7_contenthost, target_sat
session, function_sca_manifest_org, rhel7_contenthost, target_sat
):
"""Subscribe a host to activation key with Premium service level and with
custom product
Expand Down Expand Up @@ -1064,81 +1053,25 @@ def test_positive_service_level_subscription_with_custom_product(
:parametrized: yes
"""
org = function_entitlement_manifest_org
org = function_sca_manifest_org
entities_ids = target_sat.cli_factory.setup_org_for_a_custom_repo(
{'url': settings.repos.yum_1.url, 'organization-id': org.id}
)
product = target_sat.api.Product(id=entities_ids['product-id']).read()
activation_key = target_sat.api.ActivationKey(id=entities_ids['activationkey-id']).read()
# add the default RH subscription
subscription = target_sat.api.Subscription(organization=org).search(
query={'search': f'name="{constants.DEFAULT_SUBSCRIPTION_NAME}"'}
)[0]
activation_key.add_subscriptions(data={'quantity': 1, 'subscription_id': subscription.id})
# ensure all the needed subscriptions are attached to activation key
results = activation_key.subscriptions()['results']
assert {product.name, constants.DEFAULT_SUBSCRIPTION_NAME} == {
ak_subscription['name'] for ak_subscription in results
}
# Set the activation service_level to Premium
activation_key.service_level = 'Premium'
activation_key = activation_key.update(['service_level'])

rhel7_contenthost.install_katello_ca(target_sat)
rhel7_contenthost.register_contenthost(org.label, activation_key=activation_key.name)
assert rhel7_contenthost.subscribed
result = rhel7_contenthost.run('subscription-manager list --consumed')
assert result.status == 0
assert f'Subscription Name: {product.name}' in result.stdout
with session:
session.organization.select(org.name)
chost = session.contenthost.read(rhel7_contenthost.hostname, widget_names='subscriptions')
subscriptions = {
subs['Repository Name'] for subs in chost['subscriptions']['resources']['assigned']
}
assert product.name in subscriptions


@pytest.mark.run_in_one_thread
@pytest.mark.tier2
def test_positive_delete_manifest(session, function_entitlement_manifest_org, target_sat):
"""Check if deleting a manifest removes it from Activation key
:id: 512d8e41-b937-451e-a9c6-840457d3d7d4
:steps:
1. Create Activation key
2. Associate a manifest to the Activation Key
3. Delete the manifest
:expectedresults: Deleting a manifest removes it from the Activation
key
"""
org = function_entitlement_manifest_org
# Create activation key
activation_key = target_sat.api.ActivationKey(organization=org).create()
# Associate a manifest to the activation key
subscription = target_sat.api.Subscription(organization=org).search(
query={'search': f'name="{constants.DEFAULT_SUBSCRIPTION_NAME}"'}
)[0]
activation_key.add_subscriptions(data={'quantity': 1, 'subscription_id': subscription.id})
with session:
session.organization.select(org.name)
# Verify subscription is assigned to activation key
ak = session.activationkey.read(activation_key.name, widget_names='subscriptions')
assert (
ak['subscriptions']['resources']['assigned'][0]['Repository Name']
== constants.DEFAULT_SUBSCRIPTION_NAME
session.location.select(constants.DEFAULT_LOC)
chost = session.host_new.get_details(
rhel7_contenthost.hostname, widget_names='content.repository_sets'
)
# Delete the manifest
# Ignore "404 Not Found" as server will connect to upstream subscription service to verify
# the consumer uuid, that will be displayed in flash error messages
# Note: this happen only when using clone manifest.
session.subscription.delete_manifest(ignore_error_messages='404 Not Found')
assert not session.subscription.has_manifest
# Verify subscription is not assigned to activation key anymore
ak = session.activationkey.read(activation_key.name, widget_names='subscriptions')
assert not ak['subscriptions']['resources']['assigned']
assert product.name == chost['content']['repository_sets']['table'][0]['Product']


@pytest.mark.skip_if_not_set('clients')
Expand Down Expand Up @@ -1175,22 +1108,3 @@ def test_positive_ak_with_custom_product_on_rhel6(session, rhel6_contenthost, ta
ak = session.activationkey.read(ak.name, widget_names='content_hosts')
assert len(ak['content_hosts']['table']) == 1
assert ak['content_hosts']['table'][0]['Name'] == rhel6_contenthost.hostname


def test_positive_prepare_for_sca_only_ak(target_sat, function_entitlement_manifest_org):
"""Verify that the ActivationKey details page notifies users that Simple Content Access
will be required for all organizations in Satellite 6.16
:id: 417a8331-3c66-473f-938c-bbf01deb6031
:expectedresults: The ActivationKey page notifies users that Simple Content Access will
be required for all organizations in Satellite 6.16
"""
ak = target_sat.api.ActivationKey(organization=function_entitlement_manifest_org).create()
with target_sat.ui_session() as session:
session.organization.select(function_entitlement_manifest_org.name)
ak = session.activationkey.read(ak.name)
assert (
'This organization is not using Simple Content Access. Entitlement-based subscription '
'management is deprecated and will be removed in Satellite 6.16.' in ak['sca_alert']
)

0 comments on commit 2a777d3

Please sign in to comment.