Skip to content

Test servers no longer inherit bloks-server's local key - #504

Open
rpavlovs wants to merge 1 commit into
hamedgitty:mainfrom
rpavlovs:qa130-local-key-fixture
Open

rpavlovs wants to merge 1 commit into
hamedgitty:mainfrom
rpavlovs:qa130-local-key-fixture

Conversation

@rpavlovs

Copy link
Copy Markdown
Contributor

When the tests run in a process that bloks-server started, such as an agent's turn, they inherit BLOKS_LOCAL_KEY=1, which bin/bloks-server.mjs sets in its own environment, and the test harness passes it on to the server it starts. That server then treats every request without that start's key as a stranger's. The harness's readiness check carries no key, so unless the test turned pairing on, /api/health answers 403 and the harness gives up after 30 seconds with harness exited null, before the test begins.

The harness already clears the other variables bloks-server sets, such as BLOKS_LOOPBACK_ONLY. This clears BLOKS_LOCAL_KEY the same way. A test that wants the key still passes it in extraEnv, which comes last, as the two key tests in test/local-key.test.ts do.

Checked:

  • CI on this exact commit passed: typecheck, 6,504 tests (6,499 passed, 5 skipped, none failed), build and the stray build output check (run).
  • A new test in test/local-key.test.ts sets BLOKS_LOCAL_KEY=1 in the test process and expects an ordinary server without a key. On main it fails at the harness's 30-second bound; with this change it passes.
  • With BLOKS_LOCAL_KEY=1 inherited, these pass with this change: test/local-key.test.ts (5 tests, including the two that turn the key on and check stranger, owner, stale key and agent credential), test/telegram-full-access.test.ts (11), test/plan-remote.test.ts (3) and test/mcp-apps-remote.test.ts (3). With main's harness and the same inherited value, the two key-less tests in test/local-key.test.ts (the existing one and the new one) and the first telegram-full-access test fail to start.
  • Typecheck passes.

Tests that start a server themselves rather than through the harness are unchanged.

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.

1 participant