feat(settings): 知识库绑定按环境一次保存连接与内外库
原「知识库映射 → WeKnora 连接」把地址、文件和绑定分散在多处,页面无法输入密钥, 也看不到候选实例真实可读的库。现在测试 090 / 生产 090 各自一个工作区:草稿填地址 与 API Key,服务器真实分页列库并区分空库/无权限/不可达,选内外库后一次保存连接与 绑定,回读真实生效值。 服务端以修订号 + 行锁 + 单事务写连接、绑定与待入库重排;旧部署无新行时继续使用文件 凭据/默认绑定。密钥只存 AES-256-GCM 密文,主密钥在独立文件;换地址必须重录,旧密钥 不转发、不跨环境取用。消费端(readiness/上传轮询/列库/探活/生产列库)统一从该存储 解析当前连接,避免只保存了页面数据。 验证:go test ./...;前端 606 项;隔离 PostgreSQL 集成用例覆盖保存/冲突/重排/拒错; make verify 在本提交上执行(结果见交付说明)。
This commit is contained in:
+79
-33
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@@ -17,6 +18,7 @@ import (
|
||||
"knowledge-governance/internal/backuphost"
|
||||
"knowledge-governance/internal/dingtalkdiscovery"
|
||||
"knowledge-governance/internal/httpapi"
|
||||
"knowledge-governance/internal/kbbinding"
|
||||
"knowledge-governance/internal/libraryhandoff"
|
||||
"knowledge-governance/internal/monitoring"
|
||||
postgresstore "knowledge-governance/internal/platform/postgres"
|
||||
@@ -98,36 +100,81 @@ func run(ctx context.Context, getenv func(string) string) error {
|
||||
// 这里的真源;容器 env 只作为未在网页配置时的兜底。凭据与发布目标仍留在
|
||||
// release 运行时配置(RELEASE_CONFIG_FILE)里,不经网页也不落明文。
|
||||
actionStore := postgresstore.NewStore(pool)
|
||||
productionEndpointResolver := func(resolveCtx context.Context) string {
|
||||
settings, err := actionStore.GetActiveUISettings(resolveCtx)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return settings.ProductionWeKnoraBaseURL
|
||||
}
|
||||
testEndpointResolver := func(resolveCtx context.Context) string {
|
||||
settings, err := actionStore.GetActiveUISettings(resolveCtx)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return settings.TestWeKnoraBaseURL
|
||||
}
|
||||
// P10 readiness 与执行链看同一目标:网页保存的端点、当前持久化绑定、同一份
|
||||
// API Key。启动时只捕获 resolver,不捕获任何一项的值(F13:旧 env 绑定 404)。
|
||||
readinessResolver := newWeKnoraReadinessResolver(
|
||||
func(resolveCtx context.Context) string {
|
||||
if saved := testEndpointResolver(resolveCtx); saved != "" {
|
||||
return saved
|
||||
kbBindings := kbbinding.New(pool, kbbinding.Options{
|
||||
MasterKeyFile: config.WeKnoraBindingMasterKeyFile,
|
||||
Timeout: 10 * time.Second,
|
||||
AllowDockerHTTP: map[string]bool{
|
||||
kbbinding.EnvTest: config.TestWeKnoraAllowDockerHTTP,
|
||||
kbbinding.EnvProduction: config.ProductionWeKnoraAllowDockerHTTP,
|
||||
},
|
||||
LegacyBaseURL: func(resolveCtx context.Context, env string) string {
|
||||
settings, err := actionStore.GetActiveUISettings(resolveCtx)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if env == kbbinding.EnvProduction {
|
||||
if value := strings.TrimSpace(settings.ProductionWeKnoraBaseURL); value != "" {
|
||||
return value
|
||||
}
|
||||
return config.ProductionWeKnoraBaseURL
|
||||
}
|
||||
if value := strings.TrimSpace(settings.TestWeKnoraBaseURL); value != "" {
|
||||
return value
|
||||
}
|
||||
return config.TestWeKnoraBaseURL
|
||||
},
|
||||
config.InternalRoutingKnowledgeBaseID,
|
||||
func(resolveCtx context.Context) (string, error) {
|
||||
internal, _, _, err := actionStore.LoadRoutingKBBindings(resolveCtx)
|
||||
return internal, err
|
||||
LegacyKey: func(env string) (string, error) {
|
||||
path := config.TestWeKnoraAPIKeyFile
|
||||
if env == kbbinding.EnvProduction {
|
||||
path = config.ProductionWeKnoraAPIKeyFile
|
||||
}
|
||||
if strings.TrimSpace(path) == "" {
|
||||
return "", nil
|
||||
}
|
||||
return weknora.ReadAPIKeyFile(path)
|
||||
},
|
||||
func() (string, error) { return weknora.ReadAPIKeyFile(config.TestWeKnoraAPIKeyFile) },
|
||||
)
|
||||
LegacyBinding: func(resolveCtx context.Context, env string) (string, string, error) {
|
||||
if env == kbbinding.EnvProduction {
|
||||
internal, external, _, err := actionStore.LoadProductionKBBindings(resolveCtx)
|
||||
return internal, external, err
|
||||
}
|
||||
internal, external, _, err := actionStore.LoadRoutingKBBindings(resolveCtx)
|
||||
if internal == "" {
|
||||
internal = config.InternalRoutingKnowledgeBaseID
|
||||
}
|
||||
if external == "" {
|
||||
external = config.ExternalRoutingKnowledgeBaseID
|
||||
}
|
||||
return internal, external, err
|
||||
},
|
||||
RoutingDefaults: func() (string, string) {
|
||||
return config.InternalRoutingKnowledgeBaseID, config.ExternalRoutingKnowledgeBaseID
|
||||
},
|
||||
})
|
||||
productionEndpointResolver := func(resolveCtx context.Context) string {
|
||||
return kbBindings.ResolveBaseURL(resolveCtx, kbbinding.EnvProduction)
|
||||
}
|
||||
testEndpointResolver := func(resolveCtx context.Context) string {
|
||||
return kbBindings.ResolveBaseURL(resolveCtx, kbbinding.EnvTest)
|
||||
}
|
||||
// P10 readiness 与执行链看同一目标:当前持久化绑定、当前有效连接(加密存储优先、
|
||||
// 旧部署 file 凭据兜底)。任何一项读取失败都必须显式报错,不能静默退回旧值。
|
||||
readinessResolver := func(resolveCtx context.Context) (readiness.Target, error) {
|
||||
target := readiness.Target{KnowledgeBaseID: config.InternalRoutingKnowledgeBaseID}
|
||||
stored, _, _, err := actionStore.LoadRoutingKBBindings(resolveCtx)
|
||||
if err != nil {
|
||||
return readiness.Target{}, fmt.Errorf("读取当前知识库绑定失败")
|
||||
}
|
||||
if strings.TrimSpace(stored) != "" {
|
||||
target.KnowledgeBaseID = strings.TrimSpace(stored)
|
||||
}
|
||||
connection, err := kbBindings.Resolve(resolveCtx, kbbinding.EnvTest)
|
||||
if err != nil {
|
||||
return readiness.Target{}, fmt.Errorf("读取 WeKnora 有效连接失败:%w", err)
|
||||
}
|
||||
target.BaseURL, target.APIKey = connection.BaseURL, connection.APIKey
|
||||
return target, nil
|
||||
}
|
||||
readinessProber := readiness.Prober{
|
||||
Resolve: readinessResolver,
|
||||
Timeout: config.TestWeKnoraHTTPTimeout,
|
||||
@@ -138,13 +185,10 @@ func run(ctx context.Context, getenv func(string) string) error {
|
||||
return result.Target, result.Err
|
||||
}
|
||||
knowledgeBaseLister := &weKnoraLister{
|
||||
endpoint: func(resolveCtx context.Context) string {
|
||||
if saved := testEndpointResolver(resolveCtx); saved != "" {
|
||||
return saved
|
||||
}
|
||||
return config.TestWeKnoraBaseURL
|
||||
resolve: func(resolveCtx context.Context) (string, string, error) {
|
||||
connection, err := kbBindings.Resolve(resolveCtx, kbbinding.EnvTest)
|
||||
return connection.BaseURL, connection.APIKey, err
|
||||
},
|
||||
readKey: func() (string, error) { return weknora.ReadAPIKeyFile(config.TestWeKnoraAPIKeyFile) },
|
||||
timeout: config.TestWeKnoraHTTPTimeout,
|
||||
allowDockerHTTP: config.TestWeKnoraAllowDockerHTTP,
|
||||
}
|
||||
@@ -160,6 +204,7 @@ func run(ctx context.Context, getenv func(string) string) error {
|
||||
TestAllowDockerHTTP: config.TestWeKnoraAllowDockerHTTP,
|
||||
ProductionAllowDockerHTTP: config.ProductionWeKnoraAllowDockerHTTP,
|
||||
})
|
||||
productionKnowledgeBases := &productionKnowledgeBaseLister{bindings: kbBindings, timeout: 10 * time.Second, allowDockerHTTP: config.ProductionWeKnoraAllowDockerHTTP}
|
||||
// 「版本记录」:只读查询面在 API 侧接线;真正的抓取在 worker 侧(未配置来源即未接线)。
|
||||
versionHistoryStore, versionHistoryRepo := httpapi.VersionHistoryStore(nil), ""
|
||||
if config.VersionHistoryGiteaBaseURL != "" {
|
||||
@@ -227,7 +272,8 @@ func run(ctx context.Context, getenv func(string) string) error {
|
||||
RoutingBindings: postgresstore.NewStore(pool),
|
||||
KnowledgeBases: knowledgeBaseLister,
|
||||
ProductionBindings: postgresstore.NewStore(pool),
|
||||
ProductionKnowledgeBases: serviceTargetVerifier,
|
||||
ProductionKnowledgeBases: productionKnowledgeBases,
|
||||
KBBindings: kbBindings,
|
||||
ProductionWeKnoraBaseURL: config.ProductionWeKnoraBaseURL,
|
||||
ServiceTargetVerifier: serviceTargetVerifier,
|
||||
ProductionReleaseRequestsEnabled: config.ProductionReleaseRequestsEnabled,
|
||||
|
||||
+42
-8
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"knowledge-governance/internal/kbbinding"
|
||||
"knowledge-governance/internal/platform/weknora"
|
||||
"knowledge-governance/internal/readiness"
|
||||
)
|
||||
@@ -51,23 +52,25 @@ func newWeKnoraReadinessResolver(
|
||||
// weKnoraLister 让「系统设置」的知识库下拉与保存校验同样跟随当前端点/凭据,
|
||||
// 而不是复用启动时的客户端(否则改端点后选项仍来自旧实例)。
|
||||
type weKnoraLister struct {
|
||||
endpoint func(context.Context) string
|
||||
readKey func() (string, error)
|
||||
resolve func(context.Context) (baseURL, apiKey string, err error)
|
||||
timeout time.Duration
|
||||
allowDockerHTTP bool
|
||||
}
|
||||
|
||||
func (lister *weKnoraLister) ListKnowledgeBases(ctx context.Context) ([]weknora.KnowledgeBase, error) {
|
||||
baseURL := ""
|
||||
if lister.endpoint != nil {
|
||||
baseURL = strings.TrimSpace(lister.endpoint(ctx))
|
||||
if lister.resolve == nil {
|
||||
return nil, fmt.Errorf("WeKnora 端点未配置")
|
||||
}
|
||||
baseURL, apiKey, err := lister.resolve(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
baseURL = strings.TrimSpace(baseURL)
|
||||
if baseURL == "" {
|
||||
return nil, fmt.Errorf("WeKnora 端点未配置")
|
||||
}
|
||||
apiKey, err := lister.readKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if strings.TrimSpace(apiKey) == "" {
|
||||
return nil, fmt.Errorf("WeKnora API Key 未配置")
|
||||
}
|
||||
timeout := lister.timeout
|
||||
if timeout <= 0 || timeout > 10*time.Second {
|
||||
@@ -79,3 +82,34 @@ func (lister *weKnoraLister) ListKnowledgeBases(ctx context.Context) ([]weknora.
|
||||
}
|
||||
return client.ListKnowledgeBases(ctx)
|
||||
}
|
||||
|
||||
// productionKnowledgeBaseLister 列生产端知识库时使用「生产环境」保存的连接
|
||||
// (加密密钥),而不是另一条文件凭据。显式传入的地址必须与已保存连接一致,
|
||||
// 防止把生产密钥发往另一个地址。
|
||||
type productionKnowledgeBaseLister struct {
|
||||
bindings *kbbinding.Store
|
||||
timeout time.Duration
|
||||
allowDockerHTTP bool
|
||||
}
|
||||
|
||||
func (lister *productionKnowledgeBaseLister) ListProductionKnowledgeBases(ctx context.Context, baseURL string) ([]weknora.KnowledgeBase, error) {
|
||||
if lister.bindings == nil {
|
||||
return nil, fmt.Errorf("生产知识库连接存储未接线")
|
||||
}
|
||||
target, err := lister.bindings.Resolve(ctx, kbbinding.EnvProduction)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if explicit := strings.TrimSpace(baseURL); explicit != "" && explicit != target.BaseURL {
|
||||
return nil, fmt.Errorf("生产地址与已保存的连接不一致:请在生产工作区重新保存连接")
|
||||
}
|
||||
timeout := lister.timeout
|
||||
if timeout <= 0 || timeout > 10*time.Second {
|
||||
timeout = 10 * time.Second
|
||||
}
|
||||
client, err := weknora.NewClient(weknora.ClientConfig{BaseURL: target.BaseURL, APIKey: target.APIKey, Timeout: timeout, AllowDockerHTTP: lister.allowDockerHTTP})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return client.ListKnowledgeBases(ctx)
|
||||
}
|
||||
|
||||
@@ -96,9 +96,8 @@ func TestKnowledgeBaseListerFollowsTheCurrentEndpoint(t *testing.T) {
|
||||
defer second.Close()
|
||||
endpoint := first.URL
|
||||
lister := &weKnoraLister{
|
||||
endpoint: func(context.Context) string { return endpoint },
|
||||
readKey: func() (string, error) { return "key-1", nil },
|
||||
timeout: time.Second,
|
||||
resolve: func(context.Context) (string, string, error) { return endpoint, "key-1", nil },
|
||||
timeout: time.Second,
|
||||
}
|
||||
bases, err := lister.ListKnowledgeBases(context.Background())
|
||||
if err != nil || len(bases) != 1 || bases[0].ID != "kb-a" {
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestWorkerHandlersFollowWorkerRole(t *testing.T) {
|
||||
VersionHistoryGiteaBaseURL: "https://gitea.invalid/Weknora/knowledge-governance",
|
||||
VersionHistoryAllowedOrigins: []string{"https://gitea.invalid"},
|
||||
}
|
||||
handlers, err := workerHandlers(postgresstore.NewStore(nil), release)
|
||||
handlers, err := workerHandlers(postgresstore.NewStore(nil), release, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("release-executor workerHandlers() error = %v", err)
|
||||
}
|
||||
@@ -74,12 +74,12 @@ func TestWorkerHandlersFollowWorkerRole(t *testing.T) {
|
||||
TestWeKnoraEnabled: true,
|
||||
TestWeKnoraAPIKeyFile: "/nonexistent/api-key",
|
||||
}
|
||||
if _, err := workerHandlers(nil, capture); err == nil || !strings.Contains(err.Error(), "test WeKnora API key") {
|
||||
if _, err := workerHandlers(nil, capture, nil); err == nil || !strings.Contains(err.Error(), "test WeKnora API key") {
|
||||
t.Fatalf("capture role must reach the test WeKnora wiring, got %v", err)
|
||||
}
|
||||
capture.TestWeKnoraEnabled = false
|
||||
capture.PPScanEnabled = false
|
||||
handlers, err = workerHandlers(postgresstore.NewStore(nil), capture)
|
||||
handlers, err = workerHandlers(postgresstore.NewStore(nil), capture, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("capture workerHandlers() error = %v", err)
|
||||
}
|
||||
|
||||
+69
-14
@@ -19,6 +19,7 @@ import (
|
||||
"knowledge-governance/internal/appconfig"
|
||||
"knowledge-governance/internal/governance"
|
||||
"knowledge-governance/internal/jobs"
|
||||
"knowledge-governance/internal/kbbinding"
|
||||
"knowledge-governance/internal/libraryagent"
|
||||
"knowledge-governance/internal/libraryhandoff"
|
||||
"knowledge-governance/internal/libraryrelease"
|
||||
@@ -173,6 +174,57 @@ func run(ctx context.Context, getenv func(string) string) error {
|
||||
}
|
||||
store := postgresstore.NewStore(pool).WithLibraryTarget(config.LibraryTargetIdentity()).WithRoutingDefaults(config.InternalRoutingKnowledgeBaseID, config.ExternalRoutingKnowledgeBaseID).
|
||||
WithRestoreDispatchEvidence(config.LibraryTargetJournalRoot)
|
||||
kbBindings := kbbinding.New(pool, kbbinding.Options{
|
||||
MasterKeyFile: config.WeKnoraBindingMasterKeyFile,
|
||||
Timeout: 10 * time.Second,
|
||||
AllowDockerHTTP: map[string]bool{
|
||||
kbbinding.EnvTest: config.TestWeKnoraAllowDockerHTTP,
|
||||
kbbinding.EnvProduction: config.ProductionWeKnoraAllowDockerHTTP,
|
||||
},
|
||||
LegacyBaseURL: func(resolveCtx context.Context, env string) string {
|
||||
settings, err := store.GetActiveUISettings(resolveCtx)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if env == kbbinding.EnvProduction {
|
||||
if value := strings.TrimSpace(settings.ProductionWeKnoraBaseURL); value != "" {
|
||||
return value
|
||||
}
|
||||
return config.ProductionWeKnoraBaseURL
|
||||
}
|
||||
if value := strings.TrimSpace(settings.TestWeKnoraBaseURL); value != "" {
|
||||
return value
|
||||
}
|
||||
return config.TestWeKnoraBaseURL
|
||||
},
|
||||
LegacyKey: func(env string) (string, error) {
|
||||
path := config.TestWeKnoraAPIKeyFile
|
||||
if env == kbbinding.EnvProduction {
|
||||
path = config.ProductionWeKnoraAPIKeyFile
|
||||
}
|
||||
if strings.TrimSpace(path) == "" {
|
||||
return "", nil
|
||||
}
|
||||
return weknora.ReadAPIKeyFile(path)
|
||||
},
|
||||
LegacyBinding: func(resolveCtx context.Context, env string) (string, string, error) {
|
||||
if env == kbbinding.EnvProduction {
|
||||
internal, external, _, err := store.LoadProductionKBBindings(resolveCtx)
|
||||
return internal, external, err
|
||||
}
|
||||
internal, external, _, err := store.LoadRoutingKBBindings(resolveCtx)
|
||||
if internal == "" {
|
||||
internal = config.InternalRoutingKnowledgeBaseID
|
||||
}
|
||||
if external == "" {
|
||||
external = config.ExternalRoutingKnowledgeBaseID
|
||||
}
|
||||
return internal, external, err
|
||||
},
|
||||
RoutingDefaults: func() (string, string) {
|
||||
return config.InternalRoutingKnowledgeBaseID, config.ExternalRoutingKnowledgeBaseID
|
||||
},
|
||||
})
|
||||
log.Printf("library target evidence identity=%s", config.LibraryTargetIdentity())
|
||||
// 启动先接管被中断的写作业(复用已持久化的预备份),再把剩下的孤儿判失败:
|
||||
// 顺序反了会把可接管的作业先标失败,丢掉已完成的备份。
|
||||
@@ -211,7 +263,7 @@ func run(ctx context.Context, getenv func(string) string) error {
|
||||
} else if repaired > 0 {
|
||||
log.Printf("library job reconcile: %d orphan job(s) marked failed", repaired)
|
||||
}
|
||||
handlers, err := workerHandlers(store, config)
|
||||
handlers, err := workerHandlers(store, config, kbBindings)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -324,7 +376,7 @@ func completeLibraryCaptureJob(ctx context.Context, store libraryCapturePersiste
|
||||
return nil
|
||||
}
|
||||
|
||||
func workerHandlers(store *postgresstore.Store, config appconfig.Config) (map[string]jobs.Handler, error) {
|
||||
func workerHandlers(store *postgresstore.Store, config appconfig.Config, kbBindings *kbbinding.Store) (map[string]jobs.Handler, error) {
|
||||
handlers := map[string]jobs.Handler{
|
||||
"demo": func(_ context.Context, job jobs.Job) error {
|
||||
log.Printf("completed demo job id=%s", job.ID)
|
||||
@@ -526,24 +578,27 @@ func workerHandlers(store *postgresstore.Store, config appconfig.Config) (map[st
|
||||
if !config.TestWeKnoraEnabled || !config.LibraryWorkerRole.ExecutesSourceWork() {
|
||||
return handlers, nil
|
||||
}
|
||||
// 启动只验证凭据“存在”(缺失像以前一样拒绝启动);具体值仍由 resolver 每次调用重读。
|
||||
if _, err := weknora.ReadAPIKeyFile(config.TestWeKnoraAPIKeyFile); err != nil {
|
||||
return nil, fmt.Errorf("read test WeKnora API key: %w", err)
|
||||
// 启动只验证“有一条可用凭据”:旧部署是文件,新部署可以是加密存储里的连接。
|
||||
// 两者都没有时不再静默启动,仍像以前一样拒绝;具体值由 resolver 每次重读。
|
||||
storageReady := kbBindings != nil && kbBindings.StorageReady()
|
||||
if _, fileErr := weknora.ReadAPIKeyFile(config.TestWeKnoraAPIKeyFile); fileErr != nil && !storageReady {
|
||||
return nil, fmt.Errorf("read test WeKnora API key: %w", fileErr)
|
||||
}
|
||||
// 与 API 探测共用同一有效目标:网页保存的端点优先、env 只作未配置兜底;
|
||||
// 当前持久化绑定优先、env 兜底;凭据每次调用重读同一 key 文件。
|
||||
// 与 API 探测共用同一有效目标:加密存储里的连接优先、旧部署文件/端点兜底;
|
||||
// 当前持久化绑定优先、env 兜底。
|
||||
remoteResolver := readiness.Resolver{
|
||||
Endpoint: func(resolveCtx context.Context) string {
|
||||
if settings, settingsErr := store.GetActiveUISettings(resolveCtx); settingsErr == nil && strings.TrimSpace(settings.TestWeKnoraBaseURL) != "" {
|
||||
return settings.TestWeKnoraBaseURL
|
||||
}
|
||||
return config.TestWeKnoraBaseURL
|
||||
},
|
||||
LoadBinding: func(resolveCtx context.Context) (string, error) {
|
||||
internal, _, _, bindingErr := store.LoadRoutingKBBindings(resolveCtx)
|
||||
return internal, bindingErr
|
||||
},
|
||||
ReadKey: func() (string, error) { return weknora.ReadAPIKeyFile(config.TestWeKnoraAPIKeyFile) },
|
||||
ResolveConnection: func(resolveCtx context.Context) (string, string, error) {
|
||||
if kbBindings == nil {
|
||||
key, err := weknora.ReadAPIKeyFile(config.TestWeKnoraAPIKeyFile)
|
||||
return config.TestWeKnoraBaseURL, key, err
|
||||
}
|
||||
target, resolveErr := kbBindings.Resolve(resolveCtx, kbbinding.EnvTest)
|
||||
return target.BaseURL, target.APIKey, resolveErr
|
||||
},
|
||||
DefaultKB: config.InternalRoutingKnowledgeBaseID,
|
||||
}
|
||||
client := &weknoraaccess.Client{Resolver: remoteResolver, Timeout: config.TestWeKnoraHTTPTimeout, AllowDockerHTTP: config.TestWeKnoraAllowDockerHTTP}
|
||||
|
||||
@@ -20,7 +20,7 @@ func TestRunRequiresDatabaseURL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWorkerHandlersExcludeReleaseAndTestJobsByDefault(t *testing.T) {
|
||||
handlers, err := workerHandlers(nil, appconfig.Config{})
|
||||
handlers, err := workerHandlers(nil, appconfig.Config{}, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("workerHandlers() error = %v", err)
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func TestWorkerHandlersRegisterPPScanWhenExplicitlyEnabled(t *testing.T) {
|
||||
PPScanLedgerPath: filepath.Join(root, "state.jsonl"),
|
||||
PPScanManifestPath: filepath.Join(root, "manifest.json"),
|
||||
}
|
||||
handlers, err := workerHandlers(postgresstore.NewStore(nil), config)
|
||||
handlers, err := workerHandlers(postgresstore.NewStore(nil), config, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("workerHandlers() error = %v", err)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func TestWorkerHandlersRegisterPPScanWhenExplicitlyEnabled(t *testing.T) {
|
||||
|
||||
func TestWorkerHandlersRequireAPIKeyWhenTestWeKnoraEnabled(t *testing.T) {
|
||||
config := appconfig.Config{TestWeKnoraEnabled: true, TestWeKnoraAPIKeyFile: "/nonexistent/api-key"}
|
||||
_, err := workerHandlers(nil, config)
|
||||
_, err := workerHandlers(nil, config, nil)
|
||||
if err == nil || !strings.Contains(err.Error(), "read test WeKnora API key") {
|
||||
t.Fatalf("workerHandlers() error = %v", err)
|
||||
}
|
||||
@@ -80,7 +80,7 @@ func TestWorkerHandlersRegisterTestJobsForExplicitDockerHTTP(t *testing.T) {
|
||||
TestWeKnoraMaxUploadBytes: 1024,
|
||||
TestAcceptancePolicyVersion: "structural-v1",
|
||||
}
|
||||
handlers, err := workerHandlers(postgresstore.NewStore(nil), config)
|
||||
handlers, err := workerHandlers(postgresstore.NewStore(nil), config, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("workerHandlers() error = %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user