Skip to content

Commit

Permalink
eol banner (SatelliteQE#13211)
Browse files Browse the repository at this point in the history
  • Loading branch information
pondrejk committed Oct 24, 2024
1 parent 58e6b11 commit 85c0352
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions tests/foreman/ui/test_eol_banner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
"""Test module for Dashboard UI
:Requirement: Dashboard
:CaseAutomation: Automated
:CaseComponent: Dashboard
:Team: Endeavour
:CaseImportance: High
"""

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 85c0352

Please sign in to comment.