Commit Graph

3 Commits

Author SHA1 Message Date
Riley Zhang
ceaf7f9fb5 test: add unit tests for handler and store packages
- Added TestSearchRequests for store package (0% → 100% coverage)
- Added TestOpenInMemory for store package Open function
- Added TestNewSQLiteRepoNilDB for error handling
- Added TestV1ReplayRequest for handler package (0% → 100% coverage)
- Added TestPrettyJSON and TestFormatTime for inspect helpers
- Added TestJoinPath for path joining utility
- Added TestHandleMockReturnsErrorOnInvalidJSON
- Added TestInspectReturnsHTMLErrorOnRepoFailure
- Added TestCaptureMissingEndpointID, TestV1CaptureRequestMissingEndpoint, TestV1ListRequestsMissingEndpoint

Coverage improvements:
- Handler: 77.1% → 82.2%
- Store: 61.1% → 82.2%

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-24 05:07:50 +02:00
SoftwareEngineer
4256d34c27 feat: add one-click replay for captured requests
- Add POST /e/{endpoint}/requests/{id}/replay endpoint
- Replay re-sends captured method, path, headers, query, body to target URL
- Response includes target status code, headers, body (truncated 64KB)
- SSRF guard: denies replay to private/loopback by default
- Opt-in env var HATCH_ALLOW_PRIVATE_REPLAY=true for local dev
- Server-rendered inspect page at GET /e/{endpoint} with replay button UI
- SSE live stream for new requests (EventSource)
- Mock configuration at PUT /e/{endpoint}/mock
- Store: GetRequest, GetMock, SetMock methods added
- Chi router migration from stdlib ServeMux
- 26 passing tests including replay unit tests and E2E capture-to-replay

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-22 16:58:42 +02:00
CTO
90c3f6285d feat: mock endpoint — configure response per endpoint
- Add mock_status, mock_headers, mock_body columns to endpoints schema
- Add MockConfig struct and UpsertMock to Repository interface
- Implement UpsertMock in sqliteRepo (INSERT ON CONFLICT UPDATE)
- Update GetEndpoint to return mock configuration when present
- Add PUT /e/{endpoint_id}/mock handler with JSON body {status, headers, body}
- Add catch-all /{endpoint_id} handler returning mock or default 200
- Header sanitization: only allow Content-Type, Cache-Control, X-*
- Wire handler into cmd/hatch main with SQLite store
- Fix Dockerfile: COPY go.sum for reproducible builds
- Tests: store mock CRUD, handler mock config + header sanitization

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-22 14:32:53 +02:00