Validate tokens and port at startup, test the HTTP server #58

Stängd
öppnade 2026-10-08 21:12:33 +00:00 av supernaut · 0 kommentarer
Ägare

What

loadConfig accepts any token, repeated tokens and a non-numeric port. parseTokens silently skips a pair it cannot parse. createServer has no test.

Why

The shim is a network endpoint and the bearer token is its only gate.

Failing case

RECONCILE_SHIM_TOKENS=a=x starts and accepts Bearer x. forgejo-repo:abc is dropped with no log. A refactor that writes the sentinel before the auth check keeps all 20 tests green.

Fix

Throw on tokens under 32 chars, duplicate tokens, unparseable non-empty pairs and an invalid port. Add src/server.test.ts: 401 writes nothing, 204 writes the file, unwritable path gives 500, GET /healthz gives 200.

Done when

  • Each rejection case has a test
  • Server tests cover 401, 204, 500 and /healthz
  • pnpm test passes
## What `loadConfig` accepts any token, repeated tokens and a non-numeric port. `parseTokens` silently skips a pair it cannot parse. `createServer` has no test. ## Why The shim is a network endpoint and the bearer token is its only gate. ## Failing case `RECONCILE_SHIM_TOKENS=a=x` starts and accepts `Bearer x`. `forgejo-repo:abc` is dropped with no log. A refactor that writes the sentinel before the auth check keeps all 20 tests green. ## Fix Throw on tokens under 32 chars, duplicate tokens, unparseable non-empty pairs and an invalid port. Add `src/server.test.ts`: 401 writes nothing, 204 writes the file, unwritable path gives 500, `GET /healthz` gives 200. ## Done when - [ ] Each rejection case has a test - [ ] Server tests cover 401, 204, 500 and /healthz - [ ] `pnpm test` passes
Logga in för att delta i denna konversation.
Ingen milstolpe
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-reconcile-trigger#58
Ingen beskrivning angiven.