test(backend): add route-level integration tests for admin indexer endpoints (#847) - #1174
Open
jotel-dev wants to merge 4 commits into
Open
test(backend): add route-level integration tests for admin indexer endpoints (#847)#1174jotel-dev wants to merge 4 commits into
jotel-dev wants to merge 4 commits into
Conversation
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.
Description
Adds comprehensive route-level integration tests for the administrative indexer endpoints:
GET /v1/admin/indexer/status,POST /v1/admin/indexer/reset, andPOST /v1/admin/indexer/replay.Previously, these operational endpoints lacked route-level test coverage in
tests/integration/admin-metrics.test.ts. This left therequireAdminauthentication middleware, query/body parameter validation logic, status code outputs (200,202,400,401,403,500), and downstream service function invocations unverified.Type of Change
Related Issues
Closes #847
Changes Made
requireAdminmiddleware implementation instead of stubbing auth to a no-op handler.signJwt) and environment key setup (process.env.ADMIN_PUBLIC_KEY) to ensure end-to-end routing validation.GET /v1/admin/indexer/status:401 Unauthorizedwhen no token is present and403 Forbiddenfor non-admin tokens.200 OKand returned payload matchinggetIndexerStatus()for valid admin requests.500 Internal Server Errorhandling whengetIndexerStatus()throws.POST /v1/admin/indexer/reset:401 Unauthorizedand403 Forbiddenauth enforcement.400 Bad Requestwith error message"ledger must be a non-negative integer"for missing body, negative integers (-1), floating-point values (12.34), or non-numeric strings ("not-a-number"), ensuringresetIndexeris not called.200 OKresponse{ ok: true, lastLedger: expected }and verifiesresetIndexeris called with parsed integer values (500,0,'123').500 Internal Server Errorhandling whenresetIndexerthrows.POST /v1/admin/indexer/replay:401 Unauthorizedand403 Forbiddenauth enforcement.400 Bad Requestwith error message"from_ledger must be a non-negative integer"for missingfrom_ledgerquery parameter, negative values (-1,-50), floating-point numbers (3.14), or non-numeric strings ("invalid"), ensuringreplayFromLedgeris not called.202 Acceptedresponse{ ok: true, replayingFrom: expected }and verifiesreplayFromLedgeris called with parsed integer values (200,0).500 Internal Server Errorhandling whenreplayFromLedgerthrows.Testing
Test Coverage
Test Steps
closes #847