Skip to content

Commit

Permalink
Fix obc ui test leftovers (#8592)
Browse files Browse the repository at this point in the history
Signed-off-by: Elena Bondarenko <[email protected]>
  • Loading branch information
ebondare authored Sep 29, 2023
1 parent 462dd48 commit 13b0e44
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
19 changes: 15 additions & 4 deletions ocs_ci/ocs/ui/page_objects/object_bucket_claims_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,41 @@ 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"])
self.do_click(self.sc_loc["select_administrator"], timeout=5)
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")

namespaces = []
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):
"""
Expand Down
23 changes: 8 additions & 15 deletions tests/ui/test_non_admin_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -19,7 +18,6 @@
tier1,
E2ETest,
)
from time import sleep
from ocs_ci.utility.utils import ceph_health_check


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 13b0e44

Please sign in to comment.