diff --git a/conf/subscription.yaml.template b/conf/subscription.yaml.template index 54bb596a401..4de58229816 100644 --- a/conf/subscription.yaml.template +++ b/conf/subscription.yaml.template @@ -5,3 +5,5 @@ SUBSCRIPTION: RHN_PASSWORD: # subscription pool id RHN_POOLID: + # lifecycle API url + LIFECYCLE_API_URL: diff --git a/robottelo/config/validators.py b/robottelo/config/validators.py index a47dba2e211..971ac082d13 100644 --- a/robottelo/config/validators.py +++ b/robottelo/config/validators.py @@ -43,6 +43,7 @@ Validator('subscription.rhn_username', must_exist=True), Validator('subscription.rhn_password', must_exist=True), Validator('subscription.rhn_poolid', must_exist=True), + Validator('subscription.lifecycle_api_url', must_exist=True), ], ansible_hub=[ Validator('ansible_hub.url', must_exist=True), diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index 05571d2c3e3..a97bae1b308 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -2071,6 +2071,7 @@ class Colored(Box): "DELETE", "PATCH", ] +LIFECYCLE_METADATA_FILE = '/usr/share/satellite/lifecycle-metadata.yml' OPENSSH_RECOMMENDATION = 'Decreased security: OpenSSH config permissions' DNF_RECOMMENDATION = ( diff --git a/tests/foreman/api/test_eol_banner.py b/tests/foreman/api/test_eol_banner.py new file mode 100644 index 00000000000..454ca6202c7 --- /dev/null +++ b/tests/foreman/api/test_eol_banner.py @@ -0,0 +1,53 @@ +"""Test module for EOL tracking + +:Requirement: Dashboard + +:CaseAutomation: Automated + +:CaseLevel: Acceptance + +:CaseComponent: Dashboard + +:Team: Endeavour + +:TestType: Functional + +:CaseImportance: High + +:Upstream: No +""" +from datetime import datetime + +import pytest +import requests +import yaml + +from robottelo.config import settings +from robottelo.constants import LIFECYCLE_METADATA_FILE + + +@pytest.mark.tier2 +def test_positive_check_eol_date(target_sat): + """Check if the EOL date for the satellite version + + :id: 0ce6c11c-d969-4e7e-a934-cd1683de62a3 + + :expectedresults: EOL date from satellite-lifecycle package is accurate + """ + current_version = '.'.join(target_sat.version.split('.')[0:2]) + output = yaml.load(target_sat.execute(rf'cat {LIFECYCLE_METADATA_FILE}').stdout, yaml.Loader) + eol_datetime = datetime.strptime(output['releases'][current_version]['end_of_life'], '%Y-%m-%y') + result = requests.get(settings.subscription.lifecycle_api_url, verify=False) + if result.status_code != 200: + raise requests.HTTPError(f'{settings.subscription.lifecycle_api_url} is not accessible') + versions = result.json()['data'][0]['versions'] + version = [v for v in versions if v['name'] == current_version] + api_date = [ + (p['date_format'], p['date']) + for p in version[0]['phases'] + if p['name'] == 'Maintenance support' + ] + if api_date[0][0] == 'string': + assert eol_datetime.strftime("%B, %Y") in api_date[0][1] + if api_date[0][0] == 'date': + assert eol_datetime.strftime("%B, %Y") in api_date[0][1].strftime("%B, %Y")