未验证 提交 60f427da 编写于 作者: H huangjincheng2022 提交者: GitHub

add rbac test cases (#19063)

Signed-off-by: Nhuangjincheng2022 <jincheng.huang@zilliz.com>
Signed-off-by: Nhuangjincheng2022 <jincheng.huang@zilliz.com>
上级 56693836
......@@ -247,6 +247,12 @@ class ApiUtilityWrapper:
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ).run()
return res, check_result
def update_password(self, user, old_password, new_password, check_task=None, check_items=None):
func_name = sys._getframe().f_code.co_name
res, is_succ = api_request([self.ut.update_password, user, old_password, new_password])
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ).run()
return res, check_result
def delete_user(self, user, using="default", check_task=None, check_items=None):
func_name = sys._getframe().f_code.co_name
res, is_succ = api_request([self.ut.delete_user, user, using])
......@@ -265,7 +271,6 @@ class ApiUtilityWrapper:
def create_role(self, using="default", check_task=None, check_items=None, **kwargs):
func_name = sys._getframe().f_code.co_name
res, is_succ = api_request([self.role.create], **kwargs)
res = res if is_succ else None
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
**kwargs).run()
return res, check_result
......
......@@ -80,6 +80,10 @@ class ResponseChecker:
# Collection interface response check
result = self.check_role_property(self.response, self.func_name, self.check_items)
elif self.check_task == CheckTasks.check_permission_deny:
# Collection interface response check
result = self.check_permission_deny(self.response, self.succ)
# Add check_items here if something new need verify
return result
......@@ -390,3 +394,13 @@ class ResponseChecker:
if check_items.get("name", None):
assert role.name == check_items["name"]
return True
@staticmethod
def check_permission_deny(res, actual=True):
assert actual is False
if isinstance(res, Error):
assert "permission deny" in res.message
else:
log.error("[CheckFunc] Response of API is not an error: %s" % str(res))
assert False
return True
......@@ -193,6 +193,7 @@ class CheckTasks:
check_delete_compact = "check_delete_compact"
check_merge_compact = "check_merge_compact"
check_role_property = "check_role_property"
check_permission_deny = "check_permission_deny"
class BulkLoadStates:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册