diff --git a/tests/foreman/cli/test_activationkey.py b/tests/foreman/cli/test_activationkey.py index 2910395d32..7a4c9cb24e 100644 --- a/tests/foreman/cli/test_activationkey.py +++ b/tests/foreman/cli/test_activationkey.py @@ -1581,3 +1581,63 @@ def test_positive_invalid_release_version(module_sca_manifest_org, module_target } ) assert update_ak[0]['message'] == 'Activation key updated.' + + +# -------------------------- MULTI-CV SCENARIOS ------------------------- +def test_positive_multi_cv_info( + session_multicv_sat, session_multicv_org, session_multicv_default_ak +): + """Verify that multi-env AK display into hammer activation-key info commands output + + :id: 6a1c3189-74f9-4a54-8579-f3b045870cd9 + + :steps: + 1. Create two lifecycle environments and two content views, publish/promote to respective lce + 2. Create activation key and update ak with multiple content view environments + 3. Check ak info displays 'Multi Content View Environment' and 'Content View Environments' + + :expectedresults: AK info displays 'Multi Content View Environment' and 'Content View Environments' + + :CaseImportance: Medium + + :CaseComponent: ActivationKeys + + :team: Phoenix-subscriptions + + :parametrized: No + """ + # Create two lifecycle environments + lce1 = session_multicv_sat.api.LifecycleEnvironment(organization=session_multicv_org).create() + lce2 = session_multicv_sat.api.LifecycleEnvironment(organization=session_multicv_org).create() + + # Create two content views + cv1 = session_multicv_sat.api.ContentView(organization=session_multicv_org).create() + cv1.publish() + cv1 = cv1.read() + cv1.version[0].promote(data={'environment_ids': lce1.id}) + + cv2 = session_multicv_sat.api.ContentView(organization=session_multicv_org).create() + cv2.publish() + cv2 = cv2.read() + cv2.version[0].promote(data={'environment_ids': lce2.id}) + + # Update ak with multiple content view environments + ak = session_multicv_default_ak + cv_envs = f'{lce1.name}/{cv1.name},{lce2.name}/{cv2.name}' + ak_info = session_multicv_sat.cli.ActivationKey.info({'id': ak.id}) + assert ak_info['multi-content-view-environment'] == 'no' + assert ak_info['content-view-environment-labels'] == 'Library' + + ret_val = session_multicv_sat.cli.ActivationKey.update( + { + 'id': ak.id, + 'organization-id': session_multicv_org.id, + 'content-view-environments': cv_envs, + } + ) + assert ret_val[0]['message'] == 'Activation key updated.' + + # Verify ak info displays 'Multi Content View Environment' and 'Content View Environments' + ak_info = session_multicv_sat.cli.ActivationKey.info({'id': ak.id}) + assert ak_info['multi-content-view-environment'] == 'yes' + assert ak_info['content-view-environment-labels'] == cv_envs