test: cover the captcha and sign-up gates #276
Inga granskare
Etiketter
Inga etiketter
area/backups
area/ci
area/control-panel
area/identity
area/infra
area/observability
area/payments
area/security
area/storage
area/web
blocked
needs-info
needs-triage
ready-for-implementation
type
bug
type
chore
type
docs
type
epic
type
feature
type
task
wontfix
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Inget förfallodatum satt.
Beroenden
Inga beroenden satta
Referens
bitborg/bitborg-web!276
Läser in…
Hänvisa till i nytt ärende
Ingen beskrivning angiven.
Ta bort grenen "test/255-signup-gate"
Borttagning av en gren är permanent. Även om den borttagna grenen kan fortsätta existera en kort tid innan den faktiskt tas bort, kan det INTE ångras i de flesta fall. Vill du fortsätta?
What
Tests for the captcha and sign-up gates: 95 new tests in four files. No version bump.
src/lib/captcha.test.ts:CAP_SECRETunset in production fails closed for create, redeem and validate; outside production it bypasses as documented. Tokens are single-use; never-issued, malformed, wrong-secret and expired tokens are rejected; double redeem returnsalready_redeemed.src/lib/signup-access.test.ts:signupsOpen()andtrialOpen()env handling, read at call time.src/test/captcha-routes.test.ts: challenge and redeem routes for success, sign-ups closed (404), rate limit (429, nothing minted), library throw (500), library refusal (403), and 9 malformed bodies (400, library never called).src/test/signup.test.ts: kill switch, rate limit, captcha missing/invalid/valid (checked after cheap input checks so a bad form does not spend the token), terms, email, username, country eligibility, trial flag, DB health check before provisioning, and every status mapping.One production change:
/api/captcha/redeemvalidates its body with a zod schema that mirrors the library'sValidateChallengeBody(token,solutions, optionalinstr*), and returns 400invalid_bodyotherwise.Findings
No gate fails open. There are no allowlist or invite gates in the code. The country gate is unreachable through the real route today (
requiresCountryis false for every account type); its branches are tested with a mock.Verification
487 tests pass across 33 files. Lint,
astro check, build and e2e pass.Closes #255