Unify auth middleware and remove X-User-ID trust, add project_members authorization, sandbox workspaces via resolver, and admin-only reconcile by run_id. Introduce goose migrations with startup schema gate, fail closed when DB unavailable outside explicit ALLOW_IN_MEMORY, bundle web/dist in app Dockerfile, and remove frontend pseudo-login fallback.
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
package bizdev
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"chat-agent-system/internal/config"
|
|
)
|
|
|
|
func TestExecuteTask_TestManagerAfterApprovedUpstream(t *testing.T) {
|
|
svc := MustNewService(t, &config.Config{DataDir: t.TempDir(), AgentBackend: "stub"})
|
|
ctx := context.Background()
|
|
srDocID := "doc_proj1001_system_reqs"
|
|
_, err := svc.DocGov().CreateOrGetDocument(
|
|
ctx, srDocID, 1001, "system_reqs", "系统需求规格书", "V0.5", "",
|
|
2, "张工", 3, "李主管", 4, "王总监",
|
|
)
|
|
if err != nil {
|
|
t.Fatalf("CreateOrGetDocument: %v", err)
|
|
}
|
|
_ = svc.DocGov().MarkDocumentContentUpdated(ctx, srDocID, "hash_v1", false)
|
|
_, _ = svc.DocGov().SubmitForReview(ctx, srDocID, 2, "author", "张工")
|
|
_, _ = svc.DocGov().ReviewApprove(ctx, srDocID, 3, "reviewer", "李主管", "同意")
|
|
_, err = svc.DocGov().ApproverApprove(ctx, srDocID, 4, "approver", "王总监", "批准")
|
|
if err != nil {
|
|
t.Fatalf("ApproverApprove: %v", err)
|
|
}
|
|
|
|
res, err := svc.ExecuteTask(ctx, TaskRunRequest{
|
|
TaskKey: "test_manager",
|
|
ProjectID: 1001,
|
|
ProjectName: "智能肺功能仪",
|
|
Backend: "stub",
|
|
Timeout: 30 * time.Second,
|
|
UserID: 2,
|
|
Materials: []MaterialInput{{
|
|
Filename: "upstream_system_requirements.md",
|
|
Content: []byte("# 系统需求\n| REQ-01 | 测量流量误差 <= 3% | 测试 | 高 |\n"),
|
|
}},
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("ExecuteTask error: %v reason=%s", err, res.ErrorReason)
|
|
}
|
|
if res == nil {
|
|
t.Fatal("expected task result")
|
|
}
|
|
}
|