From 7548d599c297c149d969a94cca2b564ded537fc6 Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Mon, 3 Jun 2024 02:53:05 -0500 Subject: [PATCH 1/3] 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'} + ) From 3c516547ff9ac1c64fad74c3146f7e969bb8b440 Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Wed, 3 Jul 2024 08:25:37 -0500 Subject: [PATCH 2/3] Rework test to not use any airgun/locator logic --- tests/foreman/ui/test_contentview.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/tests/foreman/ui/test_contentview.py b/tests/foreman/ui/test_contentview.py index 8f04ff54bf1..b7b7b60d6e9 100644 --- a/tests/foreman/ui/test_contentview.py +++ b/tests/foreman/ui/test_contentview.py @@ -14,12 +14,9 @@ from fauxfactory import gen_string import pytest -from widgetastic_patternfly4.dropdown import DropdownItemDisabled - -from robottelo.constants import REPOS -from robottelo.exceptions import CLIReturnCodeError from robottelo.constants import FAKE_FILE_NEW_NAME, REPOS, DataFile +from robottelo.exceptions import CLIReturnCodeError @pytest.mark.tier2 @@ -113,9 +110,11 @@ def test_no_blank_page_on_language_switch(session, target_sat, module_org): 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 @@ -125,8 +124,11 @@ def test_republish_metadata(session, function_sca_manifest_org, target_sat): 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( @@ -139,14 +141,7 @@ def test_republish_metadata(session, function_sca_manifest_org, target_sat): 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] - ) + assert session.contentview_new.republish_metadata_error(cv.name, 'Version 1.0') with pytest.raises(CLIReturnCodeError) as error: target_sat.cli.ContentView.version_republish_repositories( {'id': version.id, 'force': 'false'} @@ -160,6 +155,7 @@ def test_republish_metadata(session, function_sca_manifest_org, target_sat): {'id': version.id, 'force': 'true'} ) + @pytest.mark.tier2 def test_file_cv_display(session, target_sat, module_org, module_product): """Content-> Files displays only the Content Views associated with that file @@ -197,4 +193,3 @@ def test_file_cv_display(session, target_sat, module_org, module_product): file_values = session.file.read_cv_table(FAKE_FILE_NEW_NAME) assert len(file_values) == 1 assert file_values[0]['Name'] == cv.name - From b58f0081bdfb6e38096010ff39f73462c4c6b2d7 Mon Sep 17 00:00:00 2001 From: Sam Bible Date: Wed, 3 Jul 2024 08:41:58 -0500 Subject: [PATCH 3/3] Update docstring --- tests/foreman/ui/test_contentview.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/foreman/ui/test_contentview.py b/tests/foreman/ui/test_contentview.py index b7b7b60d6e9..d8f49575a16 100644 --- a/tests/foreman/ui/test_contentview.py +++ b/tests/foreman/ui/test_contentview.py @@ -95,6 +95,8 @@ def test_no_blank_page_on_language_switch(session, target_sat, module_org): :BZ: 2163538 + :CaseImportance: High + :customerscenario: true """ user_password = gen_string('alpha') @@ -113,6 +115,7 @@ def test_no_blank_page_on_language_switch(session, target_sat, module_org): 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: @@ -123,6 +126,7 @@ def test_republish_metadata(session, function_sca_manifest_org, target_sat): 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