From 7fe4f18003c1ceacf9d2fdc3b49557440ec6d475 Mon Sep 17 00:00:00 2001 From: shwsingh Date: Tue, 2 Jan 2024 12:13:34 +0530 Subject: [PATCH] Test capsule without registration module --- tests/foreman/api/test_registration.py | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/foreman/api/test_registration.py b/tests/foreman/api/test_registration.py index 77fd856db11..c05160e9c3e 100644 --- a/tests/foreman/api/test_registration.py +++ b/tests/foreman/api/test_registration.py @@ -227,3 +227,43 @@ def test_negative_global_registration_without_ak(module_target_sat): with pytest.raises(HTTPError) as context: module_target_sat.api.RegistrationCommand().create() assert 'Missing activation key!' in context.value.response.text + + +def test_positive_capsule_without_registration_module( + module_target_sat, + module_capsule_configured, + module_ak_with_cv, + rhel8_contenthost, + module_entitlement_manifest_org, + module_location, +): + """Test a capsule without registration module + + :id: a2f23e42-648d-4428-a961-6e0b933c6dff + + :steps: + + 1. Get a configured capsule + 2. The registration is set to False on capsule by default + 3. Try to register host with that capsule + + :expectedresults: Registration fails with HTTP error code 422 and an error message. + """ + org = module_entitlement_manifest_org + module_target_sat.api.SmartProxy().search( + query={'search': f'name = {module_capsule_configured.hostname}'} + )[0] + + nc = module_capsule_configured.nailgun_smart_proxy + 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']) + + with pytest.raises(HTTPError): + module_target_sat.api.RegistrationCommand( + smart_proxy=nc, + organization=org, + location=module_location, + activation_keys=[module_ak_with_cv.name], + insecure=True, + force=True, + ).create()