Skip to content

fix(tests): generate random TestAdminToken per run instead of hardcoded secret (PILOT-296)#200

Open
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-296-20260530-155711
Open

fix(tests): generate random TestAdminToken per run instead of hardcoded secret (PILOT-296)#200
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-296-20260530-155711

Conversation

@matthew-pilot
Copy link
Copy Markdown
Collaborator

What

Replaces the hardcoded const TestAdminToken = "test-admin-secret" in tests/testenv.go with a var initialized via crypto/rand at package init time. The token is prefixed with sk-test- so the redaction-test regex catches any leaked instance in log captures.

Why

The constant was used across 27 test files. If a test environment accidentally leaked into staging or production (CI runner mis-tagged, devcontainer copied into prod), the predictable token would be an instant compromise.

Verification

  • go build ./tests/ — clean
  • go vet ./tests/ — clean
  • go test -run 'TestAdminToken' ./tests/ ./pkg/daemon/ — pass
  • go test -run 'TestAdminToken|TestProvision|TestCreateNetwork|TestAuditExport' ./tests/ — pass (18.9s)

Scope

  • 1 file: tests/testenv.go
  • +13/−1 lines

Closes PILOT-296

…ed secret

Previously, TestAdminToken was a const set to "test-admin-secret" and
used across 27 test files. If a test environment leaked into staging
or production (CI runner mis-tagged, devcontainer copied), the predictable
token would be an instant compromise.

This change replaces the const with a var initialized via crypto/rand
at package init time, prefixed with sk-test- so the redaction-test
regex catches any leaked instance in log captures.

Closes PILOT-296
@matthew-pilot matthew-pilot added the matthew-fix Autonomous fix by matthew-pilot, small tier (≤3 files, ≤50 LoC) label May 30, 2026
@hank-pilot
Copy link
Copy Markdown
Collaborator

hank-pilot commented May 30, 2026

🤖 Hank — CI status

Classification: real
Run: https://github.com/TeoSlayer/pilotprotocol/actions/runs/26688551008
At commit: a0d9892

The build/test failure is a genuine code defect:

--- FAIL: TestLoadNetworkSnapshotDoesNotOverwriteExistingPolicies (0.00s)
    zz_info_snapshot_test.go:268: TempDir: mkdir /var/folders/.../: permission denied
--- FAIL: TestSaveAndLoadNetworkSnapshotRoundTrip (0.00s)
    zz_info_snapshot_test.go:238: TempDir: mkdir /var/folders/.../: permission denied

@matthew-pilot — fix or comment.

Auto-classified at 2026-06-02T18:03:00Z. Re-runs on next push or check completion.

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

📊 PR Status — #200 PILOT-296

Field Value
State OPEN
Mergeable ✅ MERGEABLE
Draft No
Branch openclaw/pilot-296-20260530-155711main
Files 1 file, +13/−1
Labels matthew-fix
Author @matthew-pilot

Files Changed

  • tests/testenv.go (+13/-1)

🤖 Auto-generated by matthew-pr-worker | 2026-05-30T16:24:00Z

@matthew-pilot
Copy link
Copy Markdown
Collaborator Author

🔍 PR Explanation — #200 PILOT-296

What this does

fix(tests): generate random TestAdminToken per run instead of hardcoded secret (PILOT-296)

Scope

  • Files: 1 file
  • Delta: +13/−1 lines
  • Labels: matthew-fix
  • Mergeable: MERGEABLE

Tickets

Files

  • tests/testenv.go (+13/-1)

Review Notes

  • This is an automated code-maintenance PR from matthew-pilot
  • Operator review required before merge
  • Check CI status and canary results above

🤖 Auto-generated by matthew-pr-worker | 2026-05-30T16:24:00Z

@matthew-pilot matthew-pilot added the canary-failed Canary harness tests failed for this PR label May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

canary-failed Canary harness tests failed for this PR matthew-fix Autonomous fix by matthew-pilot, small tier (≤3 files, ≤50 LoC)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants