Test the /metrics basic auth and metrics recording through the router (needs approval to change an existing test) #180

Open
opened 2026-10-04 11:58:53 +02:00 by clawbot · 0 comments
Collaborator

Split from #79 by the review of #178 (#178 (comment)).

No test checks that the router (SetupRoutes in internal/server/routes.go) puts the basic auth in front of /metrics, or that it installs the metrics middleware when a metrics username is set. #178 tests both pieces on their own, so either could drop out of the router unnoticed.

Only one test in internal/server can set up /metrics, because the metrics middleware registers with the process-wide Prometheus registry, and that test is the existing TestMaintenanceModeKeepsOtherRoutes (internal/server/maintenance_internal_test.go). CLAUDE.md needs your approval to change an existing test.

Question: may that test be extended (or its /metrics part moved into a new test) to also check that /metrics answers 401 with a WWW-Authenticate challenge without credentials and with a wrong password, and that /metrics reports a request the router served?

  • Yes (recommended): a small tests-only change; the /metrics gate is then covered where it matters.
  • No: this stays untested until #85 changes how metrics are set up.

Model: opus-5-5

Split from https://git.eeqj.de/sneak/pixa/issues/79 by the review of https://git.eeqj.de/sneak/pixa/pulls/178 (https://git.eeqj.de/sneak/pixa/pulls/178#issuecomment-122519). No test checks that the router (`SetupRoutes` in `internal/server/routes.go`) puts the basic auth in front of `/metrics`, or that it installs the metrics middleware when a metrics username is set. https://git.eeqj.de/sneak/pixa/pulls/178 tests both pieces on their own, so either could drop out of the router unnoticed. Only one test in `internal/server` can set up `/metrics`, because the metrics middleware registers with the process-wide Prometheus registry, and that test is the existing `TestMaintenanceModeKeepsOtherRoutes` (`internal/server/maintenance_internal_test.go`). `CLAUDE.md` needs your approval to change an existing test. Question: may that test be extended (or its `/metrics` part moved into a new test) to also check that `/metrics` answers 401 with a `WWW-Authenticate` challenge without credentials and with a wrong password, and that `/metrics` reports a request the router served? - Yes (recommended): a small tests-only change; the `/metrics` gate is then covered where it matters. - No: this stays untested until https://git.eeqj.de/sneak/pixa/issues/85 changes how metrics are set up. Model: opus-5-5
sneak was assigned by clawbot 2026-10-04 11:58:53 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/pixa#180