Fix ldap tests: mostly ui testing part
Added main menu locator for Kibana UI. Increased timeout to load page to prevent timeout on opening of Kibana UI. Improved message for Grafana UI LDAP tests. Fixed "is_admin" determination in Grafana UI LDAP tests. Change-Id: I7e79a365a1ca722f9ce6b0c64eff991dbb1d93e8 Closes-Bug: #1621414 Partial-Bug: #1628526
This commit is contained in:
parent
c85e995921
commit
032186bb78
@ -23,6 +23,9 @@ class MainPage(base_pages.PageObject):
|
||||
_submit_button_locator = (
|
||||
by.By.XPATH, '//button[@class="btn btn-primary"][@type="submit"]')
|
||||
_error_field_locator = (by.By.CLASS_NAME, 'panel-title')
|
||||
_main_menu_locator = (
|
||||
by.By.CLASS_NAME, 'navbar-nav'
|
||||
)
|
||||
|
||||
def __init__(self, driver):
|
||||
super(MainPage, self).__init__(driver)
|
||||
|
@ -32,4 +32,4 @@ implicit_wait = os.environ.get('IMPLICIT_WAIT', 5)
|
||||
|
||||
# Set the amount of time to wait for a page load to complete
|
||||
# before throwing an error.
|
||||
page_timeout = os.environ.get('PAGE_TIMEOUT', 15)
|
||||
page_timeout = os.environ.get('PAGE_TIMEOUT', 25)
|
||||
|
@ -56,19 +56,20 @@ def check_grafana_dashboards(url):
|
||||
dashboard_page.get_back_to_home()
|
||||
|
||||
|
||||
def _check_available_menu_items_for_user(user, url, authz):
|
||||
def _check_available_menu_items_for_user(user, url, authz, is_admin=False):
|
||||
logger.info("Checking Grafana service at {} with LDAP authorization "
|
||||
"for {} user".format(url, user[0]))
|
||||
admin_panels = ["Dashboards", "Data Sources", "Plugins", "Admin"]
|
||||
viewer_panel = admin_panels[:1] if authz else admin_panels
|
||||
expected_panels = admin_panels if is_admin else viewer_panel
|
||||
|
||||
with ui_tester.ui_driver(url, "Grafana", login_key_xpath) as driver:
|
||||
home_page = _get_main_page(driver, user)
|
||||
menu_items = [name.text for name in home_page.main_menu.items]
|
||||
msg = "Not all required panels are available in main menu."
|
||||
msg = ("Not all required panels are available in main menu, "
|
||||
"expected: {}, found: {}.".format(expected_panels, menu_items))
|
||||
asserts.assert_true(
|
||||
(admin_panels if ("uadmin" in user)
|
||||
else viewer_panel) == menu_items,
|
||||
expected_panels == menu_items,
|
||||
msg
|
||||
)
|
||||
|
||||
@ -76,5 +77,5 @@ def _check_available_menu_items_for_user(user, url, authz):
|
||||
def check_grafana_ldap(grafana_url, authz=False,
|
||||
uadmin=("uadmin", "uadmin"),
|
||||
uviewer=("uviewer", "uviewer")):
|
||||
_check_available_menu_items_for_user(uadmin, grafana_url, authz)
|
||||
_check_available_menu_items_for_user(uadmin, grafana_url, authz, True)
|
||||
_check_available_menu_items_for_user(uviewer, grafana_url, authz)
|
||||
|
Loading…
Reference in New Issue
Block a user