Skip to content

test(web4): fix TestSetTagsDashboardAPI against admin-gated /api/stats - #431

Merged
TeoSlayer merged 2 commits into
mainfrom
hotfix/web4-tags-dashboard-admin-token
Jul 27, 2026
Merged

test(web4): fix TestSetTagsDashboardAPI against admin-gated /api/stats#431
TeoSlayer merged 2 commits into
mainfrom
hotfix/web4-tags-dashboard-admin-token

Conversation

@TeoSlayer

Copy link
Copy Markdown
Collaborator

Problem

TestSetTagsDashboardAPI fails deterministically on main:

zz_tags_test.go:298: decode JSON: invalid character 'a' looking for beginning of value

The security batch moved the rich /api/stats payload behind requireAdminToken in rendezvous. With no token configured the endpoint returns 401 with body admin token not configured — the 'a' in the decode error.

tests/zz_dashboard_test.go was updated for this (it passes ?admin_token=), but tests/zz_tags_test.go was missed.

Why PR CI didn't catch it

requireRealNetwork(t) skips only when GITHUB_ACTIONS == "true" && PILOT_REAL_NETWORK != "1". So the test is skipped on GitHub-hosted runners but runs — and fails — locally and on the self-hosted nightly runner (PILOT_REAL_NETWORK=1). Left as-is, tonight's nightly goes red.

Fix

Configure an admin token on the test registry and pass it on the /api/stats request, matching the existing pattern in zz_dashboard_test.go. Also assert 200 so a future auth regression fails with a clear status mismatch rather than a JSON decode error.

Test-only change — no product code touched.

Verification

  • go test -count=1 -run TestSetTags ./tests/ — all 12 pass
  • go test -count=1 ./... — full suite green (exit 0)

Follow-up (not in this PR)

TestSetTagsDashboardNoHostname and TestSetTagsDashboardNoIPLeak hit the same gated endpoint but still pass vacuously — they assert the response body does not contain a hostname/IP, which is trivially true of a 401 body. They are asserting nothing right now and should get the same treatment.

🤖 Generated with Claude Code

claude added 2 commits July 27, 2026 15:31
…/api/stats

The security batch moved the rich /api/stats payload behind
requireAdminToken in rendezvous. zz_dashboard_test.go was updated for
this (it passes ?admin_token=), but zz_tags_test.go was not, so
TestSetTagsDashboardAPI now receives a 401 with the body
"admin token not configured" and fails deterministically with
`decode JSON: invalid character 'a' looking for beginning of value`.

Configure an admin token on the test registry and pass it on the
/api/stats request, matching the existing pattern in zz_dashboard_test.go.
Also assert the 200 so a future auth regression fails with a clear
status mismatch instead of a JSON decode error.

Test-only change; no product code touched.

Note: this did not show up in PR CI because requireRealNetwork skips the
test on GitHub-hosted runners. It fails locally and on the self-hosted
nightly runner (PILOT_REAL_NETWORK=1).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ed endpoint

TestSetTagsDashboardNoHostname and TestSetTagsDashboardNoIPLeak assert
that the response body does NOT contain a hostname, 127.0.0.1, real_addr
or public_key. Since /api/stats moved behind requireAdminToken these
tests receive a 401 body, which trivially satisfies every assertion —
they pass while checking nothing.

Point them at /api/public-stats, the curated anonymous payload that is
actually the surface this privacy property is about, and assert 200 plus
a non-empty body so they cannot silently go vacuous again.

Test-only change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@TeoSlayer
TeoSlayer merged commit 250275c into main Jul 27, 2026
13 checks passed
@TeoSlayer
TeoSlayer deleted the hotfix/web4-tags-dashboard-admin-token branch July 27, 2026 12:59
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