Skip to content

test(service): dfx_kyc_service core methods (+10 tests)#343

Merged
TaprootFreak merged 1 commit into
developfrom
test/kyc-service-core
May 15, 2026
Merged

test(service): dfx_kyc_service core methods (+10 tests)#343
TaprootFreak merged 1 commit into
developfrom
test/kyc-service-core

Conversation

@TaprootFreak
Copy link
Copy Markdown
Contributor

Summary

Stage 20 of the coverage push. Covers four core methods of the previously-deferred `dfx_kyc_service`.

Method Cases
`getUser` 3
`updateUser` 3
`request2FaCode` 2
`verify2FaCode` 2

What each method's tests pin

  • getUser: GET `/v2/user` with Bearer JWT + parses `UserDto`; 201 also accepted (in addition to 200); throws `ApiException` on a non-2xx non-401 (the 401-refresh-and-retry path is large enough to deserve its own test, deferred).
  • updateUser: PUT `/v2/user` with the JSON body; 201 accepted; `ApiException` on non-2xx.
  • request2FaCode: POST `/v2/kyc/2fa?level=Strict` with `x-kyc-code` header set from `getUser().kyc.hash` (pins the kyc-hash propagation); `ApiException` on non-2xx.
  • verify2FaCode: POST `/v2/kyc/2fa/verify` with `{ token: code }` body and the same `x-kyc-code` header; `ApiException` on non-2xx.

Conflict avoidance

PR #332 (bitbox sign + KYC routing) touches `lib/screens/kyc/cubits/kyc/kyc_cubit.dart` and `real_unit_registration_service.dart` — NOT this service. `dfx_kyc_service.dart` itself is unchanged on that branch, so this PR is conflict-free.

Notes

  • Tests use a tiny `_StubWallet` so `DFXAuthService.wallet` resolves without plumbing a real `SoftwareWallet` through.
  • The wire format for `kyc.level` is the numeric value (e.g. `20` → `KycLevel.level20`), pinned in the test fixture so a future enum / DTO refactor surfaces immediately.

Excluded (deferred)

  • `getUser`'s 401 → `refreshAuthToken` → retry path needs a stateful MockClient + the auth-service signing flow; deserves its own focused test.
  • `continueKyc`, `startStep`, `setData`, `getFinancialData`, `setFinancialData` — more elaborate bodies + headers; will follow up if/when needed.

Test plan

  • `flutter analyze` clean
  • `flutter test` — 10 / 10 passing locally
  • CI green

Stage 20 of the coverage push. Covers four core methods of the
previously-deferred dfx_kyc_service. Safe from PR #332 conflicts —
that PR touches lib/screens/kyc/cubits/kyc/kyc_cubit.dart and
real_unit_registration_service.dart, NOT this service.

- getUser (3): GET /v2/user with Bearer JWT + parses UserDto; 201
  also accepted; ApiException on non-2xx non-401
- updateUser (3): PUT /v2/user with the JSON body; 201 accepted;
  ApiException on non-2xx
- request2FaCode (2): POST /v2/kyc/2fa?level=Strict with the
  x-kyc-code header set from getUser().kyc.hash; ApiException on
  non-2xx
- verify2FaCode (2): POST /v2/kyc/2fa/verify with {token: code} and
  the x-kyc-code header; ApiException on non-2xx

Excluded (deferred): continueKyc, startStep, setData, getFinancialData,
setFinancialData (more involved bodies; will land separately if
needed).
TaprootFreak added a commit that referenced this pull request May 15, 2026
## Summary
Stage 21 of the coverage push. Closes the \`dfx_kyc_service\` surface
added in #343.

| Method | Cases |
| --- | --- |
| \`continueKyc\` | 2 |
| \`startStep\` | 2 |
| \`setData\` | 2 |
| \`getFinancialData\` | 3 |
| \`setFinancialData\` | 2 |

## What each method pins
- **continueKyc:** PUT \`/v2/kyc\` with the \`x-kyc-code\` header from
\`getUser().kyc.hash\`; parses \`KycSessionDto\`; \`ApiException\` on
non-2xx.
- **startStep:** GET \`/v2/kyc/<stepName.value>\` (the path encodes the
step enum's wire string); parses \`KycSessionDto\`; \`ApiException\` on
non-2xx.
- **setData:** PUTs the caller-provided session URL (NOT the host) with
the JSON body + \`x-kyc-code\` header; \`ApiException\` on non-2xx.
- **getFinancialData:** GET \`<url>?lang=<lang.code>\`; defaults the
language to \`Language.de\` (\`'de'\`); \`x-kyc-code\` header;
\`ApiException\` on non-2xx.
- **setFinancialData:** PUTs \`{ "responses": [...] }\` to the
caller-provided URL with \`x-kyc-code\` header; serialises each
\`KycFinancialResponse\` to \`{ key, value }\`; \`ApiException\` on
non-2xx.

## Conflict avoidance
Same as #343 — \`dfx_kyc_service.dart\` is NOT in PR #332's diff. The
service surface is stable on that branch.

## Test plan
- [x] \`flutter analyze\` clean
- [x] \`flutter test\` — 11 / 11 passing locally
- [ ] CI green
@TaprootFreak TaprootFreak marked this pull request as ready for review May 15, 2026 12:00
@TaprootFreak TaprootFreak merged commit 27979cd into develop May 15, 2026
1 check passed
@TaprootFreak TaprootFreak deleted the test/kyc-service-core branch May 15, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant