Добавлен тест панели событий для пользователя с ролью 'Специалист ИБ'
parent
9da4097e8d
commit
004bb2b4d7
|
|
@ -33,7 +33,6 @@ class EventPanelLocators:
|
||||||
TAB_MAINTENANCE = "//div[@data-testid='BASELINE__service_tab__toolbar']"
|
TAB_MAINTENANCE = "//div[@data-testid='BASELINE__service_tab__toolbar']"
|
||||||
TAB_SYSTEM_LOG = "//div[@data-testid='BASELINE__system journal_tab__toolbar']"
|
TAB_SYSTEM_LOG = "//div[@data-testid='BASELINE__system journal_tab__toolbar']"
|
||||||
TAB_AUDIT = "//div[@data-testid='BASELINE__audit_tab__toolbar']"
|
TAB_AUDIT = "//div[@data-testid='BASELINE__audit_tab__toolbar']"
|
||||||
TAB_INFORMATION_SECURITY = "//div[@data-testid='BASELINE__information security_tab__toolbar']"
|
|
||||||
|
|
||||||
BUTTONS_EVENT = "//nav/div[@class='v-toolbar__content']/div[@class='v-toolbar__items'][2]//span[contains(@class, 'v-tooltip')]"
|
BUTTONS_EVENT = "//nav/div[@class='v-toolbar__content']/div[@class='v-toolbar__items'][2]//span[contains(@class, 'v-tooltip')]"
|
||||||
|
|
||||||
|
|
@ -55,4 +54,3 @@ class EventPanelLocators:
|
||||||
CONTAINER_MAINTENANCE_EVENTS = "#app > div.application--wrap > div > div:nth-child(3) > div:nth-child(4)"
|
CONTAINER_MAINTENANCE_EVENTS = "#app > div.application--wrap > div > div:nth-child(3) > div:nth-child(4)"
|
||||||
CONTAINER_SYSTEM_LOG_EVENTS = "#app > div.application--wrap > div > div:nth-child(3) > div:nth-child(5)"
|
CONTAINER_SYSTEM_LOG_EVENTS = "#app > div.application--wrap > div > div:nth-child(3) > div:nth-child(5)"
|
||||||
CONTAINER_AUDIT_EVENTS = "#app > div.application--wrap > div > div:nth-child(3) > div:nth-child(6)"
|
CONTAINER_AUDIT_EVENTS = "#app > div.application--wrap > div > div:nth-child(3) > div:nth-child(6)"
|
||||||
CONTAINER_INFORMATION_SECURITY = "#app > div.application--wrap > div > div:nth-child(3) > div:nth-child(6)"
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,377 @@
|
||||||
|
"""Модуль тестов контейнера для отображения событий информационной безопасности.
|
||||||
|
|
||||||
|
Содержит тесты для проверки функциональности
|
||||||
|
контейнера для отображения событий информационной безопасности.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from playwright.sync_api import Page
|
||||||
|
from pages.users_tab import UsersTab
|
||||||
|
from pages.main_page import MainPage
|
||||||
|
from pages.login_page import LoginPage
|
||||||
|
|
||||||
|
# @pytest.mark.smoke
|
||||||
|
class TestAuditEventsContainerSecurity:
|
||||||
|
"""Класс тестов для проверки контейнера для отображения событий информационной безопасности.
|
||||||
|
|
||||||
|
Атрибуты:
|
||||||
|
browser: Фикстура для работы с браузером.
|
||||||
|
"""
|
||||||
|
user_data = {"name": "TestSecurityUser", "role": "Специалист информационной безопасности",
|
||||||
|
"password": "qwerty1234567"}
|
||||||
|
|
||||||
|
@pytest.fixture(scope="class", autouse=True)
|
||||||
|
def test_fixture(self, browser: Page) -> None:
|
||||||
|
"""Функция для подготовки и удаления тестового окружения.
|
||||||
|
"""
|
||||||
|
# Авторизация в системе
|
||||||
|
lp = LoginPage(browser)
|
||||||
|
lp.do_login()
|
||||||
|
|
||||||
|
# Инициализация главной страницы
|
||||||
|
mp = MainPage(browser)
|
||||||
|
|
||||||
|
# Создание тестового пользователя
|
||||||
|
mp.should_be_navigation_panel()
|
||||||
|
|
||||||
|
mp.click_main_navigation_panel_item("Настройки")
|
||||||
|
mp.click_subpanel_item("Пользователи")
|
||||||
|
ut = UsersTab(browser)
|
||||||
|
ut.open_add_user_window()
|
||||||
|
ut.add_new_user(self.user_data)
|
||||||
|
|
||||||
|
mp.do_logout()
|
||||||
|
|
||||||
|
yield
|
||||||
|
|
||||||
|
# Авторизация как администратор
|
||||||
|
lp = LoginPage(browser)
|
||||||
|
lp.do_login()
|
||||||
|
|
||||||
|
# Удаляем тестового пользователя
|
||||||
|
mp = MainPage(browser)
|
||||||
|
mp.click_main_navigation_panel_item("Настройки")
|
||||||
|
mp.click_subpanel_item("Пользователи")
|
||||||
|
ut = UsersTab(browser)
|
||||||
|
|
||||||
|
# Проверяем существует ли пользователь и удаляем его
|
||||||
|
user_index = ut.find_user_in_table(self.user_data["name"], self.user_data["role"])
|
||||||
|
if user_index != -1:
|
||||||
|
ut.open_edit_user_page_by_user(self.user_data["name"], self.user_data["role"])
|
||||||
|
ut.delete_user(self.user_data["name"])
|
||||||
|
|
||||||
|
mp.do_logout()
|
||||||
|
|
||||||
|
# @pytest.mark.develop
|
||||||
|
def test_events_tab_content(self, browser: Page) -> None:
|
||||||
|
"""Проверяет содержимое контейнера для отображения событий информационной безопасности.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
browser: Экземпляр страницы Playwright.
|
||||||
|
"""
|
||||||
|
|
||||||
|
lp = LoginPage(browser)
|
||||||
|
lp.do_login(username=self.user_data["name"], password=self.user_data["password"])
|
||||||
|
browser.wait_for_timeout(1000)
|
||||||
|
|
||||||
|
mp = MainPage(browser)
|
||||||
|
mp.should_be_event_panel()
|
||||||
|
|
||||||
|
security_events_container = mp.click_events_panel_audit_tab()
|
||||||
|
browser.wait_for_timeout(2000)
|
||||||
|
|
||||||
|
security_events_container.check_content()
|
||||||
|
|
||||||
|
# Выход из системы текущего пользователя
|
||||||
|
mp.do_logout()
|
||||||
|
|
||||||
|
def test_events_table_row_highlighting(self, browser: Page):
|
||||||
|
"""Проверяет выделение строк в таблице событий.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
browser: Экземпляр страницы Playwright.
|
||||||
|
"""
|
||||||
|
lp = LoginPage(browser)
|
||||||
|
lp.do_login(username=self.user_data["name"], password=self.user_data["password"])
|
||||||
|
browser.wait_for_timeout(1000)
|
||||||
|
|
||||||
|
mp = MainPage(browser)
|
||||||
|
mp.should_be_event_panel()
|
||||||
|
|
||||||
|
security_events_container = mp.click_events_panel_audit_tab()
|
||||||
|
|
||||||
|
# Получение количества строк в таблице
|
||||||
|
rows_count = security_events_container.get_events_table_rows_count()
|
||||||
|
|
||||||
|
# Проверка выделения строк
|
||||||
|
security_events_container.check_events_table_row_highlighting(0)
|
||||||
|
security_events_container.check_events_table_row_highlighting(rows_count - 1)
|
||||||
|
security_events_container.check_events_table_row_highlighting(int(rows_count / 2))
|
||||||
|
|
||||||
|
# Выход из системы текущего пользователя
|
||||||
|
mp.do_logout()
|
||||||
|
|
||||||
|
def test_events_table_scrolling(self, browser: Page):
|
||||||
|
"""Проверяет возможность скроллинга таблицы событий.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
browser: Экземпляр страницы Playwright.
|
||||||
|
"""
|
||||||
|
|
||||||
|
lp = LoginPage(browser)
|
||||||
|
lp.do_login(username=self.user_data["name"], password=self.user_data["password"])
|
||||||
|
browser.wait_for_timeout(1000)
|
||||||
|
|
||||||
|
mp = MainPage(browser)
|
||||||
|
mp.should_be_event_panel()
|
||||||
|
|
||||||
|
security_events_container = mp.click_events_panel_audit_tab()
|
||||||
|
|
||||||
|
events_panel_position = mp.get_events_panel_position()
|
||||||
|
|
||||||
|
# Проверка, что панель с таблицей открыта
|
||||||
|
assert events_panel_position != "bottom", "Panel with security events should be opened"
|
||||||
|
|
||||||
|
is_scrollable = security_events_container.check_events_table_verticall_scrolling()
|
||||||
|
|
||||||
|
# Убеждаемся, что панель открыта наполовину и проверяем скроллинг
|
||||||
|
assert events_panel_position == "center",\
|
||||||
|
"Panel with security events should be located on the main page center"
|
||||||
|
assert is_scrollable, "Security events table should be scrollable"
|
||||||
|
|
||||||
|
# Скроллинг вниз
|
||||||
|
security_events_container.scroll_events_table_down()
|
||||||
|
browser.wait_for_timeout(1000)
|
||||||
|
|
||||||
|
# Проверка видимости последней строки после прокрутки
|
||||||
|
security_events_container.check_events_table_last_row_visibility()
|
||||||
|
|
||||||
|
# Скроллинг вверх
|
||||||
|
security_events_container.scroll_events_table_up()
|
||||||
|
browser.wait_for_timeout(1000)
|
||||||
|
|
||||||
|
# Проверка видимости первой строки после прокрутки
|
||||||
|
security_events_container.check_events_table_first_row_visibility()
|
||||||
|
|
||||||
|
# Раскрываем панель полностью и проверяем скроллинг
|
||||||
|
assert mp.check_expand_more_button(), \
|
||||||
|
"Expand more button should be present"
|
||||||
|
mp.click_events_panel_expand_more_button()
|
||||||
|
mp.wait_for_timeout(500)
|
||||||
|
|
||||||
|
events_panel_position = mp.get_events_panel_position()
|
||||||
|
assert events_panel_position == "top",\
|
||||||
|
"Panel with security events should be located on the main page top"
|
||||||
|
|
||||||
|
is_scrollable = security_events_container.check_events_table_verticall_scrolling()
|
||||||
|
assert is_scrollable, "Security events table should be scrollable in the full window"
|
||||||
|
|
||||||
|
# Скроллинг вниз
|
||||||
|
security_events_container.scroll_events_table_down()
|
||||||
|
browser.wait_for_timeout(1000)
|
||||||
|
|
||||||
|
# Проверка видимости последней строки после прокрутки
|
||||||
|
security_events_container.check_events_table_last_row_visibility()
|
||||||
|
|
||||||
|
# Скроллинг вверх
|
||||||
|
security_events_container.scroll_events_table_up()
|
||||||
|
browser.wait_for_timeout(1000)
|
||||||
|
|
||||||
|
# Проверка видимости первой строки после прокрутки
|
||||||
|
security_events_container.check_events_table_first_row_visibility()
|
||||||
|
|
||||||
|
# Выход из системы текущего пользователя
|
||||||
|
mp.do_logout()
|
||||||
|
|
||||||
|
def test_events_table_column_sorting(self, browser: Page):
|
||||||
|
"""Проверяет сортировку колонки 'Время' в таблице событий.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
browser: Экземпляр страницы Playwright.
|
||||||
|
"""
|
||||||
|
|
||||||
|
lp = LoginPage(browser)
|
||||||
|
lp.do_login(username=self.user_data["name"], password=self.user_data["password"])
|
||||||
|
browser.wait_for_timeout(1000)
|
||||||
|
|
||||||
|
mp = MainPage(browser)
|
||||||
|
mp.should_be_event_panel()
|
||||||
|
|
||||||
|
security_events_container = mp.click_events_panel_audit_tab()
|
||||||
|
|
||||||
|
index = 0
|
||||||
|
state = security_events_container.get_arrow_button_state(index)
|
||||||
|
assert state == "down", "Arrow button should be down"
|
||||||
|
|
||||||
|
security_events_container.click_event_table_header_arrow(index)
|
||||||
|
browser.wait_for_timeout(500)
|
||||||
|
|
||||||
|
state = security_events_container.get_arrow_button_state(index)
|
||||||
|
assert state == "up", "Arrow button should be up"
|
||||||
|
is_descending_order = security_events_container.check_events_table_column_descending_order(index,
|
||||||
|
convert2timestamp=True)
|
||||||
|
assert not is_descending_order, "Column data should be in ascending order"
|
||||||
|
|
||||||
|
security_events_container.click_event_table_header_arrow(index)
|
||||||
|
browser.wait_for_timeout(500)
|
||||||
|
state = security_events_container.get_arrow_button_state(index)
|
||||||
|
assert state == "down", "Arrow button should be down"
|
||||||
|
is_descending_order = security_events_container.check_events_table_column_descending_order(index,
|
||||||
|
convert2timestamp=True)
|
||||||
|
assert is_descending_order, "Column data should be in descending order"
|
||||||
|
|
||||||
|
# Выход из системы текущего пользователя
|
||||||
|
mp.do_logout()
|
||||||
|
|
||||||
|
def test_events_table_pagination(self, browser: Page):
|
||||||
|
"""Проверяет возможность пагинации таблицы событий.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
browser: Экземпляр страницы Playwright.
|
||||||
|
"""
|
||||||
|
|
||||||
|
lp = LoginPage(browser)
|
||||||
|
lp.do_login(username=self.user_data["name"], password=self.user_data["password"])
|
||||||
|
browser.wait_for_timeout(1000)
|
||||||
|
|
||||||
|
mp = MainPage(browser)
|
||||||
|
mp.should_be_event_panel()
|
||||||
|
|
||||||
|
security_events_container = mp.click_events_panel_audit_tab()
|
||||||
|
|
||||||
|
security_events_container.should_be_pagination_buttons()
|
||||||
|
|
||||||
|
# Проверка начального состояния
|
||||||
|
tested_pages = 1
|
||||||
|
|
||||||
|
# to do: некорректный запрос в бэк, должно быть "filter": {"page": 0}
|
||||||
|
payload = {"table": "default",
|
||||||
|
"filter": {
|
||||||
|
"tags": [
|
||||||
|
"testaudit",
|
||||||
|
"secure"
|
||||||
|
],
|
||||||
|
"page": 0
|
||||||
|
},
|
||||||
|
"count": 40
|
||||||
|
}
|
||||||
|
|
||||||
|
response = mp.send_post_api_request("e-nms/logs_enode", payload)
|
||||||
|
if response.status == 200:
|
||||||
|
response_body = mp.get_response_body(response)
|
||||||
|
|
||||||
|
if response_body:
|
||||||
|
pages = response_body["data"]["pages"]
|
||||||
|
|
||||||
|
if pages > 5:
|
||||||
|
tested_pages = 5
|
||||||
|
else:
|
||||||
|
tested_pages = pages
|
||||||
|
|
||||||
|
current_number = security_events_container.get_current_data_set_number()
|
||||||
|
assert current_number == 1, "The first page should be number one"
|
||||||
|
|
||||||
|
if tested_pages == 1:
|
||||||
|
security_events_container.should_be_all_disabled()
|
||||||
|
else:
|
||||||
|
security_events_container.should_be_initial_state()
|
||||||
|
|
||||||
|
# Переход на самую последнюю страницу, возврат на страницу назад, потом на страницу вперед
|
||||||
|
security_events_container.click_last_page()
|
||||||
|
browser.wait_for_timeout(2000)
|
||||||
|
|
||||||
|
security_events_container.should_be_final_state()
|
||||||
|
|
||||||
|
last_number = security_events_container.get_current_data_set_number()
|
||||||
|
|
||||||
|
security_events_container.click_chevron_left()
|
||||||
|
browser.wait_for_timeout(4000)
|
||||||
|
|
||||||
|
if last_number == 2:
|
||||||
|
security_events_container.should_be_initial_state()
|
||||||
|
else:
|
||||||
|
security_events_container.should_be_all_enabled()
|
||||||
|
|
||||||
|
counter = last_number - 1
|
||||||
|
current_number = security_events_container.get_current_data_set_number()
|
||||||
|
assert current_number == counter, f"Expected page number {counter} is not equal actual {current_number}"
|
||||||
|
|
||||||
|
security_events_container.click_chevron_right()
|
||||||
|
browser.wait_for_timeout(4000)
|
||||||
|
|
||||||
|
security_events_container.should_be_final_state()
|
||||||
|
|
||||||
|
current_number = security_events_container.get_current_data_set_number()
|
||||||
|
assert current_number == last_number, \
|
||||||
|
f"Expected page number {last_number} is not equal actual {current_number}"
|
||||||
|
|
||||||
|
# Переход на первую страницу, переход на следующую страницу, возврат на первую страницу
|
||||||
|
security_events_container.click_first_page()
|
||||||
|
browser.wait_for_timeout(2000)
|
||||||
|
|
||||||
|
security_events_container.should_be_initial_state()
|
||||||
|
|
||||||
|
current_number = security_events_container.get_current_data_set_number()
|
||||||
|
assert current_number == 1, f"Expected page number 1 is not equal actual {current_number}"
|
||||||
|
|
||||||
|
security_events_container.click_chevron_right()
|
||||||
|
browser.wait_for_timeout(4000)
|
||||||
|
|
||||||
|
if tested_pages == 2:
|
||||||
|
security_events_container.should_be_final_state()
|
||||||
|
else:
|
||||||
|
security_events_container.should_be_all_enabled()
|
||||||
|
|
||||||
|
current_number = security_events_container.get_current_data_set_number()
|
||||||
|
assert current_number == 2, f"Expected page number 2 is not equal actual {current_number}"
|
||||||
|
|
||||||
|
security_events_container.click_chevron_left()
|
||||||
|
browser.wait_for_timeout(4000)
|
||||||
|
|
||||||
|
security_events_container.should_be_initial_state()
|
||||||
|
|
||||||
|
current_number = security_events_container.get_current_data_set_number()
|
||||||
|
assert current_number == 1, f"Expected page number 1 is not equal actual {current_number}"
|
||||||
|
|
||||||
|
if tested_pages > 2:
|
||||||
|
# загрузка страниц от начала и до конца
|
||||||
|
# to_do: проверка, что происходит обновление содержимого таблицы
|
||||||
|
counter = 1
|
||||||
|
|
||||||
|
while counter < tested_pages:
|
||||||
|
security_events_container.click_chevron_right()
|
||||||
|
counter += 1
|
||||||
|
browser.wait_for_timeout(2000)
|
||||||
|
|
||||||
|
if counter == tested_pages:
|
||||||
|
security_events_container.should_be_final_state()
|
||||||
|
else:
|
||||||
|
security_events_container.should_be_all_enabled()
|
||||||
|
current_number = security_events_container.get_current_data_set_number()
|
||||||
|
assert current_number == counter,\
|
||||||
|
f"Expected page number {counter} is not equal actual {current_number}"
|
||||||
|
|
||||||
|
# загрузка страниц от конца к началу
|
||||||
|
# to_do: проверка, что происходит обновление содержимого таблицы
|
||||||
|
while counter > 2:
|
||||||
|
security_events_container.click_chevron_left()
|
||||||
|
browser.wait_for_timeout(2000)
|
||||||
|
|
||||||
|
security_events_container.should_be_all_enabled()
|
||||||
|
|
||||||
|
counter -= 1
|
||||||
|
current_number = security_events_container.get_current_data_set_number()
|
||||||
|
assert current_number == counter,\
|
||||||
|
f"Expected page number {counter} is not equal actual {current_number}"
|
||||||
|
|
||||||
|
# Проверка возврата к начальному состоянию
|
||||||
|
security_events_container.click_chevron_left()
|
||||||
|
browser.wait_for_timeout(2000)
|
||||||
|
|
||||||
|
security_events_container.should_be_initial_state()
|
||||||
|
|
||||||
|
current_number = security_events_container.get_current_data_set_number()
|
||||||
|
assert current_number == 1, "The first page should be number one"
|
||||||
|
|
||||||
|
# Выход из системы текущего пользователя
|
||||||
|
mp.do_logout()
|
||||||
Loading…
Reference in New Issue