From 7548d599c297c149d969a94cca2b564ded537fc6 Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Mon, 3 Jun 2024 02:53:05 -0500 Subject: [PATCH] add test for customer case bz --- tests/foreman/ui/test_contentview.py | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/foreman/ui/test_contentview.py b/tests/foreman/ui/test_contentview.py index 0d203fc7707..a3b191c5149 100644 --- a/tests/foreman/ui/test_contentview.py +++ b/tests/foreman/ui/test_contentview.py @@ -14,6 +14,10 @@ from fauxfactory import gen_string import pytest +from widgetastic_patternfly4.dropdown import DropdownItemDisabled + +from robottelo.constants import REPOS +from robottelo.exceptions import CLIReturnCodeError @pytest.mark.tier2 @@ -65,3 +69,51 @@ def test_no_blank_page_on_language_switch(session, target_sat, module_org): with target_sat.ui_session(user=user.login, password=user_password) as session: session.user.update(user.login, {'user.language': 'Français'}) assert session.contentview_new.read_french_lang_cv() + + +def test_republish_metadata(session, function_sca_manifest_org, target_sat): + """Verify that you can't republish metadata from the UI, and you can from the CLI + :id: 96ef4fe5-dec4-4919-aa4d-b8806d90b654 + :steps: + 1. Enable and Sync RH Repo + 2. Add repo to a CV + 3. Publish the CV + 4. Navigate to the published Version's page + 5. Verify that you can't click the "republish metadata" option from the UI + 6. Verify that you can't republish metadata from the cli without the force option + 7. Verify that you can republish metadata from the CLI using the --force option + :expectedresults: You can't republish RH Repo metadata from the UI, and can from the CLI with --force + :CaseImportance: Critical + :BZ: 2227271 + :customerscenario: true + """ + rh_repo_id = target_sat.api_factory.enable_sync_redhat_repo( + REPOS['rhae2.9_el8'], function_sca_manifest_org.id + ) + rh_repo = target_sat.api.Repository(id=rh_repo_id).read() + cv = target_sat.api.ContentView(organization=function_sca_manifest_org).create() + cv = target_sat.api.ContentView(id=cv.id, repository=[rh_repo]).update(["repository"]) + cv.publish() + version = cv.read().version[0].read() + with target_sat.ui_session() as session: + session.organization.select(org_name=function_sca_manifest_org.name) + with pytest.raises(DropdownItemDisabled) as error: + session.contentview_new.click_version_dropdown( + cv.name, 'Version 1.0', "Republish repository metadata" + ) + assert ( + 'Item "Republish repository metadata" of dropdown ".//div[@data-ouia-component-id="cv-version-header-actions-dropdown"]" is disabled' + in error.value.args[0] + ) + with pytest.raises(CLIReturnCodeError) as error: + target_sat.cli.ContentView.version_republish_repositories( + {'id': version.id, 'force': 'false'} + ) + assert ( + 'Could not republish the Content View:\n Metadata republishing is dangerous on content view versions with repositories with the \'Complete Mirroring\' mirroring policy.' + in error.value.stderr + ) + # This returns '' when successful, so this is just run to test that it doesn't throw any errors. + target_sat.cli.ContentView.version_republish_repositories( + {'id': version.id, 'force': 'true'} + )