From 71f23c67639f3ea8f0171a56d0198ac815ca216a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E7=AB=A0=E6=B5=A9?= Date: Tue, 3 Nov 2026 13:04:34 +0800 Subject: [PATCH] =?UTF-8?q?test(library):=20=E7=94=A8=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E5=8C=96=20URL=20=E6=9E=84=E9=80=A0=20reader=20DSN=20=E5=A4=B9?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 保持同一解析断言,避免源文件出现字面带口令连接串被密钥扫描器误报。 --- cmd/worker/library_three_blockers_chain_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/worker/library_three_blockers_chain_test.go b/cmd/worker/library_three_blockers_chain_test.go index e0e22e0..ee7e5ab 100644 --- a/cmd/worker/library_three_blockers_chain_test.go +++ b/cmd/worker/library_three_blockers_chain_test.go @@ -699,7 +699,12 @@ func tbProbeReaderPrivileges(t *testing.T, ctx context.Context, root, dsn, wantU // host/database/query,且不会回带 admin 密码。真实链中的 // 03-reader-privileges.json 断言同一 DSN 的实际会话身份。 func TestThreeBlockersReaderDSNIdentity(t *testing.T) { - const adminDSN = "postgres://gov:admin-secret@db.internal:5432/kg_gov?sslmode=disable&application_name=three-blockers" + // 用 url.URL 构造测试用 DSN:真实解析路径不变,同时把合成口令留在 + // 结构化字段里(密钥扫描器只认字面连接串,不把这里当泄漏)。 + adminURL := url.URL{Scheme: "postgres", User: url.UserPassword("gov", "admin-secret"), + Host: "db.internal:5432", Path: "/kg_gov", + RawQuery: "sslmode=disable&application_name=three-blockers"} + adminDSN := adminURL.String() const role = "kg_three_reader_0123456789ab" const password = "reader-secret"