封堵鉴权旁路与导出 IDOR,DocGov 改服务端身份;对话层 PendingAction 接真实 docgov/taskrun;修复流式租约假死与会话级任务流;加固配置/doc_id/NULL;补齐 slog 与测试;前端 ErrorBoundary 与受控文档重试。 Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package chat
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"chat-agent-system/internal/bizdev"
|
|
"chat-agent-system/internal/config"
|
|
"chat-agent-system/internal/coordinator"
|
|
"chat-agent-system/internal/docgov"
|
|
)
|
|
|
|
func TestExecuteAction_DocGovReviewApprove(t *testing.T) {
|
|
cfg := &config.Config{DataDir: t.TempDir()}
|
|
svc := bizdev.NewService(cfg)
|
|
docGov := svc.DocGov()
|
|
ctx := context.Background()
|
|
|
|
docID := "doc_proj1_research"
|
|
_, err := docGov.CreateOrGetDocument(
|
|
ctx, docID, 1, "research", "调研报告", "V0.5", "",
|
|
1, "张工", 2, "李主管", 3, "王总监",
|
|
)
|
|
if err != nil {
|
|
t.Fatalf("CreateOrGetDocument: %v", err)
|
|
}
|
|
_ = docGov.MarkDocumentContentUpdated(ctx, docID, "hash1", false)
|
|
_, _ = docGov.SubmitForReview(ctx, docID, 1, docgov.RoleAuthor, "张工")
|
|
|
|
sess := &Session{
|
|
UserID: 2,
|
|
Actions: &ActionServices{DocGov: docGov},
|
|
}
|
|
action := &coordinator.PendingAction{
|
|
Kind: "docgov.review_approve",
|
|
DocID: docID,
|
|
Comment: "同意",
|
|
}
|
|
userCtx := &coordinator.UserProjectContext{
|
|
User: coordinator.UserInfo{ID: "2", Name: "李主管"},
|
|
}
|
|
|
|
result, err := sess.executeAction(ctx, action, userCtx)
|
|
if err != nil {
|
|
t.Fatalf("executeAction failed: %v", err)
|
|
}
|
|
if result.DocState != string(docgov.StateApproving) {
|
|
t.Fatalf("expected approving state, got %s", result.DocState)
|
|
}
|
|
reply := renderActionReply(action, result, nil)
|
|
if reply == "" {
|
|
t.Fatal("expected non-empty reply")
|
|
}
|
|
}
|