internal/middleware: CORS, logging, and the metrics auth gate are untested #79
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Verified against
mainat61f42e6.internal/middlewarehas two tests, both on security headers:TestSecurityHeadersandTestSecurityHeaders_PreservesExistingHeaders.Untested:
MetricsAuth(middleware.go:135-144) — the basic-auth gate on/metrics. This is an access control check with no test. Metrics can leak upstream hostnames, traffic volumes, and cache behavior; if this gate regresses, nothing catches it.CORS(middleware.go:114) — currently hardcoded to[]string{"*"}. Becomes configurable via theaccess_control_allow_originwork; that change should land on top of a test that pins current behavior first.Logging(middleware.go:82-109) — including that it does not log secrets. Worth an explicit assertion that the signing key never appears in a log line, given it can arrive as a form value onPOST /.Metrics(middleware.go:124-132).Definition of done
MetricsAuthtests: no credentials returns 401 with aWWW-Authenticatechallenge; wrong credentials returns 401; correct credentials passes through. Also assert the comparison is constant-time if it is not already (and make it so if not — a timing-attackable metrics password is a small but free win).*behavior, written so they extend naturally when the config key lands.POST /body containing the signing key does not put that value into the log output.make checkgreen.