diff --git a/pytest_fixtures/component/activationkey.py b/pytest_fixtures/component/activationkey.py index 05c479c65b7..89cdd638053 100644 --- a/pytest_fixtures/component/activationkey.py +++ b/pytest_fixtures/component/activationkey.py @@ -6,8 +6,14 @@ @pytest.fixture(scope='module') -def module_activation_key(module_org, module_target_sat): - return module_target_sat.api.ActivationKey(organization=module_org).create() +def module_activation_key(module_entitlement_manifest_org, module_target_sat): + 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() + return activation_key @pytest.fixture(scope='module') diff --git a/tests/foreman/api/test_registration.py b/tests/foreman/api/test_registration.py index d9267bb5d2f..4279eb76e88 100644 --- a/tests/foreman/api/test_registration.py +++ b/tests/foreman/api/test_registration.py @@ -28,9 +28,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, @@ -48,9 +48,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() @@ -64,13 +65,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() @@ -90,7 +91,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_entitlement_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 @@ -107,10 +112,11 @@ def test_positive_allow_reregistration_when_dmi_uuid_changed( """ uuid_1 = str(uuid.uuid1()) uuid_2 = str(uuid.uuid4()) + org = module_entitlement_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) @@ -119,8 +125,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) 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, )