What
Add inline unit tests for trapfalld/src/server.rs (1045 LOC) and related handler files that currently have zero inline tests.
Why
BMAD COO finding: TrapFall has 231 tests total, but they're concentrated in trapfall-db (81) and integration-level tests/ directories. The HTTP handler layer — server.rs (1045 LOC), alert.rs (266 LOC), auth.rs (312 LOC), config.rs (281 LOC) — has zero inline #[test] functions.
This means handler-level edge cases (malformed requests, auth edge cases, rate limiting behavior) are only caught by E2E tests, which are slower and less precise.
Changes
- server.rs: Unit tests for:
- Request routing (each endpoint returns correct status for valid/invalid input)
- Error response shapes
- Authentication middleware (valid token, expired token, missing token, malformed token)
- Rate limiting behavior
- alert.rs: Unit tests for:
- Rule matching logic (condition evaluation)
- Cooldown tracking
- Webhook dispatch (mock HTTP)
- auth.rs: Unit tests for:
- JWT generation and validation
- Argon2 password hashing/verification
- DSN validation against registered projects
- config.rs: Unit tests for:
- Default values
- Environment variable parsing
- Invalid config handling
Testing
This IS the testing task. Success = cargo test --workspace count increases by 30-50 tests, with handler-level coverage significantly improved.
What
Add inline unit tests for
trapfalld/src/server.rs(1045 LOC) and related handler files that currently have zero inline tests.Why
BMAD COO finding: TrapFall has 231 tests total, but they're concentrated in
trapfall-db(81) and integration-leveltests/directories. The HTTP handler layer —server.rs(1045 LOC),alert.rs(266 LOC),auth.rs(312 LOC),config.rs(281 LOC) — has zero inline#[test]functions.This means handler-level edge cases (malformed requests, auth edge cases, rate limiting behavior) are only caught by E2E tests, which are slower and less precise.
Changes
Testing
This IS the testing task. Success =
cargo test --workspacecount increases by 30-50 tests, with handler-level coverage significantly improved.