Skip to content

Commit

Permalink
cu-case-katello-reimport-scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaysawant committed Mar 30, 2024
1 parent 7bd2a07 commit 0265ec7
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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)
46 changes: 45 additions & 1 deletion tests/foreman/cli/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Binary file added tests/foreman/data/expired-manifest.zip
Binary file not shown.

0 comments on commit 0265ec7

Please sign in to comment.