feat: 强化打包配置与服务安全
This commit is contained in:
+56
-1
@@ -1,4 +1,5 @@
|
||||
"""任务接口测试"""
|
||||
import json
|
||||
from unittest.mock import patch, AsyncMock
|
||||
|
||||
|
||||
@@ -22,7 +23,7 @@ def test_create_task(mock_queue, client, tmp_config):
|
||||
data = resp.json()
|
||||
assert data["status"] == "pending"
|
||||
assert data["app_name"] == "测试App"
|
||||
assert data["scheme_name"] == "testScheme"
|
||||
assert data["scheme_name"] == "readoor31"
|
||||
assert data["branch"] == "main"
|
||||
assert data["build_type"] == "Ad_Hoc"
|
||||
|
||||
@@ -61,6 +62,60 @@ def test_create_task_invalid_scheme(mock_queue, client, tmp_config):
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
@patch("backend.services.build_queue.build_queue")
|
||||
def test_create_task_rejects_unconfigured_certificate_type(mock_queue, client, tmp_config):
|
||||
config = json.loads(tmp_config.read_text())
|
||||
config["apps"]["1"]["certificates"] = {
|
||||
"Ad_Hoc": {"name": "com.test.app"},
|
||||
}
|
||||
tmp_config.write_text(json.dumps(config))
|
||||
|
||||
resp = client.post("/api/tasks", json={
|
||||
"app_id": "1", "build_type": "App_Store", "scheme_id": "1", "branch": "main",
|
||||
})
|
||||
|
||||
assert resp.status_code == 400
|
||||
assert "未配置 App_Store 证书" in resp.json()["detail"]
|
||||
|
||||
|
||||
@patch("backend.services.build_queue.build_queue")
|
||||
def test_create_task_rejects_disallowed_special_app_scheme(mock_queue, client, tmp_config):
|
||||
config = json.loads(tmp_config.read_text())
|
||||
config["apps"]["1"].update({
|
||||
"name": "英汉大词典",
|
||||
"certificates": {"Ad_Hoc": {"name": "com.dictionary.app"}},
|
||||
})
|
||||
config["schemes"] = {
|
||||
"1": {"name": "readoor31"},
|
||||
"2": {"name": "readoorDict"},
|
||||
}
|
||||
tmp_config.write_text(json.dumps(config))
|
||||
|
||||
resp = client.post("/api/tasks", json={
|
||||
"app_id": "1", "build_type": "Ad_Hoc", "scheme_id": "1", "branch": "main",
|
||||
})
|
||||
|
||||
assert resp.status_code == 400
|
||||
assert "readoorDict" in resp.json()["detail"]
|
||||
|
||||
|
||||
@patch("backend.services.build_queue.build_queue")
|
||||
def test_create_task_rejects_non_default_scheme_for_regular_app(mock_queue, client, tmp_config):
|
||||
config = json.loads(tmp_config.read_text())
|
||||
config["schemes"] = {
|
||||
"1": {"name": "readoor31"},
|
||||
"2": {"name": "readoorDict"},
|
||||
}
|
||||
tmp_config.write_text(json.dumps(config))
|
||||
|
||||
resp = client.post("/api/tasks", json={
|
||||
"app_id": "1", "build_type": "Ad_Hoc", "scheme_id": "2", "branch": "main",
|
||||
})
|
||||
|
||||
assert resp.status_code == 400
|
||||
assert "readoor31OtherPay" in resp.json()["detail"]
|
||||
|
||||
|
||||
@patch("backend.services.build_queue.build_queue")
|
||||
def test_list_tasks_after_create(mock_queue, client, tmp_config):
|
||||
mock_queue.submit = AsyncMock()
|
||||
|
||||
Reference in New Issue
Block a user