Skip to content

test: add comprehensive test suite for RateLimitStore (closes #1081) - #1253

Open
fadesany wants to merge 1 commit into
RevoraOrg:masterfrom
fadesany:feature/backend-011-rate-limiter-tier-policies
Open

fadesany wants to merge 1 commit into
RevoraOrg:masterfrom
fadesany:feature/backend-011-rate-limiter-tier-policies

Conversation

@fadesany

@fadesany fadesany commented Oct 5, 2026

Copy link
Copy Markdown

Adds dedicated test suite for src/security/rateLimit.ts covering RateLimitStore, InMemoryRateLimitStore, RedisRateLimitStore, SlidingWindowRateLimiter, createRateLimitMiddleware, and factory functions. Coverage: 100% statements/lines/functions, 90.24% branches. Closes #1081

- Covers RateLimitStore interface contract
- Tests InMemoryRateLimitStore: get, set, increment, reset, cleanup
- Tests RedisRateLimitStore: get, set, increment, reset with mocked Redis
- Tests SlidingWindowRateLimiter: isAllowed, recordRequest
- Tests defaultKeyGenerator with various security contexts
- Tests createRateLimitMiddleware: allowed/blocked requests, headers, custom key generator, onLimitReached, audit events, fail-open behavior
- Tests factory functions: createValidationRateLimit, createAuthRateLimit, createAuditRateLimit
- Tests createRateLimitStore factory with different environments
- Tests edge cases: missing security context, missing route, reset time calculation

Coverage: 100% statements, 100% lines, 100% functions, 90.24% branches
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 focused behavior coverage for RateLimitStore

1 participant