- 为什么:白盒复检 P1——平台侧文件详情抽屉 503 只有文案,需求 §8 要求跳转链接;/monitor/tasks 行没有 URL。 - 做什么:抽出 KnowledgeBaseConsoleURL,finding 与 /monitor/tasks 共用同一拼接;handler 用当前生效测试端点填 weknora_url,前端抽屉透传给 WeKnoraProgress;openapi/需求 §7 同步。 - 补证据:stage=weknora 真库合并用例;对账扫描改为真实 HTTP 桩断言零写;progress 投影断言上游密钥字段不外泄。 - 验证:make verify 17 项 success;go test ./... exit 0;web 648 测试 + build;monitor_tasks 真库集成用例 PASS。
This commit is contained in:
@@ -68,3 +68,42 @@ func TestRuntimeProviderUnavailableAndNotFound(t *testing.T) {
|
||||
t.Fatalf("missing document err=%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// The progress passthrough is a projection, not a proxy: whatever extra fields
|
||||
// the platform endpoint returns (keys, authorization headers, token echoes) must
|
||||
// never reach the browser. This guards the shape if someone later switches to
|
||||
// forwarding the upstream body.
|
||||
func TestRuntimeProviderDropsSensitiveUpstreamFields(t *testing.T) {
|
||||
const secret = "leak-sentinel"
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{"success": true, "data": map[string]any{
|
||||
"document": map[string]any{
|
||||
"id": "doc-1", "parse_status": "completed", "ingestion_status": "completed", "wiki_status": "none",
|
||||
"api_key": secret, "apiKey": secret, "authorization": "Bearer " + secret,
|
||||
"headers": map[string]any{"X-API-Key": secret},
|
||||
},
|
||||
"failures": []map[string]any{},
|
||||
"has_more_failures": false,
|
||||
"api_key": secret,
|
||||
}})
|
||||
}))
|
||||
defer server.Close()
|
||||
provider := NewRuntimeProvider(RuntimeConfig{
|
||||
BaseURL: func(context.Context) string { return server.URL },
|
||||
APIKey: "runtime-key", Timeout: 5 * time.Second,
|
||||
})
|
||||
progress, err := provider.DocumentProgress(context.Background(), "doc-1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
payload, err := json.Marshal(progress)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.Contains(string(payload), secret) || strings.Contains(string(payload), "Bearer ") {
|
||||
t.Fatalf("progress leaked upstream credentials: %s", payload)
|
||||
}
|
||||
if progress.DocumentID != "doc-1" || progress.ParseStatus != "completed" {
|
||||
t.Fatalf("projection dropped real fields: %#v", progress)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user