Skip to content

Commit

Permalink
Fix registration test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
shweta83 committed Nov 14, 2023
1 parent 06911ae commit a2ac54d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
10 changes: 8 additions & 2 deletions pytest_fixtures/component/activationkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
30 changes: 18 additions & 12 deletions tests/foreman/api/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()

Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
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

0 comments on commit a2ac54d

Please sign in to comment.