Skip to content

feat: Implement and test POST /api/kyc/submit endpoint - #170

Merged
ONEONUORA merged 2 commits into
Fracverse:masterfrom
Olowodarey:kyctest
Feb 24, 2026
Merged

feat: Implement and test POST /api/kyc/submit endpoint#170
ONEONUORA merged 2 commits into
Fracverse:masterfrom
Olowodarey:kyctest

Conversation

@Olowodarey

Copy link
Copy Markdown
Contributor

This PR implements the user-facing KYC submission endpoint (POST /api/kyc/submit) and introduces a comprehensive integration test suite covering:

  • Authentication enforcement
  • Idempotent behavior
  • Response shape validation

While the route handler and KycService::submit_kyc method were already scaffolded, they lacked test coverage. This PR closes that gap and ensures the endpoint is production-ready and verifiable.


What Was Done

1️⃣ Endpoint Verification

Confirmed that:

  • POST /api/kyc/submit is correctly wired in app.rs
  • The handler uses the AuthenticatedUser extractor
  • The request is delegated to KycService::submit_kyc
  • The service performs an upsert on the kyc_status table:
INSERT ... ON CONFLICT DO UPDATE
  • The record is inserted (or updated) with:

    status = 'pending'
    

This guarantees idempotent behavior for repeated submissions.


2️⃣ Integration Test Suite

Added 5 integration tests in:

tests/kyc_submit_tests.rs

Key characteristics:

  • Uses the real Axum router via create_app
  • No mocked HTTP handlers
  • Tests exercise the full request → handler → service → database flow

Test Coverage Includes

  • ✅ Rejects unauthenticated requests
  • ✅ Accepts authenticated requests
  • ✅ Inserts a new kyc_status row with pending status
  • ✅ Ensures idempotency (repeat submissions do not create duplicates)
  • ✅ Validates response structure and status codes

Technical Notes

  • Router created via create_app
  • Uses AuthenticatedUser extractor for auth enforcement
  • Ensures database upsert logic behaves as intended
  • Improves overall API reliability and confidence before frontend integration

Checklist

  • Endpoint wiring verified
  • Integration tests added
  • Authentication behavior validated
  • Idempotency confirmed
  • Response shape validated
  • All tests passing locally

closes #126

@ONEONUORA ONEONUORA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice implementation @Olowodarey

@ONEONUORA
ONEONUORA merged commit bd6c07b into Fracverse:master Feb 24, 2026
2 checks passed
@Olowodarey
Olowodarey deleted the kyctest branch March 24, 2026 04:55
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.

[Backend] User View Own KYC (Missing Endpoint)

2 participants