Skip to content

Commit

Permalink
eol banner (#13211)
Browse files Browse the repository at this point in the history
  • Loading branch information
pondrejk authored Feb 27, 2024
1 parent 4c9e5bb commit d1d8472
Showing 1 changed file with 104 additions and 0 deletions.
104 changes: 104 additions & 0 deletions tests/foreman/ui/test_eol_banner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
"""Test module for Dashboard UI
:Requirement: Dashboard
:CaseAutomation: Automated
:CaseLevel: Acceptance
:CaseComponent: Dashboard
:Team: Endeavour
:TestType: Functional
:CaseImportance: High
:Upstream: No
"""
from datetime import datetime, timedelta

from airgun.session import Session
from navmazing import NavigationTriesExceeded
import pytest

from robottelo.utils.datafactory import gen_string


def set_eol_date(target_sat, eol_date):
target_sat.execute(
rf'''sed -i "/end_of_life/c\ 'end_of_life': '{eol_date}'" /usr/share/satellite/lifecycle-metadata.yml'''
)
target_sat.restart_services()


@pytest.mark.upgrade
@pytest.mark.run_in_one_thread
@pytest.mark.tier2
def test_positive_eol_banner_e2e(session, target_sat, test_name):
"""Check if the EOL banner is displayed correctly
:id: 0ce6c11c-d969-4e7e-a934-cd1683de62a3
:Steps:
1. Set the EOL date witin 6 months, assert warning banner
2. Check non-admin users can't see warning banner
3. Dismiss banner
4. Move EOL date to the past, assert error banner
5. Check non-admin users can't see error banner
6. Dismiss banner
:expectedresults: Banner shows up when it should
"""
# non-admin user
username = gen_string('alpha')
password = gen_string('alpha')
target_sat.api.User(login=username, password=password, mail='[email protected]').create()
# admin user
admin_username = gen_string('alpha')
admin_password = gen_string('alpha')
target_sat.api.User(
login=admin_username, password=admin_password, admin=True, mail='[email protected]'
).create()

# eol in 3 months
eol_date = (datetime.now() + timedelta(days=90)).strftime("%Y-%m-%d")
message_date = (datetime.now() + timedelta(days=90)).strftime("%B %Y")
set_eol_date(target_sat, eol_date)

# non-admin can't see banner
with Session(test_name, username, password) as newsession:
with pytest.raises(NavigationTriesExceeded) as error:
newsession.eol_banner.read()
assert error.typename == 'NavigationTriesExceeded'

# admin can see warning banner
with Session(test_name, admin_username, admin_password) as adminsession:
banner = adminsession.eol_banner.read()
assert message_date in banner["name"]
assert adminsession.eol_banner.is_warning()
adminsession.eol_banner.dismiss()
with pytest.raises(NavigationTriesExceeded) as error:
adminsession.eol_banner.read()
assert error.typename == 'NavigationTriesExceeded'

# past eol_date
eol_date = (datetime.now() - timedelta(days=5)).strftime("%Y-%m-%d")
set_eol_date(target_sat, eol_date)

# non-admin can't see danger banner
with Session(test_name, username, password) as newsession:
with pytest.raises(NavigationTriesExceeded) as error:
newsession.eol_banner.read()
assert error.typename == 'NavigationTriesExceeded'

# admin can see danger banner
with Session(test_name, admin_username, admin_password) as adminsession:
banner = adminsession.eol_banner.read()
assert eol_date in banner["name"]
assert adminsession.eol_banner.is_danger()
adminsession.eol_banner.dismiss()
with pytest.raises(NavigationTriesExceeded) as error:
adminsession.eol_banner.read()
assert error.typename == 'NavigationTriesExceeded'

0 comments on commit d1d8472

Please sign in to comment.