179 lines
9.1 KiB
Python
179 lines
9.1 KiB
Python
"""Модуль вкладки 'Сертификаты'.
|
||
|
||
Содержит класс CertificatesTab для работы с вкладкой 'Сертификаты'.
|
||
Позволяет проверять состояние и взаимодействовать с элементами вкладки.
|
||
"""
|
||
|
||
from playwright.sync_api import Page
|
||
from locators.certificate_locators import CertificateLocators
|
||
from elements.tab_button_element import TabButton
|
||
from components.toolbar_custom_component import CustomToolbar
|
||
from components.alert_component import AlertComponent
|
||
from components_derived.view_certificate_form import ViewCertificateForm
|
||
from components_derived.reissue_certificate_form import ReissueCertificateForm
|
||
from components_derived.import_certificate_form import ImportCertificateForm
|
||
from pages.base_page import BasePage
|
||
|
||
|
||
class CertificatesTab(BasePage):
|
||
"""Класс для работы с вкладкой 'Сертификаты'.
|
||
|
||
Предоставляет методы для взаимодействия с вкладкой 'Сертификаты'.
|
||
|
||
Args:
|
||
page: Экземпляр страницы Playwright.
|
||
"""
|
||
|
||
def __init__(self, page: Page) -> None:
|
||
"""Инициализирует компоненты вкладки настройки резервного копирования."""
|
||
|
||
super().__init__(page)
|
||
|
||
self.toolbar_main = CustomToolbar(page)
|
||
self.toolbar_secondary = CustomToolbar(page)
|
||
|
||
self.tab_button_certificate = TabButton(page, CertificateLocators.TAB_CERTIFICATE_CA, "tab_button_certificate")
|
||
self.tab_button_reissue = TabButton(page, CertificateLocators.TAB_REISSUE_CA, "tab_button_reissue")
|
||
self.tab_button_import = TabButton(page, CertificateLocators.TAB_IMPORT_CA, "tab_button_import")
|
||
|
||
self.view_certificate_form = ViewCertificateForm(page)
|
||
self.reissue_certificate_form = ReissueCertificateForm(page)
|
||
self.import_certificate_form = ImportCertificateForm(page)
|
||
|
||
self.alert = AlertComponent(page)
|
||
|
||
# Действия:
|
||
def click_certificate_tab_button(self) -> None:
|
||
"""Выполняет нажатие tab-кнопки 'Сертификат CA'."""
|
||
|
||
self.tab_button_certificate.check_visibility("'Сертификат CA' tab button is missing")
|
||
self.tab_button_certificate.click()
|
||
assert self.tab_button_certificate.is_active(), "'Сертификат CA' tab button should be active"
|
||
|
||
def click_reissue_tab_button(self) -> None:
|
||
"""Выполняет нажатие tab-кнопки 'Пересоздание CA'."""
|
||
|
||
self.tab_button_reissue.check_visibility("'Пересоздание CA' tab button is missing")
|
||
self.tab_button_reissue.click()
|
||
assert self.tab_button_reissue.is_active(), "'Пересоздание CA' tab button should be active"
|
||
|
||
def click_import_tab_button(self) -> None:
|
||
"""Выполняет нажатие tab-кнопки 'Import ca (p12)'."""
|
||
|
||
self.tab_button_import.check_visibility("'Import ca (p12)' tab button is missing")
|
||
self.tab_button_import.click()
|
||
assert self.tab_button_import.is_active(), "'Import ca (p12)' tab button should be active"
|
||
|
||
def get_certificate(self) -> dict:
|
||
""" Возвращает значания полей отображаемого сертификата"""
|
||
|
||
return self.view_certificate_form.get_certificate()
|
||
|
||
def get_identification_fields_values(self) -> dict:
|
||
"""Возвращает текущее значение полей блока 'Идентификация CA' формы для пересоздания сертификата.
|
||
|
||
Returns:
|
||
dict : Текущее значение полей блока 'Идентификация CA' формы для пересоздания сертификата.
|
||
"""
|
||
|
||
return self.reissue_certificate_form.get_identification_fields_values()
|
||
|
||
def get_location_fields_values(self) -> dict:
|
||
"""Возвращает текущее значение полей блока 'Адрес / Местонахождение' формы для пересоздания сертификата.
|
||
|
||
Returns:
|
||
dict : Текущее значение полей блока блока 'Адрес / Местонахождение' формы для пересоздания сертификата.
|
||
"""
|
||
|
||
return self.reissue_certificate_form.get_location_fields_values()
|
||
|
||
def get_password_field_value(self) -> str:
|
||
"""Возвращает текущее значение поля 'Пароль' формы импорта сертификата.
|
||
|
||
Returns:
|
||
str : Текущее значение поля 'Пароль' формы импорта сертификата.
|
||
"""
|
||
|
||
return self.import_certificate_form.get_password_field_value()
|
||
|
||
def export_certificate(self) -> str:
|
||
"""Нажатие кнопки 'Экспорт сертификата (CA)' в форме отображения сертификата и
|
||
скачивание текущего корневого сертификата.
|
||
|
||
Returns:
|
||
str : Полный путь к скачанному файлу.
|
||
"""
|
||
|
||
return self.view_certificate_form.export_certificate()
|
||
|
||
def input_identification_cert_name_field(self, value: str) -> None:
|
||
"""Заполнение поля 'Имя Сертификата' блока 'Идентификация CA' формы для пересоздания сертификата"""
|
||
|
||
self.reissue_certificate_form.input_identification_cert_name_field(value)
|
||
|
||
def input_identification_organization_field(self, value: str) -> None:
|
||
"""Заполнение поля 'Организация' блока 'Идентификация CA' формы для пересоздания сертификата"""
|
||
|
||
self.reissue_certificate_form.input_identification_organization_field(value)
|
||
|
||
def input_identification_org_unit_field(self, value: str) -> None:
|
||
"""Заполнение поля 'Подразделение' блока 'Идентификация CA' формы для пересоздания сертификата"""
|
||
|
||
self.reissue_certificate_form.input_identification_org_unit_field(value)
|
||
|
||
def input_location_country_field(self, value: str) -> None:
|
||
"""Заполнение поля 'Страна' блока 'Адрес / Местонахождение' формы для пересоздания сертификата"""
|
||
|
||
self.reissue_certificate_form.input_location_country_field(value)
|
||
|
||
def input_location_state_field(self, value: str) -> None:
|
||
"""Заполнение поля 'Регион / Область' блока 'Адрес / Местонахождение' формы для пересоздания сертификата"""
|
||
|
||
self.reissue_certificate_form.input_location_state_field(value)
|
||
|
||
def input_location_city_field(self, value: str) -> None:
|
||
"""Заполнение поля 'Город' блока 'Адрес / Местонахождение' формы для пересоздания сертификата"""
|
||
|
||
self.reissue_certificate_form.input_location_city_field(value)
|
||
|
||
def input_password_field(self, value: str) -> None:
|
||
"""Заполнение поля 'Пароль' формы импорта сертификата"""
|
||
|
||
self.import_certificate_form.input_password_field(value)
|
||
|
||
# Проверки:
|
||
def check_content(self):
|
||
"""Проверяет наличие и корректность всех элементов страницы."""
|
||
|
||
self.toolbar_main.check_toolbar_presence(['Сертификаты'])
|
||
self.toolbar_secondary.check_toolbar_presence(['Центр сертификации (CA)',
|
||
'Управление корневым сертификатом системы'])
|
||
|
||
self.click_certificate_tab_button()
|
||
self.view_certificate_form.check_content()
|
||
|
||
self.click_reissue_tab_button()
|
||
self.reissue_certificate_form.check_content()
|
||
|
||
self.click_import_tab_button()
|
||
self.import_certificate_form.check_content()
|
||
|
||
def check_alert(self, alert_type: str, alert_text: str) -> None:
|
||
"""Проверяет наличие alert заданного типа и текста."""
|
||
|
||
actual_alert_type = self.alert.get_alert_type()
|
||
assert actual_alert_type == alert_type, f"Got unexpected alert type {actual_alert_type}"
|
||
|
||
self.alert.check_alert_presence(alert_text)
|
||
self.alert.check_alert_absence(alert_text)
|
||
|
||
def is_import_button_disabled(self) -> bool:
|
||
"""Проверяет доступность кнопки импорта сертификата."""
|
||
|
||
return self.import_certificate_form.is_import_button_disabled()
|
||
|
||
def is_reissue_button_disabled(self) -> bool:
|
||
"""Проверяет доступность кнопки перевыпуска сертификата."""
|
||
|
||
return self.reissue_certificate_form.is_reissue_button_disabled()
|