Skip to content

test : add unit tests for crypto.ts utility functions #483

@tmdeveloper007

Description

@tmdeveloper007

Summary of What Needs to be Done: The repository has zero test files for core utility functions. The crypto.ts file contains encryptToken and decryptToken functions with complex logic that lacks test coverage. Adding unit tests will ensure the encryption/decryption works correctly and prevent regressions.

Changes that Need to be Made:

  • Create new file: src/lib/crypto.test.ts
  • Add tests for encryptToken:
    • Should encrypt and decrypt a token successfully
    • Should return different ciphertext for same input (due to random IV)
  • Add tests for decryptToken:
    • Should throw on invalid hex input (odd length)
    • Should throw on invalid hex input (non-hex characters)
    • Should throw on invalid IV length

Use Node's native node:test and node:assert/strict modules.

Impact that it would Provide:

  • Ensures encrypt/decrypt functionality works correctly
  • Catches regressions early in development
  • Provides documentation of expected behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions