test: add unit test suite for KYC, plan query filters, and JWT middlewares - #1021
Open
owohdora-stack wants to merge 2 commits into
Open
Conversation
…wares - Add plan query filter tests (beneficiary, both owner+beneficiary, no filters, cache miss, owner cache hit) - Add KYC API endpoint tests (status, submit, upload, required, requirements) - Add JWT middleware tests (missing/invalid headers, expired/wrong-secret/non-admin tokens, valid admin token)
|
@owohdora-stack Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@owohdora-stack |
Contributor
|
@owohdora-stack |
Author
|
@ONEONUORA @Caneryy Please can any maintainer approve workflow on this pr? |
Contributor
|
@owohdora-stack |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #959
Implements comprehensive request tests in
tests/covering KYC API endpoints, plan query filters, and JWT middlewares. All tests follow existing patterns (lazy DB pool, toweroneshotrequests, no real DB required).Changes
Plan Query Filter Tests (
tests/api_tests.rs)test_get_plans_filter_by_beneficiary_only— GET with?beneficiary=test_get_plans_filter_by_both_owner_and_beneficiary— GET with?owner=&beneficiary=test_get_plans_all_no_filters— GET with no query paramstest_get_plans_owner_filter_caches_on_miss— populated cache returns cached data with correct JSON structureKYC API Endpoint Tests (
tests/kyc_api_tests.rs— new)test_get_kyc_status_requires_wallet_addressGET /api/kyc/statustest_get_kyc_status_with_address_hits_dbGET /api/kyc/statustest_get_kyc_status_is_publicGET /api/kyc/statustest_submit_kyc_rejects_empty_bodyPOST /api/kyc/submittest_submit_kyc_with_valid_body_hits_dbPOST /api/kyc/submittest_upload_kyc_document_returns_okPOST /api/kyc/uploadtest_upload_kyc_document_returns_expected_structurePOST /api/kyc/upload{document_id, url}test_is_kyc_required_returns_trueGET /api/kyc/required{required: true, reason}test_get_kyc_requirements_returns_okGET /api/kyc/requirementstest_get_kyc_requirements_returns_expected_structureGET /api/kyc/requirementstest_kyc_endpoints_do_not_require_authJWT Middleware Tests (
tests/jwt_auth_tests.rs— new)test_jwt_missing_authorization_headerAuthorizationheadertest_jwt_invalid_header_formatAuthorization: NotBearer …test_jwt_empty_bearer_tokenAuthorization: Bearertest_jwt_invalid_token_payloadBearer invalid.jwt.tokentest_jwt_valid_token_with_non_admin_rolerole: "user"test_jwt_valid_admin_token_passes_middlewarerole: "admin"test_jwt_token_signed_with_wrong_secret_rejectedtest_jwt_expired_token_rejectedexpin the pastVerification
All 84 tests pass (34 unit + 20 api + 8 jwt + 11 kyc_api + 6 kyc_webhook + 5 middleware):