feat(release): 生产授权支持页面通道(管理员会话 + 固定确认语句)
页面原本没有任何生产入口,授权/重排/回滚只能带 Bearer 调接口,实际还要 admin 会话。 现在三个端点支持两条通道,门禁语义不变: - 运维通道:Authorization: Bearer <token>,审计记 PRODUCTION_RELEASE_AUTHORIZER_REF - 页面通道:已认证 admin 会话 + 固定确认语句,审计记该管理员用户名 - 请求门禁 / 备份恢复门禁 / Release Worker 执行门禁三者不受影响 - 发布管理第 6–8 步加「授权发布 / 重排 / 回滚」按钮,点击需逐字输入确认语句, 仅 admin 可见;重排沿用原执行授权人,不改写历史 - openapi 与 P6 契约同步;测试:双通道各一条 + 非 admin/错短语拒绝 + 前端按钮与确认门禁
This commit is contained in:
@@ -45,13 +45,58 @@ func TestTargetContractInspectorRejectsMismatchedPlanKB(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// With a 源库 → 目标库 mapping the two sides must read DIFFERENT bases: the
|
||||
// target reads the mapped one, the source keeps reading the tested one. Reading
|
||||
// the mapped base on the source plane made a real release fail with
|
||||
// "source WeKnora release contract mismatch" (the target base is unknown there).
|
||||
func TestTargetContractInspectorSidesPickTheRightBase(t *testing.T) {
|
||||
row := contractRow{values: []any{74, false, uint64(10000), "bge-m3", 1024, "elasticsearch", "chunks"}}
|
||||
mapping := &mappingInspector{sha: strings.Repeat("a", 64)}
|
||||
plan := releasePlanForArchive()
|
||||
plan.TargetKnowledgeBaseID = "prod-kb"
|
||||
|
||||
targetDB := &contractDB{row: row}
|
||||
targetInspector, err := NewTargetContractInspector(TargetContractInspectorConfig{DB: targetDB, Mapping: mapping, KnowledgeBaseID: "kb-safe", TenantID: 10000, IndexName: "chunks"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
targetContract, err := targetInspector.Contract(context.Background(), plan)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if targetContract.KnowledgeBaseID != "prod-kb" {
|
||||
t.Fatalf("target contract kb=%q, want the mapped base", targetContract.KnowledgeBaseID)
|
||||
}
|
||||
if len(targetDB.args) != 1 || targetDB.args[0] != "prod-kb" {
|
||||
t.Fatalf("target read base=%v, want prod-kb", targetDB.args)
|
||||
}
|
||||
|
||||
sourceDB := &contractDB{row: row}
|
||||
sourceInspector, err := NewTargetContractInspector(TargetContractInspectorConfig{DB: sourceDB, Mapping: mapping, KnowledgeBaseID: "kb-safe", TenantID: 10000, IndexName: "chunks", ReadTestedBase: true})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sourceContract, err := sourceInspector.Contract(context.Background(), plan)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if sourceContract.KnowledgeBaseID != "kb-safe" {
|
||||
t.Fatalf("source contract kb=%q, want the tested base", sourceContract.KnowledgeBaseID)
|
||||
}
|
||||
if len(sourceDB.args) != 1 || sourceDB.args[0] != "kb-safe" {
|
||||
t.Fatalf("source read base=%v, want kb-safe", sourceDB.args)
|
||||
}
|
||||
}
|
||||
|
||||
type contractDB struct {
|
||||
row contractRow
|
||||
query string
|
||||
args []any
|
||||
}
|
||||
|
||||
func (d *contractDB) QueryRow(_ context.Context, query string, args ...any) pgx.Row {
|
||||
d.query = query
|
||||
d.args = args
|
||||
return d.row
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user