From 13b0e44cc5c5075509ce749f64ea7d161d4ec558 Mon Sep 17 00:00:00 2001 From: Elena Bondarenko <40801241+ebondare@users.noreply.github.com> Date: Fri, 29 Sep 2023 14:06:24 +0200 Subject: [PATCH] Fix obc ui test leftovers (#8592) Signed-off-by: Elena Bondarenko --- .../page_objects/object_bucket_claims_tab.py | 19 +++++++++++---- tests/ui/test_non_admin_user.py | 23 +++++++------------ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/ocs_ci/ocs/ui/page_objects/object_bucket_claims_tab.py b/ocs_ci/ocs/ui/page_objects/object_bucket_claims_tab.py index e16874b2ea1..893fb2c7dfc 100644 --- a/ocs_ci/ocs/ui/page_objects/object_bucket_claims_tab.py +++ b/ocs_ci/ocs/ui/page_objects/object_bucket_claims_tab.py @@ -62,8 +62,15 @@ def __init__(self): } self.sc_loc = self.obc_loc - def check_obc_option(self, text="Object Bucket Claims"): - """check OBC is visible to user after giving admin access""" + def check_obc_option(self, username, text="Object Bucket Claims"): + """ + Check OBC is visible to user after giving admin access + + Args: + username (str): user's username + text (str): text to be found on OBC page + + """ sc_name = create_unique_resource_name("namespace-", "interface") self.do_click(self.sc_loc["Developer_dropdown"]) @@ -71,14 +78,17 @@ def check_obc_option(self, text="Object Bucket Claims"): self.do_click(self.sc_loc["create_project"]) self.do_send_keys(self.sc_loc["project_name"], sc_name) self.do_click(self.sc_loc["save_project"]) - self.choose_expanded_mode(mode=True, locator=self.page_nav["Storage"]) + ocp_obj = OCP() + ocp_obj.exec_oc_cmd( + f"adm policy add-role-to-user admin {username} -n {sc_name}" + ) + BucketsUI.navigate_object_bucket_claims_page(self) obc_found = self.wait_until_expected_text_is_found( locator=self.sc_loc["obc_menu_name"], expected_text=text, timeout=10 ) if not obc_found: logger.info("user is not able to access OBC") self.take_screenshot() - return None else: logger.info("user is able to access OBC") @@ -86,6 +96,7 @@ def check_obc_option(self, text="Object Bucket Claims"): namespace_obj = OCP(kind=constants.NAMESPACE, namespace=sc_name) namespaces.append(namespace_obj) delete_projects(namespaces) + return obc_found def _check_obc_cannot_be_used_before(self, rule_exp): """ diff --git a/tests/ui/test_non_admin_user.py b/tests/ui/test_non_admin_user.py index 9620b8f95ee..f72a8f5f10e 100644 --- a/tests/ui/test_non_admin_user.py +++ b/tests/ui/test_non_admin_user.py @@ -9,7 +9,6 @@ from ocs_ci.ocs.ui.page_objects.object_bucket_claims_tab import ObjectBucketClaimsTab from ocs_ci.ocs.ui.validation_ui import ValidationUI -from ocs_ci.ocs import ocp from ocs_ci.framework.testlib import ( ManageTest, ui, @@ -19,7 +18,6 @@ tier1, E2ETest, ) -from time import sleep from ocs_ci.utility.utils import ceph_health_check @@ -52,22 +50,17 @@ def finalizer(): @skipif_ibm_cloud_managed @bugzilla("2031705") @polarion_id("OCS-4620") - def test_create_storageclass_rbd(self, user_factory, login_factory): - """Create user""" - user = user_factory() - sleep(30) - - """ Create RoleBinding """ - ocp_obj = ocp.OCP() - ocp_obj.exec_oc_cmd( - f"-n openshift-storage create rolebinding {user[0]} --role=mcg-operator.v4.11.0-noobaa-odf-ui-548459769c " - f"--user={user[0]} " - ) + def test_project_admin_obcs_access(self, user_factory, login_factory): + """ + Test if user with admin access to the project can view the list of OBCs - """Login using created user""" + """ + user = user_factory() login_factory(user[0], user[1]) obc_ui_obj = ObjectBucketClaimsTab() - obc_ui_obj.check_obc_option() + assert obc_ui_obj.check_obc_option( + user[0] + ), f"User {user[0]} wasn't able to see the list of OBCs" @black_squad