add rbac test cases (#19063)

Signed-off-by: huangjincheng2022 <jincheng.huang@zilliz.com>

Signed-off-by: huangjincheng2022 <jincheng.huang@zilliz.com>
pull/19044/head
huangjincheng2022 2022-09-08 09:44:35 +08:00 committed by GitHub
parent 56693836ae
commit 60f427dad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1364 additions and 16 deletions

View File

@ -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

View File

@ -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

View File

@ -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:

File diff suppressed because it is too large Load Diff