diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index de71cdd643f..1933ae7248c 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -2149,6 +2149,7 @@ class Colored(Box): 'option is not present in the /etc/dnf/dnf.conf' ) +EXPIRED_MANIFEST = 'expired-manifest.zip' # Data File Paths class DataFile(Box): """The boxed Data directory class with its attributes pointing to the Data directory files""" @@ -2168,3 +2169,4 @@ class DataFile(Box): PARTITION_SCRIPT_DATA_FILE = DATA_DIR.joinpath(PARTITION_SCRIPT_DATA_FILE) OS_TEMPLATE_DATA_FILE = DATA_DIR.joinpath(OS_TEMPLATE_DATA_FILE) FAKE_3_YUM_REPO_RPMS_ANT = DATA_DIR.joinpath(FAKE_3_YUM_REPO_RPMS[0]) + EXPIRED_MANIFEST_FILE = DATA_DIR.joinpath(EXPIRED_MANIFEST) diff --git a/tests/foreman/cli/test_subscription.py b/tests/foreman/cli/test_subscription.py index a7a74f4360c..b27276856f8 100644 --- a/tests/foreman/cli/test_subscription.py +++ b/tests/foreman/cli/test_subscription.py @@ -12,10 +12,12 @@ """ from fauxfactory import gen_string +from manifester import Manifester from nailgun import entities import pytest -from robottelo.constants import PRDS, REPOS, REPOSET +from robottelo.config import settings +from robottelo.constants import EXPIRED_MANIFEST, PRDS, REPOS, REPOSET, DataFile from robottelo.exceptions import CLIReturnCodeError pytestmark = [pytest.mark.run_in_one_thread] @@ -276,3 +278,45 @@ def test_positive_auto_attach_disabled_golden_ticket( with pytest.raises(CLIReturnCodeError) as context: target_sat.cli.Host.subscription_auto_attach({'host-id': host_id}) assert "This host's organization is in Simple Content Access mode" in str(context.value) + + +def test_negative_check_katello_reimport(target_sat, function_org): + """Verify katello:reimport fails with Error + + :id: b7508a1c-7798-4649-83a3-cf94c7409c96 + + :steps: + 1. Import expired manifest & refresh + 2. Delete expired manifest + 3. Re-import new manifest & refresh + + :expectedresults: there should not an error after reimport manifest + + :customerscenario: true + + :BZ: 2225534, 2253621 + + :CaseImportance: Medium + """ + remote_path = f'/tmp/{EXPIRED_MANIFEST}' + target_sat.put(DataFile.EXPIRED_MANIFEST_FILE, remote_path) + # Import expired manifest & refresh + target_sat.cli.Subscription.upload({'organization-id': function_org.id, 'file': remote_path}) + with pytest.raises(CLIReturnCodeError): + assert ( + "Manifest refresh failed:\n The manifest doesn\'t exist on console.redhat.com." + in target_sat.cli.Subscription.refresh_manifest({'organization-id': function_org.id}) + ) + exec_val = target_sat.execute( + 'grep -i "Katello::HttpErrors::BadRequest: This Organization\'s subscription ' + 'manifest has expired. Please import a new manifest" /var/log/foreman/production.log' + ) + assert exec_val.status + # Delete expired manifest + target_sat.cli.Subscription.delete_manifest({'organization-id': function_org.id}) + # Re-import new manifest & refresh + manifester = Manifester(manifest_category=settings.manifest.golden_ticket) + manifest = manifester.get_manifest() + target_sat.upload_manifest(function_org.id, manifest.content) + ret_val = target_sat.cli.Subscription.refresh_manifest({'organization-id': function_org.id}) + assert "Candlepin job status: SUCCESS" in ret_val diff --git a/tests/foreman/data/expired-manifest.zip b/tests/foreman/data/expired-manifest.zip new file mode 100644 index 00000000000..8737ba42db2 Binary files /dev/null and b/tests/foreman/data/expired-manifest.zip differ