server: 平台抽象层+bilibili、服务端加密凭据库、角色中间件;web: 精简页面/路由、macOS 客户端(Swift)与多份方案文档;移除误入库的编译产物
This commit is contained in:
@@ -46,7 +46,7 @@ func uploadMaterial(t *testing.T, access string, filename string, content []byte
|
||||
}
|
||||
var data struct {
|
||||
Material models.Material `json:"material"`
|
||||
Dedup bool `json:"dedup"`
|
||||
Dedup bool `json:"dedup"`
|
||||
}
|
||||
_ = json.Unmarshal(env.Data, &data)
|
||||
if data.Dedup {
|
||||
@@ -88,8 +88,8 @@ func TestAccountChallengeFlow(t *testing.T) {
|
||||
List []models.Challenge `json:"list"`
|
||||
}
|
||||
_ = json.Unmarshal(env.Data, &cl)
|
||||
if len(cl.List) != 1 || cl.List[0].Kind != "pending" {
|
||||
t.Fatalf("expect 1 pending challenge, got %d", len(cl.List))
|
||||
if len(cl.List) != 1 || cl.List[0].Kind != "qr" || cl.List[0].QRURL == "" {
|
||||
t.Fatalf("expect 1 web QR challenge, got %d", len(cl.List))
|
||||
}
|
||||
// 挂起 → 重发
|
||||
code, env = doReq(t, "POST", fmt.Sprintf("/api/v1/challenges/%d/suspend", cl.List[0].ID), access, nil)
|
||||
@@ -121,7 +121,7 @@ func TestMaterialAndTaskFlow(t *testing.T) {
|
||||
_ = json.Unmarshal(w.Body.Bytes(), &env)
|
||||
var data struct {
|
||||
Material models.Material `json:"material"`
|
||||
Dedup bool `json:"dedup"`
|
||||
Dedup bool `json:"dedup"`
|
||||
}
|
||||
_ = json.Unmarshal(env.Data, &data)
|
||||
if !data.Dedup || data.Material.ID != matID {
|
||||
@@ -148,10 +148,45 @@ func TestMaterialAndTaskFlow(t *testing.T) {
|
||||
if code != 404 {
|
||||
t.Fatalf("one-time token should 404 on reuse, got %d", code)
|
||||
}
|
||||
accountRespCode, accountEnv := doReq(t, "POST", "/api/v1/accounts", access, gin.H{"platform": "douyin", "accountName": "任务测试账号"})
|
||||
if accountRespCode != 200 || accountEnv.Code != 0 {
|
||||
t.Fatalf("create task account failed: %d %s", accountRespCode, accountEnv.Message)
|
||||
}
|
||||
var taskAccount models.Account
|
||||
_ = json.Unmarshal(accountEnv.Data, &taskAccount)
|
||||
bindCode, bindEnv := doReq(t, "POST", fmt.Sprintf("/api/v1/accounts/%d/bind", taskAccount.ID), access, nil)
|
||||
if bindCode != 200 || bindEnv.Code != 0 {
|
||||
t.Fatalf("task account bind failed: %d %s", bindCode, bindEnv.Message)
|
||||
}
|
||||
var challengeList struct {
|
||||
List []models.Challenge `json:"list"`
|
||||
}
|
||||
_, challengeEnv := doReq(t, "GET", "/api/v1/challenges", access, nil)
|
||||
_ = json.Unmarshal(challengeEnv.Data, &challengeList)
|
||||
if len(challengeList.List) == 0 {
|
||||
t.Fatal("task account challenge missing")
|
||||
}
|
||||
challengeCode, challengeEnv := doReq(t, "POST", fmt.Sprintf("/api/v1/challenges/%d/solve", challengeList.List[0].ID), access, gin.H{"value": "web-test-login"})
|
||||
if challengeCode != 200 || challengeEnv.Code != 0 {
|
||||
t.Fatalf("task account challenge solve failed: %d %s", challengeCode, challengeEnv.Message)
|
||||
}
|
||||
// 后端不能接受尚未登录的账号作为发布目标,即使客户端绕过了筛选。
|
||||
unboundCode, unboundEnv := doReq(t, "POST", "/api/v1/accounts", access, gin.H{"platform": "bilibili", "remark": "未登录账号"})
|
||||
if unboundCode != 200 || unboundEnv.Code != 0 {
|
||||
t.Fatalf("create unbound account failed: %d %s", unboundCode, unboundEnv.Message)
|
||||
}
|
||||
var unbound models.Account
|
||||
_ = json.Unmarshal(unboundEnv.Data, &unbound)
|
||||
badTaskCode, _ := doReq(t, "POST", "/api/v1/tasks", access, gin.H{
|
||||
"title": "不应创建", "content": "", "accountIds": []uint64{unbound.ID}, "materialIds": []uint64{matID},
|
||||
})
|
||||
if badTaskCode != 400 {
|
||||
t.Fatalf("unbound account task should be rejected, got %d", badTaskCode)
|
||||
}
|
||||
// 建任务 → 提交 → 驳回 → 重提 → 通过 → 取消
|
||||
code, env = doReq(t, "POST", "/api/v1/tasks", access, gin.H{
|
||||
"title": "新品发布", "content": "正文", "tags": []string{"新品"},
|
||||
"accountIds": []uint64{1}, "materialIds": []uint64{matID},
|
||||
"accountIds": []uint64{taskAccount.ID}, "materialIds": []uint64{matID},
|
||||
})
|
||||
if code != 200 || env.Code != 0 {
|
||||
t.Fatalf("create task failed: %d %s", code, env.Message)
|
||||
@@ -189,12 +224,14 @@ func TestMaterialAndTaskFlow(t *testing.T) {
|
||||
}
|
||||
code, env = doReq(t, "GET", fmt.Sprintf("/api/v1/tasks/%d", taskRow.ID), access, nil)
|
||||
_ = json.Unmarshal(env.Data, &taskRow)
|
||||
if taskRow.Status != "queued" {
|
||||
t.Fatalf("expect queued, got %s", taskRow.Status)
|
||||
if taskRow.Status != "queued" && taskRow.Status != "dispatched" && taskRow.Status != "running" && taskRow.Status != "success" {
|
||||
t.Fatalf("expect web executor to accept task, got %s", taskRow.Status)
|
||||
}
|
||||
code, _ = doReq(t, "POST", fmt.Sprintf("/api/v1/tasks/%d/cancel", taskRow.ID), access, nil)
|
||||
if code != 200 {
|
||||
t.Fatalf("cancel failed: %d", code)
|
||||
if taskRow.Status == "queued" || taskRow.Status == "dispatched" || taskRow.Status == "running" {
|
||||
code, _ = doReq(t, "POST", fmt.Sprintf("/api/v1/tasks/%d/cancel", taskRow.ID), access, nil)
|
||||
if code != 200 {
|
||||
t.Fatalf("cancel failed: %d", code)
|
||||
}
|
||||
}
|
||||
// 通知:驳回+通过 2 条
|
||||
code, env = doReq(t, "GET", "/api/v1/notifications", access, nil)
|
||||
|
||||
Reference in New Issue
Block a user