From 2eb59546543b42f8746b7f2275669551ba98c41c Mon Sep 17 00:00:00 2001 From: floraachy <1622042529@gitlink.com> Date: Fri, 23 May 2025 14:43:02 +0800 Subject: [PATCH] ADD file via upload --- test_issue_permission.py | 101 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 test_issue_permission.py diff --git a/test_issue_permission.py b/test_issue_permission.py new file mode 100644 index 0000000..42800e4 --- /dev/null +++ b/test_issue_permission.py @@ -0,0 +1,101 @@ +""" +@FileName:test_issue_permission.py.py +@Description: +@Author:Floraachy +@Time:2024/11/22 13:46 +""" +# 第三方库导入 +import pytest +import allure +# 本地应用/模块导入 +from settings import GITLINK_DIR,GLOBAL_VARS +from utils.requests_utils.request_control import RequestControl + + +@allure.epic("GitLink") +@allure.feature("权限测试") +@allure.story("疑修") +@pytest.mark.flow +@allure.title("在私有仓库测试非仓库成员访问疑修,访问报错") +def test_issue_permission_on_private_repo(gitlink_login): + """ + 疑修权限测试 + """ + with allure.step("登录用户新建一个私有仓库"): + global_var = GLOBAL_VARS.copy() + global_var["user_id"] = GLOBAL_VARS["env_user_id"] + global_var["_cookies"] = GLOBAL_VARS["cookies"] + project_info = RequestControl().api_request_flow(api_file_path=GITLINK_DIR, + key="gitlink_projects_new_project_02", + global_var=global_var) + global_var["repo_owner"] = project_info["repo_owner"] + global_var["repo_identifier"] = project_info["repo_identifier"] + global_var["init_repo_owner"] = project_info["repo_owner"] + global_var["init_repo_identifier"] = project_info["repo_identifier"] + with allure.step("仓库拥有者新建一个疑修"): + issue_info = RequestControl().api_request_flow(api_file_path=GITLINK_DIR, key="gitlink_repo_new_issue_01", + global_var=global_var) + global_var.update(issue_info) + + with allure.step("非项目成员登录"): + global_var["env_login"] = GLOBAL_VARS["t_login"] + global_var["env_password"] = GLOBAL_VARS["t_password"] + login_info = RequestControl().api_request_flow(api_file_path=GITLINK_DIR, key="gitlink_login_01", + global_var=global_var) + global_var["cookies"] = login_info["cookies"] + + with allure.step("非项目成员,通过疑修index访问疑修详情,应该报错"): + RequestControl().api_request_flow(api_file_path=GITLINK_DIR, key="project_get_issue_detail_03", + global_var=global_var) + with allure.step("非项目成员,通过疑修id访问疑修详情,应该报错"): + RequestControl().api_request_flow(api_file_path=GITLINK_DIR, key="project_get_issue_detail_04", + global_var=global_var) + + with allure.step("仓库拥有者,删除仓库"): + global_var["cookies"] = global_var["_cookies"] + RequestControl().api_request_flow(api_file_path=GITLINK_DIR, key="gitlink_projects_delete_project_01", + global_var=global_var) + +@allure.epic("GitLink") +@allure.feature("权限测试") +@allure.story("疑修") +@pytest.mark.flow +@allure.title("在公有仓库测试非仓库成员访问疑修,访问成功") +def test_issue_permission_on_public_repo(gitlink_login): + """ + 疑修权限 + """ + with allure.step("登录用户新建一个公开仓库"): + global_var = GLOBAL_VARS.copy() + global_var["user_id"] = GLOBAL_VARS["env_user_id"] + global_var["_cookies"] = GLOBAL_VARS["cookies"] + project_info = RequestControl().api_request_flow(api_file_path=GITLINK_DIR, + key="gitlink_projects_new_project_01", + global_var=global_var) + global_var["repo_owner"] = project_info["repo_owner"] + global_var["repo_identifier"] = project_info["repo_identifier"] + global_var["init_repo_owner"] = project_info["repo_owner"] + global_var["init_repo_identifier"] = project_info["repo_identifier"] + with allure.step("仓库拥有者新建一个疑修"): + issue_info = RequestControl().api_request_flow(api_file_path=GITLINK_DIR, key="gitlink_repo_new_issue_01", + global_var=global_var) + global_var.update(issue_info) + + with allure.step("非项目成员登录"): + global_var["env_login"] = GLOBAL_VARS["t_login"] + global_var["env_password"] = GLOBAL_VARS["t_password"] + login_info = RequestControl().api_request_flow(api_file_path=GITLINK_DIR, key="gitlink_login_01", + global_var=global_var) + GLOBAL_VARS["cookies"] = login_info["cookies"] + + with allure.step("非项目成员,通过疑修index访问疑修详情,访问成功"): + RequestControl().api_request_flow(api_file_path=GITLINK_DIR, key="project_get_issue_detail_01", + global_var=global_var) + with allure.step("非项目成员,通过疑修id访问疑修详情,访问成功"): + RequestControl().api_request_flow(api_file_path=GITLINK_DIR, key="project_get_issue_detail_02", + global_var=global_var) + + with allure.step("仓库拥有者,删除仓库"): + global_var["cookies"] = global_var["_cookies"] + RequestControl().api_request_flow(api_file_path=GITLINK_DIR, key="gitlink_projects_delete_project_01", + global_var=global_var) \ No newline at end of file