From 4f31bd3f898cfa6768f043e2a6525be69412957b Mon Sep 17 00:00:00 2001 From: Elena Bondarenko Date: Tue, 3 Sep 2024 17:14:19 +0200 Subject: [PATCH] Add test for token generation with quota Signed-off-by: Elena Bondarenko --- ocs_ci/ocs/ui/page_objects/storage_clients.py | 7 ++-- tests/functional/ui/test_provider_client.py | 35 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 tests/functional/ui/test_provider_client.py diff --git a/ocs_ci/ocs/ui/page_objects/storage_clients.py b/ocs_ci/ocs/ui/page_objects/storage_clients.py index cd9259b167b..02c59e1768c 100644 --- a/ocs_ci/ocs/ui/page_objects/storage_clients.py +++ b/ocs_ci/ocs/ui/page_objects/storage_clients.py @@ -15,7 +15,8 @@ def __init__(self): def generate_client_onboarding_ticket(self, quota_value=None, quota_tib=None): """ - Generate a client onboarding ticket + Generate a client onboarding ticket. + Starting with version 4.17, client quota can be specified Args: quota_value (int): client's quota in GiB or TiB, unlimited if not defined @@ -24,8 +25,10 @@ def generate_client_onboarding_ticket(self, quota_value=None, quota_tib=None): Returns: str: onboarding_key """ + logger.info("Generating onboarding ticket") self.do_click(self.storage_clients_loc["generate_client_onboarding_ticket"]) if quota_value: + logger.info("Setting client cluster quota") self.do_click(self.storage_clients_loc["custom_quota"]) self.do_clear( locator=self.storage_clients_loc["quota_value"], @@ -37,7 +40,7 @@ def generate_client_onboarding_ticket(self, quota_value=None, quota_tib=None): if quota_tib: self.do_click(self.storage_clients_loc["choose_units"]) self.do_click(self.storage_clients_loc["quota_ti"]) - + logger.info("Confirming token generation") self.do_click(self.storage_clients_loc["confirm_generation"]) onboarding_key = self.get_element_text( self.storage_clients_loc["onboarding_key"] diff --git a/tests/functional/ui/test_provider_client.py b/tests/functional/ui/test_provider_client.py new file mode 100644 index 00000000000..ab2fc88bcc0 --- /dev/null +++ b/tests/functional/ui/test_provider_client.py @@ -0,0 +1,35 @@ +import logging + +from ocs_ci.ocs import constants +from ocs_ci.framework.testlib import ( + skipif_ocs_version, + ManageTest, + tier1, + skipif_ocp_version, + runs_on_provider, + black_squad, + hci_provider_required, +) +from ocs_ci.ocs.ui.page_objects.page_navigator import PageNavigator + + +logger = logging.getLogger(__name__) + + +@tier1 +@black_squad +@skipif_ocs_version("<4.17") +@skipif_ocp_version("<4.17") +@runs_on_provider +@hci_provider_required +class TestOnboardingTokenGenerationWithQuota(ManageTest): + """ + Test onboarding token generation when quota is specified + """ + + storage_clients = PageNavigator().nav_to_storageclients_page() + token = storage_clients.generate_client_onboarding_ticket( + quota_value=2, quota_tib=True + ) + logger.info(f"Token generated. It begins with {token[:20]}") + assert len(token) > 20, "Token is too short"