openTT/test_issue_permission.py

101 lines
5.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
@FileNametest_issue_permission.py.py
@Description
@AuthorFloraachy
@Time2024/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)