Skip to content

Unit Tests for AuthService #69

@Josue19-08

Description

@Josue19-08

🔖 Title

Unit Tests for AuthService


📄 Description

Write comprehensive unit tests for the AuthService covering nonce generation, signature verification, and JWT token issuance. Mock all external dependencies including Supabase client and Stellar SDK. This issue can be completed independently once issues #49 and #50 are implemented.

Related to: Meta-issue #67


✅ Tasks to complete

  • Test nonce generation produces unique cryptographic nonces
  • Test nonce storage in database with correct TTL
  • Test signature verification with valid Stellar Ed25519 signatures
  • Test signature verification rejects invalid signatures
  • Test JWT access token generation with correct payload and expiry
  • Test JWT refresh token generation and storage
  • Test error handling for expired nonces
  • Test error handling for already-used nonces
  • Mock Supabase client for all database operations
  • Mock Stellar SDK for signature verification
  • Achieve 80%+ coverage for AuthService

📚 Documentation/context for AI

(This link never should removed)
https://github.com/TrustUp-app/TrustUp-API/tree/main/docs

Relevant documentation:

Dependencies:


🗒️ Additional notes

Acceptance Criteria:

  • All test cases pass
  • Code coverage for AuthService is at least 80%
  • All external dependencies are mocked
  • Tests run in isolation without database or network calls
  • Edge cases are covered (null inputs, invalid formats, expired data)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions