feat(auth): accounts, sessions, RBAC and server-stamped actors
上线账号权限管理(后端): - 迁移 000032:users + user_sessions(token 只存 sha256,服务端可即时撤销) - bcrypt 密码、8 次失败锁 15 分钟、统一 401 错误防用户名枚举 - 三角色 viewer/engineer/admin;HttpOnly+SameSite=Lax 会话 cookie,滑动续期 - 强制改密锁定:must_change_password 会话只能走 auth 端点;首登 dobotai - bootstrap:users 表为空时创建 admin(初始密码 dobotai,强制改密) - 生产双闸授权/回滚/失败重试收敛为 admin 角色;AuthorizedBy 用会话身份 - 全部业务写端点删除手填 actor 字段(operator_ref/reviewer_ref/created_by/ sealed_by/confirmed_by),服务端从会话注入;auth 关闭的开发 socket 回退 system - 成员管理 API:列表/创建/改角色/启停/重置密码,最后一名 active admin 保护 - RBAC 矩阵纯函数契约测试 + 中间件行为测试(登录/锁定/角色/审计戳) - 附带修复:GET /api/v1/users 曾被 GET=viewer 规则误放行(测试抓到)
This commit is contained in:
@@ -118,7 +118,7 @@ func TestHandlerListsJobFailuresAndRunsServerSideBatchRetry(t *testing.T) {
|
||||
|
||||
recorder = httptest.NewRecorder()
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/test-publications/retry-batch",
|
||||
strings.NewReader(`{"publication_ids":["tp-1","tp-2"],"operator_ref":"姚工","reason":"解析服务恢复"}`))
|
||||
strings.NewReader(`{"publication_ids":["tp-1","tp-2"],"reason":"解析服务恢复"}`))
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
request.Header.Set("Idempotency-Key", "op-batch-1")
|
||||
handler.ServeHTTP(recorder, request)
|
||||
@@ -145,14 +145,14 @@ func TestHandlerListsJobFailuresAndRunsServerSideBatchRetry(t *testing.T) {
|
||||
// Missing Idempotency-Key is rejected before touching the store.
|
||||
recorder = httptest.NewRecorder()
|
||||
handler.ServeHTTP(recorder, httptest.NewRequest(http.MethodPost, "/api/v1/test-publications/retry-batch",
|
||||
strings.NewReader(`{"publication_ids":["tp-1"],"operator_ref":"姚工","reason":"r"}`)))
|
||||
strings.NewReader(`{"publication_ids":["tp-1"],"reason":"r"}`)))
|
||||
if recorder.Code != http.StatusBadRequest {
|
||||
t.Fatalf("missing key status = %d", recorder.Code)
|
||||
}
|
||||
// Duplicate ids rejected.
|
||||
recorder = httptest.NewRecorder()
|
||||
dup := httptest.NewRequest(http.MethodPost, "/api/v1/test-publications/retry-batch",
|
||||
strings.NewReader(`{"publication_ids":["tp-1","tp-1"],"operator_ref":"姚工","reason":"r"}`))
|
||||
strings.NewReader(`{"publication_ids":["tp-1","tp-1"],"reason":"r"}`))
|
||||
dup.Header.Set("Idempotency-Key", "op-dup")
|
||||
handler.ServeHTTP(recorder, dup)
|
||||
if recorder.Code != http.StatusBadRequest {
|
||||
@@ -224,7 +224,7 @@ func TestHandlerSetsListsAndClearsAuditedScopeRules(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
set := httptest.NewRecorder()
|
||||
request := httptest.NewRequest(http.MethodPut, "/api/v1/scope-rules", bytes.NewBufferString(`{"target_type":"directory","connection_id":"conn-safe","directory_path":"产品","visibility":"internal","operator_ref":"engineer-1","reason":"内部资料"}`))
|
||||
request := httptest.NewRequest(http.MethodPut, "/api/v1/scope-rules", bytes.NewBufferString(`{"target_type":"directory","connection_id":"conn-safe","directory_path":"产品","visibility":"internal","reason":"内部资料"}`))
|
||||
request.Header.Set("Idempotency-Key", "op-scope-set")
|
||||
handler.ServeHTTP(set, request)
|
||||
if set.Code != http.StatusOK || store.scopeRuleRequest.ConnectionID != "conn-safe" || store.scopeRuleOperationID != "op-scope-set" || store.scopeRuleRequest.Clear || store.scopeRuleRequest.Now != now || !strings.Contains(set.Body.String(), `"operation":"created"`) {
|
||||
@@ -237,7 +237,7 @@ func TestHandlerSetsListsAndClearsAuditedScopeRules(t *testing.T) {
|
||||
t.Fatalf("list=%d id=%q body=%s", list.Code, store.scopeRuleConnectionID, list.Body.String())
|
||||
}
|
||||
clear := httptest.NewRecorder()
|
||||
request = httptest.NewRequest(http.MethodDelete, "/api/v1/scope-rules", bytes.NewBufferString(`{"target_type":"directory","connection_id":"conn-safe","directory_path":"产品","operator_ref":"engineer-1","reason":"恢复来源设置"}`))
|
||||
request = httptest.NewRequest(http.MethodDelete, "/api/v1/scope-rules", bytes.NewBufferString(`{"target_type":"directory","connection_id":"conn-safe","directory_path":"产品","reason":"恢复来源设置"}`))
|
||||
request.Header.Set("Idempotency-Key", "op-scope-clear")
|
||||
handler.ServeHTTP(clear, request)
|
||||
if clear.Code != http.StatusOK || !store.scopeRuleRequest.Clear || store.scopeRuleRequest.Visibility != "" || !strings.Contains(clear.Body.String(), `"operation":"created"`) {
|
||||
@@ -249,7 +249,7 @@ func TestHandlerRejectsUnsafeScopeRuleBeforeStore(t *testing.T) {
|
||||
store := &fakeJobStore{}
|
||||
handler, _ := NewHandler(Config{Store: store, Now: time.Now})
|
||||
response := httptest.NewRecorder()
|
||||
request := httptest.NewRequest(http.MethodPut, "/api/v1/scope-rules", bytes.NewBufferString(`{"target_type":"directory","connection_id":"conn-safe","directory_path":"../private","visibility":"external","operator_ref":"engineer","reason":"bad"}`))
|
||||
request := httptest.NewRequest(http.MethodPut, "/api/v1/scope-rules", bytes.NewBufferString(`{"target_type":"directory","connection_id":"conn-safe","directory_path":"../private","visibility":"external","reason":"bad"}`))
|
||||
handler.ServeHTTP(response, request)
|
||||
if response.Code != http.StatusBadRequest || store.scopeRuleRequest.TargetType != "" {
|
||||
t.Fatalf("status=%d request=%#v", response.Code, store.scopeRuleRequest)
|
||||
@@ -354,7 +354,7 @@ func TestHandlerRoutesSelectedCatalogFilesToServerBoundScopeKB(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
response := httptest.NewRecorder()
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/route", bytes.NewBufferString(`{"connection_id":"conn-cat","node_ids":["file-a","file-b"],"visibility":"internal","operator_ref":"engineer-1","reason":"当前页批量标注"}`))
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/route", bytes.NewBufferString(`{"connection_id":"conn-cat","node_ids":["file-a","file-b"],"visibility":"internal","reason":"当前页批量标注"}`))
|
||||
request.Header.Set("Idempotency-Key", "op-route-internal")
|
||||
handler.ServeHTTP(response, request)
|
||||
if response.Code != http.StatusAccepted || store.catalogRouteRequest.TargetKnowledgeBaseID != "kb-internal" || store.catalogRouteRequest.Now != now || store.catalogRouteRequest.Visibility != governance.VisibilityInternal {
|
||||
@@ -378,7 +378,7 @@ func TestHandlerRoutesBothScopesInOneAtomicRequest(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
response := httptest.NewRecorder()
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/route", bytes.NewBufferString(`{"connection_id":"conn-cat","node_ids":["file-a"],"policy":"both","operator_ref":"engineer-1","reason":"同时供内外知识库使用"}`))
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/route", bytes.NewBufferString(`{"connection_id":"conn-cat","node_ids":["file-a"],"policy":"both","reason":"同时供内外知识库使用"}`))
|
||||
request.Header.Set("Idempotency-Key", "op-route-both")
|
||||
handler.ServeHTTP(response, request)
|
||||
if response.Code != http.StatusAccepted || store.catalogRouteRequest.Visibility != governance.VisibilityBoth {
|
||||
@@ -399,7 +399,7 @@ func TestHandlerAcceptsBlockedPolicyWithoutAConfiguredTarget(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
response := httptest.NewRecorder()
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/route", bytes.NewBufferString(`{"connection_id":"conn-cat","node_ids":["file-a"],"policy":"blocked","operator_ref":"engineer-1","reason":"资料已禁止导入"}`))
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/route", bytes.NewBufferString(`{"connection_id":"conn-cat","node_ids":["file-a"],"policy":"blocked","reason":"资料已禁止导入"}`))
|
||||
request.Header.Set("Idempotency-Key", "op-route-blocked")
|
||||
handler.ServeHTTP(response, request)
|
||||
if response.Code != http.StatusAccepted || store.catalogRouteRequest.Visibility != governance.VisibilityBlocked || len(store.catalogRouteRequest.TargetKnowledgeBaseIDs) != 0 {
|
||||
@@ -566,7 +566,7 @@ func TestHandlerReleaseChangeSetEndpoints(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body := strings.NewReader(`{"name":"9月发布","created_by":"yaozhanghao"}`)
|
||||
body := strings.NewReader(`{"name":"9月发布"}`)
|
||||
generated := httptest.NewRecorder()
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/release-change-sets", body)
|
||||
request.Header.Set("Idempotency-Key", "11111111-1111-4111-8111-111111111111")
|
||||
@@ -576,14 +576,14 @@ func TestHandlerReleaseChangeSetEndpoints(t *testing.T) {
|
||||
}
|
||||
// Missing header → 400 (C4 contract).
|
||||
noKey := httptest.NewRecorder()
|
||||
handler.ServeHTTP(noKey, httptest.NewRequest(http.MethodPost, "/api/v1/release-change-sets", strings.NewReader(`{"name":"x","created_by":"y"}`)))
|
||||
handler.ServeHTTP(noKey, httptest.NewRequest(http.MethodPost, "/api/v1/release-change-sets", strings.NewReader(`{"name":"x"}`)))
|
||||
if noKey.Code != http.StatusBadRequest {
|
||||
t.Fatalf("generate without key = %d", noKey.Code)
|
||||
}
|
||||
// Empty plan → 422 honest reason.
|
||||
store.generateChangeSetErr = postgresstore.ErrReleaseChangeSetEmpty
|
||||
empty := httptest.NewRecorder()
|
||||
request = httptest.NewRequest(http.MethodPost, "/api/v1/release-change-sets", strings.NewReader(`{"name":"x","created_by":"y"}`))
|
||||
request = httptest.NewRequest(http.MethodPost, "/api/v1/release-change-sets", strings.NewReader(`{"name":"x"}`))
|
||||
request.Header.Set("Idempotency-Key", "22222222-2222-4222-8222-222222222222")
|
||||
handler.ServeHTTP(empty, request)
|
||||
if empty.Code != http.StatusUnprocessableEntity {
|
||||
@@ -593,7 +593,7 @@ func TestHandlerReleaseChangeSetEndpoints(t *testing.T) {
|
||||
// Confirm path with envelope.
|
||||
store.confirmReleaseSetResult = governance.ReleaseChangeSet{ID: "rcs-1", State: "confirmed"}
|
||||
confirmed := httptest.NewRecorder()
|
||||
request = httptest.NewRequest(http.MethodPost, "/api/v1/release-change-sets/rcs-1/confirm", strings.NewReader(`{"confirmed_by":"yaozhanghao"}`))
|
||||
request = httptest.NewRequest(http.MethodPost, "/api/v1/release-change-sets/rcs-1/confirm", strings.NewReader(`{}`))
|
||||
request.Header.Set("Idempotency-Key", "33333333-3333-4333-8333-333333333333")
|
||||
handler.ServeHTTP(confirmed, request)
|
||||
if confirmed.Code != http.StatusOK || store.confirmReleaseSetRequest.ChangeSetID != "rcs-1" || !strings.Contains(confirmed.Body.String(), `"operation":"created"`) {
|
||||
@@ -602,7 +602,7 @@ func TestHandlerReleaseChangeSetEndpoints(t *testing.T) {
|
||||
// State conflict → 409.
|
||||
store.confirmReleaseSetErr = postgresstore.ErrReleaseChangeSetStateConflict
|
||||
conflict := httptest.NewRecorder()
|
||||
request = httptest.NewRequest(http.MethodPost, "/api/v1/release-change-sets/rcs-1/confirm", strings.NewReader(`{"confirmed_by":"yaozhanghao"}`))
|
||||
request = httptest.NewRequest(http.MethodPost, "/api/v1/release-change-sets/rcs-1/confirm", strings.NewReader(`{}`))
|
||||
request.Header.Set("Idempotency-Key", "44444444-4444-4444-8444-444444444444")
|
||||
handler.ServeHTTP(conflict, request)
|
||||
if conflict.Code != http.StatusConflict {
|
||||
@@ -629,7 +629,7 @@ func TestHandlerReleaseChangeSetEndpoints(t *testing.T) {
|
||||
// Batch citing a change set passes the binding through; unconfirmed → 422.
|
||||
store.createBatchResult = governance.ReleaseBatch{ID: "rb-1"}
|
||||
batch := httptest.NewRecorder()
|
||||
request = httptest.NewRequest(http.MethodPost, "/api/v1/release-batches", strings.NewReader(`{"name":"批次","created_by":"yaozhanghao","publication_ids":["tp-1"],"delete_publication_ids":[],"release_change_set_id":"rcs-1"}`))
|
||||
request = httptest.NewRequest(http.MethodPost, "/api/v1/release-batches", strings.NewReader(`{"name":"批次","publication_ids":["tp-1"],"delete_publication_ids":[],"release_change_set_id":"rcs-1"}`))
|
||||
request.Header.Set("Idempotency-Key", "55555555-5555-4555-8555-555555555555")
|
||||
handler.ServeHTTP(batch, request)
|
||||
if batch.Code != http.StatusCreated || store.createBatchRequest.ReleaseChangeSetID != "rcs-1" {
|
||||
@@ -637,7 +637,7 @@ func TestHandlerReleaseChangeSetEndpoints(t *testing.T) {
|
||||
}
|
||||
store.createBatchErr = postgresstore.ErrReleaseChangeSetUnconfirmed
|
||||
unconf := httptest.NewRecorder()
|
||||
request = httptest.NewRequest(http.MethodPost, "/api/v1/release-batches", strings.NewReader(`{"name":"批次","created_by":"yaozhanghao","publication_ids":["tp-1"],"delete_publication_ids":[],"release_change_set_id":"rcs-9"}`))
|
||||
request = httptest.NewRequest(http.MethodPost, "/api/v1/release-batches", strings.NewReader(`{"name":"批次","publication_ids":["tp-1"],"delete_publication_ids":[],"release_change_set_id":"rcs-9"}`))
|
||||
request.Header.Set("Idempotency-Key", "66666666-6666-4666-8666-666666666666")
|
||||
handler.ServeHTTP(unconf, request)
|
||||
if unconf.Code != http.StatusUnprocessableEntity || !strings.Contains(unconf.Body.String(), "confirmed") {
|
||||
@@ -922,7 +922,7 @@ func TestHandlerRecordsPublicationReview(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/review-candidates/tp-safe/decision", bytes.NewBufferString(`{"decision":"approved","decided_visibility":"internal","reviewer_ref":"engineer-1","decision_code":"approved_for_release"}`))
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/review-candidates/tp-safe/decision", bytes.NewBufferString(`{"decision":"approved","decided_visibility":"internal","decision_code":"approved_for_release"}`))
|
||||
request.Header.Set("Idempotency-Key", "op-review-1")
|
||||
response := httptest.NewRecorder()
|
||||
handler.ServeHTTP(response, request)
|
||||
@@ -991,18 +991,18 @@ func TestHandlerCreatesAndSealsReleaseBatchWithoutReleaseJob(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
createRequest := httptest.NewRequest(http.MethodPost, "/api/v1/release-batches", bytes.NewBufferString(`{"name":"Batch","created_by":"engineer-1","publication_ids":["tp-safe"],"delete_publication_ids":["tp-delete"]}`))
|
||||
createRequest := httptest.NewRequest(http.MethodPost, "/api/v1/release-batches", bytes.NewBufferString(`{"name":"Batch","publication_ids":["tp-safe"],"delete_publication_ids":["tp-delete"]}`))
|
||||
createRequest.Header.Set("Idempotency-Key", "op-batch-create")
|
||||
createResponse := httptest.NewRecorder()
|
||||
handler.ServeHTTP(createResponse, createRequest)
|
||||
if createResponse.Code != http.StatusCreated || len(store.createBatchRequest.PublicationIDs) != 1 || len(store.createBatchRequest.DeletePublicationIDs) != 1 || store.createBatchRequest.DeletePublicationIDs[0] != "tp-delete" {
|
||||
t.Fatalf("create status=%d request=%#v body=%s", createResponse.Code, store.createBatchRequest, createResponse.Body.String())
|
||||
}
|
||||
sealRequest := httptest.NewRequest(http.MethodPost, "/api/v1/release-batches/rb-safe/seal", bytes.NewBufferString(`{"sealed_by":"engineer-2"}`))
|
||||
sealRequest := httptest.NewRequest(http.MethodPost, "/api/v1/release-batches/rb-safe/seal", bytes.NewBufferString(`{}`))
|
||||
sealRequest.Header.Set("Idempotency-Key", "op-batch-seal")
|
||||
sealResponse := httptest.NewRecorder()
|
||||
handler.ServeHTTP(sealResponse, sealRequest)
|
||||
if sealResponse.Code != http.StatusOK || store.sealBatchRequest.BatchID != "rb-safe" || store.sealBatchRequest.SealedBy != "engineer-2" {
|
||||
if sealResponse.Code != http.StatusOK || store.sealBatchRequest.BatchID != "rb-safe" || store.sealBatchRequest.SealedBy != "system" {
|
||||
t.Fatalf("seal status=%d request=%#v body=%s", sealResponse.Code, store.sealBatchRequest, sealResponse.Body.String())
|
||||
}
|
||||
if store.enqueued.Type != "" {
|
||||
@@ -1271,7 +1271,7 @@ func TestHandlerConfirmsChangeSetItems(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
response := httptest.NewRecorder()
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/change-sets/cs-1/confirm", bytes.NewBufferString(`{"item_seqs":[4,9],"operator_ref":"engineer-1","reason":"确认新增与更新"}`))
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/change-sets/cs-1/confirm", bytes.NewBufferString(`{"item_seqs":[4,9],"reason":"确认新增与更新"}`))
|
||||
request.Header.Set("Idempotency-Key", "op-confirm-1")
|
||||
handler.ServeHTTP(response, request)
|
||||
if response.Code != http.StatusOK || store.confirmChangeSetOperationID != "op-confirm-1" || len(store.confirmChangeSetRequest.ItemSeqs) != 2 || store.confirmChangeSetRequest.InternalTargetKBID != "kb-internal" || store.confirmChangeSetRequest.Now != now {
|
||||
@@ -1282,19 +1282,19 @@ func TestHandlerConfirmsChangeSetItems(t *testing.T) {
|
||||
}
|
||||
missing := httptest.NewRecorder()
|
||||
store.confirmChangeSetErr = postgresstore.ErrCatalogChangeSetNotFound
|
||||
missingRequest := httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/change-sets/cs-nope/confirm", bytes.NewBufferString(`{"item_seqs":[1],"operator_ref":"engineer-1","reason":"确认"}`))
|
||||
missingRequest := httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/change-sets/cs-nope/confirm", bytes.NewBufferString(`{"item_seqs":[1],"reason":"确认"}`))
|
||||
missingRequest.Header.Set("Idempotency-Key", "op-confirm-missing")
|
||||
handler.ServeHTTP(missing, missingRequest)
|
||||
if missing.Code != http.StatusNotFound {
|
||||
t.Fatalf("missing change set status=%d", missing.Code)
|
||||
}
|
||||
bad := httptest.NewRecorder()
|
||||
handler.ServeHTTP(bad, httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/change-sets/cs-1/confirm", bytes.NewBufferString(`{"item_seqs":[],"operator_ref":"engineer-1","reason":"确认"}`)))
|
||||
handler.ServeHTTP(bad, httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/change-sets/cs-1/confirm", bytes.NewBufferString(`{"item_seqs":[],"reason":"确认"}`)))
|
||||
if bad.Code != http.StatusBadRequest {
|
||||
t.Fatalf("empty selection status=%d", bad.Code)
|
||||
}
|
||||
noKey := httptest.NewRecorder()
|
||||
handler.ServeHTTP(noKey, httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/change-sets/cs-1/confirm", bytes.NewBufferString(`{"item_seqs":[1],"operator_ref":"engineer-1","reason":"确认"}`)))
|
||||
handler.ServeHTTP(noKey, httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/change-sets/cs-1/confirm", bytes.NewBufferString(`{"item_seqs":[1],"reason":"确认"}`)))
|
||||
if noKey.Code != http.StatusBadRequest {
|
||||
t.Fatalf("missing idempotency key status=%d", noKey.Code)
|
||||
}
|
||||
@@ -1307,12 +1307,12 @@ func TestHandlerStartsConfirmedTestPublications(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/test-publications/start", bytes.NewBufferString(`{"publication_ids":["pub-a","pub-b"],"operator_ref":"engineer-1","reason":"确认差异后开始处理"}`))
|
||||
request := httptest.NewRequest(http.MethodPost, "/api/v1/test-publications/start", bytes.NewBufferString(`{"publication_ids":["pub-a","pub-b"],"reason":"确认差异后开始处理"}`))
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
request.Header.Set("Idempotency-Key", "op-processing-start")
|
||||
response := httptest.NewRecorder()
|
||||
handler.ServeHTTP(response, request)
|
||||
if response.Code != http.StatusAccepted || store.startPublicationsRequest.Now != now || len(store.startPublicationsRequest.PublicationIDs) != 2 || store.startPublicationsRequest.OperatorRef != "engineer-1" || !strings.Contains(response.Body.String(), `"operation":"created"`) {
|
||||
if response.Code != http.StatusAccepted || store.startPublicationsRequest.Now != now || len(store.startPublicationsRequest.PublicationIDs) != 2 || store.startPublicationsRequest.OperatorRef != "system" || !strings.Contains(response.Body.String(), `"operation":"created"`) {
|
||||
t.Fatalf("status=%d request=%#v body=%s", response.Code, store.startPublicationsRequest, response.Body.String())
|
||||
}
|
||||
if !strings.Contains(response.Body.String(), `"started":1`) || strings.Contains(response.Body.String(), "test_kb_id") {
|
||||
@@ -1378,7 +1378,7 @@ func TestHandlerRejectsCatalogMutationsWithoutOperationID(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, request := range []*http.Request{
|
||||
httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/route", bytes.NewBufferString(`{"connection_id":"conn-cat","node_ids":["file-a"],"policy":"internal","operator_ref":"engineer-1","reason":"人工标注"}`)),
|
||||
httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/route", bytes.NewBufferString(`{"connection_id":"conn-cat","node_ids":["file-a"],"policy":"internal","reason":"人工标注"}`)),
|
||||
httptest.NewRequest(http.MethodPost, "/api/v1/source-catalog/sources/conn-cat/refresh", nil),
|
||||
} {
|
||||
response := httptest.NewRecorder()
|
||||
|
||||
Reference in New Issue
Block a user