Skip to content

Commit

Permalink
Added SCA enabled manifest in activation key and removed duplicate fi…
Browse files Browse the repository at this point in the history
…xture (#13082)

Using SCA enabled manifest in activation key
  • Loading branch information
shweta83 authored Dec 12, 2023
1 parent 8c2375d commit 257ec7d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 54 deletions.
9 changes: 4 additions & 5 deletions pytest_fixtures/component/activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@


@pytest.fixture(scope='module')
def module_activation_key(module_entitlement_manifest_org, module_target_sat):
def module_activation_key(module_sca_manifest_org, module_target_sat):
"""Create activation key using default CV and library environment."""
activation_key = module_target_sat.api.ActivationKey(
auto_attach=True,
content_view=module_entitlement_manifest_org.default_content_view.id,
environment=module_entitlement_manifest_org.library.id,
organization=module_entitlement_manifest_org,
content_view=module_sca_manifest_org.default_content_view.id,
environment=module_sca_manifest_org.library.id,
organization=module_sca_manifest_org,
).create()
return activation_key

Expand Down
38 changes: 22 additions & 16 deletions tests/foreman/api/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
@pytest.mark.e2e
@pytest.mark.no_containers
def test_host_registration_end_to_end(
module_org,
module_entitlement_manifest_org,
module_location,
module_ak_with_synced_repo,
module_activation_key,
module_target_sat,
module_capsule_configured,
rhel_contenthost,
Expand All @@ -50,9 +50,10 @@ def test_host_registration_end_to_end(
:customerscenario: true
"""
org = module_entitlement_manifest_org
command = module_target_sat.api.RegistrationCommand(
organization=module_org,
activation_keys=[module_ak_with_synced_repo.name],
organization=org,
activation_keys=[module_activation_key.name],
location=module_location,
).create()

Expand All @@ -66,13 +67,13 @@ def test_host_registration_end_to_end(

# Update module_capsule_configured to include module_org/module_location
nc = module_capsule_configured.nailgun_smart_proxy
module_target_sat.api.SmartProxy(id=nc.id, organization=[module_org]).update(['organization'])
module_target_sat.api.SmartProxy(id=nc.id, organization=[org]).update(['organization'])
module_target_sat.api.SmartProxy(id=nc.id, location=[module_location]).update(['location'])

command = module_target_sat.api.RegistrationCommand(
smart_proxy=nc,
organization=module_org,
activation_keys=[module_ak_with_synced_repo.name],
organization=org,
activation_keys=[module_activation_key.name],
location=module_location,
force=True,
).create()
Expand All @@ -92,7 +93,11 @@ def test_host_registration_end_to_end(
@pytest.mark.tier3
@pytest.mark.rhel_ver_match('[^6]')
def test_positive_allow_reregistration_when_dmi_uuid_changed(
module_org, rhel_contenthost, target_sat, module_ak_with_synced_repo, module_location
module_sca_manifest_org,
rhel_contenthost,
target_sat,
module_activation_key,
module_location,
):
"""Register a content host with a custom DMI UUID, unregistering it, change
the DMI UUID, and re-registering it again
Expand All @@ -109,10 +114,11 @@ def test_positive_allow_reregistration_when_dmi_uuid_changed(
"""
uuid_1 = str(uuid.uuid1())
uuid_2 = str(uuid.uuid4())
org = module_sca_manifest_org
target_sat.execute(f'echo \'{{"dmi.system.uuid": "{uuid_1}"}}\' > /etc/rhsm/facts/uuid.facts')
command = target_sat.api.RegistrationCommand(
organization=module_org,
activation_keys=[module_ak_with_synced_repo.name],
organization=org,
activation_keys=[module_activation_key.name],
location=module_location,
).create()
result = rhel_contenthost.execute(command)
Expand All @@ -121,8 +127,8 @@ def test_positive_allow_reregistration_when_dmi_uuid_changed(
assert result.status == 0
target_sat.execute(f'echo \'{{"dmi.system.uuid": "{uuid_2}"}}\' > /etc/rhsm/facts/uuid.facts')
command = target_sat.api.RegistrationCommand(
organization=module_org,
activation_keys=[module_ak_with_synced_repo.name],
organization=org,
activation_keys=[module_activation_key.name],
location=module_location,
).create()
result = rhel_contenthost.execute(command)
Expand All @@ -131,7 +137,7 @@ def test_positive_allow_reregistration_when_dmi_uuid_changed(

def test_positive_update_packages_registration(
module_target_sat,
module_entitlement_manifest_org,
module_sca_manifest_org,
module_location,
rhel8_contenthost,
module_activation_key,
Expand All @@ -144,7 +150,7 @@ def test_positive_update_packages_registration(
:CaseLevel: Component
"""
org = module_entitlement_manifest_org
org = module_sca_manifest_org
command = module_target_sat.api.RegistrationCommand(
organization=org,
location=module_location,
Expand All @@ -164,7 +170,7 @@ def test_positive_update_packages_registration(
@pytest.mark.no_containers
def test_positive_rex_interface_for_global_registration(
module_target_sat,
module_entitlement_manifest_org,
module_sca_manifest_org,
module_location,
rhel8_contenthost,
module_activation_key,
Expand All @@ -188,7 +194,7 @@ def test_positive_rex_interface_for_global_registration(
add_interface_command = f'ip link add eth1 type dummy;ifconfig eth1 hw ether {mac_address};ip addr add {ip}/24 brd + dev eth1 label eth1:1;ip link set dev eth1 up'
result = rhel8_contenthost.execute(add_interface_command)
assert result.status == 0
org = module_entitlement_manifest_org
org = module_sca_manifest_org
command = module_target_sat.api.RegistrationCommand(
organization=org,
location=module_location,
Expand Down
13 changes: 7 additions & 6 deletions tests/foreman/cli/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
@pytest.mark.e2e
@pytest.mark.no_containers
def test_host_registration_end_to_end(
module_org,
module_entitlement_manifest_org,
module_location,
module_ak_with_synced_repo,
module_activation_key,
module_target_sat,
module_capsule_configured,
rhel_contenthost,
Expand All @@ -47,8 +47,9 @@ def test_host_registration_end_to_end(
:customerscenario: true
"""
org = module_entitlement_manifest_org
result = rhel_contenthost.register(
module_org, module_location, module_ak_with_synced_repo.name, module_target_sat
org, module_location, [module_activation_key.name], module_target_sat
)

rc = 1 if rhel_contenthost.os_version.major == 6 else 0
Expand All @@ -62,14 +63,14 @@ def test_host_registration_end_to_end(
module_target_sat.cli.Capsule.update(
{
'name': module_capsule_configured.hostname,
'organization-ids': module_org.id,
'organization-ids': org.id,
'location-ids': module_location.id,
}
)
result = rhel_contenthost.register(
module_org,
org,
module_location,
module_ak_with_synced_repo.name,
[module_activation_key.name],
module_capsule_configured,
force=True,
)
Expand Down
29 changes: 2 additions & 27 deletions tests/foreman/ui/test_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
ANY_CONTEXT,
DEFAULT_CV,
DEFAULT_LOC,
DEFAULT_SUBSCRIPTION_NAME,
ENVIRONMENT,
FAKE_1_CUSTOM_PACKAGE,
FAKE_7_CUSTOM_PACKAGE,
Expand Down Expand Up @@ -97,30 +96,6 @@ def module_global_params(module_target_sat):
global_parameter.delete()


@pytest.fixture(scope='module')
def module_activation_key(module_entitlement_manifest_org, module_target_sat):
"""Create activation key using default CV and library environment."""
activation_key = module_target_sat.api.ActivationKey(
auto_attach=True,
content_view=module_entitlement_manifest_org.default_content_view.id,
environment=module_entitlement_manifest_org.library.id,
organization=module_entitlement_manifest_org,
).create()

# Find the 'Red Hat Employee Subscription' and attach it to the activation key.
for subs in module_target_sat.api.Subscription(
organization=module_entitlement_manifest_org
).search():
if subs.name == DEFAULT_SUBSCRIPTION_NAME:
# 'quantity' must be 1, not subscription['quantity']. Greater
# values produce this error: 'RuntimeError: Error: Only pools
# with multi-entitlement product subscriptions can be added to
# the activation key with a quantity greater than one.'
activation_key.add_subscriptions(data={'quantity': 1, 'subscription_id': subs.id})
break
return activation_key


@pytest.fixture
def tracer_install_host(rex_contenthost, target_sat):
"""Sets up a contenthost with katello-host-tools-tracer enabled,
Expand Down Expand Up @@ -2421,7 +2396,7 @@ def test_positive_tracer_enable_reload(tracer_install_host, target_sat):

def test_positive_host_registration_with_non_admin_user(
test_name,
module_entitlement_manifest_org,
module_sca_manifest_org,
module_location,
target_sat,
rhel8_contenthost,
Expand All @@ -2437,7 +2412,7 @@ def test_positive_host_registration_with_non_admin_user(
:CaseLevel: Component
"""
user_password = gen_string('alpha')
org = module_entitlement_manifest_org
org = module_sca_manifest_org
role = target_sat.api.Role(organization=[org]).create()

user_permissions = {
Expand Down

0 comments on commit 257ec7d

Please sign in to comment.