diff --git a/pytest_fixtures/component/activationkey.py b/pytest_fixtures/component/activationkey.py index 9981d60f13d..fa7b53d0189 100644 --- a/pytest_fixtures/component/activationkey.py +++ b/pytest_fixtures/component/activationkey.py @@ -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 diff --git a/tests/foreman/api/test_registration.py b/tests/foreman/api/test_registration.py index f29da4c8e7a..dab85fa6209 100644 --- a/tests/foreman/api/test_registration.py +++ b/tests/foreman/api/test_registration.py @@ -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, @@ -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() @@ -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() @@ -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 @@ -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) @@ -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) @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/tests/foreman/cli/test_registration.py b/tests/foreman/cli/test_registration.py index 50102ae2c0e..25b8c0a2135 100644 --- a/tests/foreman/cli/test_registration.py +++ b/tests/foreman/cli/test_registration.py @@ -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, @@ -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 @@ -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, ) diff --git a/tests/foreman/ui/test_host.py b/tests/foreman/ui/test_host.py index 242e7f6a629..9ea2cd736db 100644 --- a/tests/foreman/ui/test_host.py +++ b/tests/foreman/ui/test_host.py @@ -34,7 +34,6 @@ ANY_CONTEXT, DEFAULT_CV, DEFAULT_LOC, - DEFAULT_SUBSCRIPTION_NAME, ENVIRONMENT, FAKE_1_CUSTOM_PACKAGE, FAKE_7_CUSTOM_PACKAGE, @@ -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, @@ -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, @@ -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 = {