Skip to content

internal: add tests for LoggableHTTPHeader redaction#7661

Closed
Bojun-Vvibe wants to merge 1 commit intocaddyserver:masterfrom
Bojun-Vvibe:agent/caddyserver_caddy-1776702159
Closed

internal: add tests for LoggableHTTPHeader redaction#7661
Bojun-Vvibe wants to merge 1 commit intocaddyserver:masterfrom
Bojun-Vvibe:agent/caddyserver_caddy-1776702159

Conversation

@Bojun-Vvibe
Copy link
Copy Markdown

Repo: caddyserver/caddy (⭐ 60000)
Type: test
Files changed: 1
Lines: +90/-0

What

Adds unit tests for internal.LoggableHTTPHeader.MarshalLogObject, covering: redaction of sensitive headers (Authorization, Proxy-Authorization, Cookie, Set-Cookie), pass-through of non-sensitive headers, opt-in credential logging via ShouldLogCredentials, case-insensitive header matching, and the nil-header no-op path.

Why

LoggableHTTPHeader guards against credential leakage in logs (see #5669, and the recent header redaction work in #7578), but the package had no tests covering the redaction behavior. Regressions here leak secrets into logs, so the behavior deserves explicit coverage. The internal package had no test file before this change.

Testing

go test ./internal/ passes locally (ok github.com/caddyserver/caddy/v2/internal 0.382s). Tests use zapcore.NewMapObjectEncoder — no new dependencies.

Risk

Low — test-only change in an internal package, no production code modified.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Bojun-Vvibe Bojun-Vvibe closed this by deleting the head repository Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants