From 1f0b30cb6abc373ce9de78a84969d57edd7a97bb Mon Sep 17 00:00:00 2001 From: Alexandrelab-200 Date: Thu, 19 Nov 2026 14:48:46 -0300 Subject: [PATCH] fix(test): assert redaction without pinning the mask marker --- cmd/artex/main_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/artex/main_test.go b/cmd/artex/main_test.go index 0953647..06eb280 100644 --- a/cmd/artex/main_test.go +++ b/cmd/artex/main_test.go @@ -13,10 +13,15 @@ import ( // The startup snapshot is meant to be safe to paste into an issue: no DSN // password may survive redaction. func TestConfigSnapshotRedactsDSNPassword(t *testing.T) { + const raw = "postgres://artex:super-secret@localhost:5432/artex?sslmode=disable" + redacted := config.Redact(raw) + if redacted == raw || !strings.Contains(redacted, "*") { + t.Fatalf("config.Redact did not mask the DSN: %q", redacted) + } s := configSnapshot{ Version: "test", ConfigFileFound: true, - PGDSN: config.Redact("postgres://artex:super-secret@localhost:5432/artex?sslmode=disable"), + PGDSN: redacted, PGDSNSource: "environment variable ARTEX_PG_DSN", TrustedProxies: []string{}, } @@ -28,8 +33,8 @@ func TestConfigSnapshotRedactsDSNPassword(t *testing.T) { if strings.Contains(out, "super-secret") { t.Fatalf("DSN password leaked into snapshot: %s", out) } - if !strings.Contains(out, "****") { - t.Fatalf("redaction marker missing from snapshot: %s", out) + if !strings.Contains(out, redacted) { + t.Fatalf("snapshot does not carry the redacted DSN: %s", out) } }