📌 Description
internal/didit/client.go wraps the Didit KYC API (CreateSession POSTs to /v2/session/, GetSessionDecision GETs /v2/session/{id}/decision/, both with x-api-key auth and a 30s timeout) but has no test file. KYC drives the kyc.go handler and gates user verification.
💡 Why it matters: Verification status decisions depend on correctly parsing Didit responses; untested parsing risks misclassifying users' KYC state.
🧩 Requirements and context
- Use
httptest.Server to assert the x-api-key header, method, path, and workflow_id payload.
- Cover a successful session creation and decision retrieval with realistic JSON.
- Cover Didit error bodies and non-2xx responses, asserting the captured raw body for debugging.
- Verify the 30s client timeout via a slow server and context deadline.
- No real Didit network access.
Non-functional requirements
- Must be secure, tested, and documented.
- Should be efficient and easy to review.
🛠️ Suggested execution
1. Fork the repo and create a branch
git checkout -b test/didit-client
2. Implement changes
- Write/modify the relevant source: refactor
NewClient to accept a base URL for tests if needed
- Write comprehensive tests:
internal/didit/client_test.go
- Add documentation: GoDoc on response parsing
- Include GoDoc comments on the status mapping
- Validate security assumptions: API key must not be logged
3. Test and commit
go test ./internal/didit/...
- Cover edge cases: error body, timeout, malformed JSON
- Include test output and security notes in the PR description.
Example commit message
test(didit): cover KYC session creation and decision parsing
✅ Acceptance criteria
🔒 Security notes
Confirms the x-api-key is sent but never logged; ensures error bodies captured for debugging do not leak into client responses.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
internal/didit/client.gowraps the Didit KYC API (CreateSessionPOSTs to/v2/session/,GetSessionDecisionGETs/v2/session/{id}/decision/, both withx-api-keyauth and a 30s timeout) but has no test file. KYC drives thekyc.gohandler and gates user verification.🧩 Requirements and context
httptest.Serverto assert thex-api-keyheader, method, path, and workflow_id payload.Non-functional requirements
🛠️ Suggested execution
1. Fork the repo and create a branch
2. Implement changes
NewClientto accept a base URL for tests if neededinternal/didit/client_test.go3. Test and commit
go test ./internal/didit/...Example commit message
✅ Acceptance criteria
🔒 Security notes
Confirms the
x-api-keyis sent but never logged; ensures error bodies captured for debugging do not leak into client responses.📋 Guidelines