Skip to content

test: add unit tests for token expiry validator (#769)Feature/token expiry validator - #788

Open
yugomania wants to merge 2 commits into
accesslayerorg:mainfrom
yugomania:feature/token-expiry-validator
Open

test: add unit tests for token expiry validator (#769)Feature/token expiry validator#788
yugomania wants to merge 2 commits into
accesslayerorg:mainfrom
yugomania:feature/token-expiry-validator

Conversation

@yugomania

@yugomania yugomania commented Aug 25, 2026

Copy link
Copy Markdown

Closes #769


Summary

Implement and test token expiry validation based on the token's iat claim and configured TTL.

What Changed

  • Added validateTokenExpiry to calculate the expected expiry timestamp as iat + ttlSeconds.
  • Added TOKEN_EXPIRY_TAMPERED and MISSING_IAT error codes.
  • Added unit tests covering all required token expiry validation scenarios.
  • Documented the new error codes in ERROR_CODE_REGISTRY.md.

Acceptance Criteria

  • Correct exp === iat + ttl passes validation.
  • Extended exp > iat + ttl fails with token_expiry_tampered.
  • Shortened exp < iat + ttl fails with token_expiry_tampered.
  • Missing iat fails with missing_iat.

Testing

  • pnpm test -- token-expiry → 4 tests passed
  • pnpm run lint → Passed
  • pnpm run build → Passed

Files Changed

  • src/constants/error.constants.ts
  • src/utils/token-expiry.validator.ts
  • src/utils/token-expiry.validator.test.ts
  • docs/ERROR_CODE_REGISTRY.md

Scope

This contribution is limited to token expiry validation, its required error codes, tests, and corresponding documentation. No unrelated functionality was modified.

@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@yugomania 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! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for the token expiry validator correctly computing the expiry timestamp from the issued-at claim

1 participant