From 1c83bb825a845c7d820194d5bfbee692864cf465 Mon Sep 17 00:00:00 2001 From: haruka <1628615876@qq.com> Date: Thu, 5 Nov 2026 03:45:27 -0500 Subject: [PATCH] test(repository): assert the auth projection carries require_privacy_set OpenAI scheduling now reads the privacy gate from the auth snapshot; cover the GetByKeyForAuth projection so a dropped column fails here instead of admitting accounts without privacy set. Co-Authored-By: Claude Opus 5.5 --- .../api_key_repo_profit_projection_integration_test.go | 3 +++ backend/internal/repository/fixtures_integration_test.go | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/internal/repository/api_key_repo_profit_projection_integration_test.go b/backend/internal/repository/api_key_repo_profit_projection_integration_test.go index 283b103d9b..ff2e398412 100644 --- a/backend/internal/repository/api_key_repo_profit_projection_integration_test.go +++ b/backend/internal/repository/api_key_repo_profit_projection_integration_test.go @@ -28,6 +28,7 @@ func TestGetByKeyForAuthCarriesProfitControlProjection(t *testing.T) { ProfitControlEnabled: true, ProfitMinMargin: 0.2, ProfitSafetyBuffer: 0.05, + RequirePrivacySet: true, }) user := mustCreateUser(t, integrationEntClient, &service.User{ Email: fmt.Sprintf("profit-proj-%d@example.com", suffix), Concurrency: 5, @@ -57,4 +58,6 @@ func TestGetByKeyForAuthCarriesProfitControlProjection(t *testing.T) { require.True(t, got.Group.ProfitControlEnabled, "profit_control_enabled 必须进入认证投影(投影漏列会让门静默失效)") require.InDelta(t, 0.2, got.Group.ProfitMinMargin, 1e-9) require.InDelta(t, 0.05, got.Group.ProfitSafetyBuffer, 1e-9) + // OpenAI 选号从认证分组读取隐私门,漏列会放行未设置隐私的账号。 + require.True(t, got.Group.RequirePrivacySet, "require_privacy_set 必须进入认证投影") } diff --git a/backend/internal/repository/fixtures_integration_test.go b/backend/internal/repository/fixtures_integration_test.go index 98e0085e2f..50e398b3ea 100644 --- a/backend/internal/repository/fixtures_integration_test.go +++ b/backend/internal/repository/fixtures_integration_test.go @@ -96,7 +96,8 @@ func mustCreateGroup(t *testing.T, client *dbent.Client, g *service.Group) *serv SetCodexModelsManifestConfig(g.CodexModelsManifestConfig). SetProfitControlEnabled(g.ProfitControlEnabled). SetProfitMinMargin(g.ProfitMinMargin). - SetProfitSafetyBuffer(g.ProfitSafetyBuffer) + SetProfitSafetyBuffer(g.ProfitSafetyBuffer). + SetRequirePrivacySet(g.RequirePrivacySet) if g.Description != "" { create.SetDescription(g.Description) }