Skip to content

Add tests for payouts route filter, sort, and pagination allowlists #352

@thlpkee20-wq

Description

@thlpkee20-wq

Description

src/routes/payouts.ts enforces allowlists for status, sortBy, sortOrder, and a MAX_LIMIT of 100, but these guards need tests proving invalid values are rejected with 400 and that pagination cannot be abused for large result sets. Expand src/routes/payouts.test.ts to cover the validation surface.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • Relevant code: src/routes/payouts.ts, src/routes/payouts.test.ts
  • Out-of-allowlist sortBy must never reach a SQL query (injection prevention)

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/payouts-filter-pagination
  • Implement changes
    • Add tests for invalid status, sortBy, sortOrder returning 400
    • Assert limit above MAX_LIMIT is clamped or rejected
    • Assert default limit of 20 applied when omitted
  • Validate security and correctness assumptions

Test and commit

  • Run tests
    • npm test
  • Cover edge cases
    • limit=0, negative offset, sortBy=created_at;DROP, non-numeric limit
  • Include test output and notes

Example commit message

test: cover payouts filter and pagination guards

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions