From 18812e0473aa54de1d30f158f97f25b71dc094b7 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Fri, 28 Feb 2020 08:05:16 -0800 Subject: [PATCH] fix(rate limits): Duration was set to 1 second, not 1 minute. Fixed --- src/middleware/route-ratelimit.js | 2 +- test/v3/rate-limits.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/middleware/route-ratelimit.js b/src/middleware/route-ratelimit.js index cac39aa..acdc6bb 100644 --- a/src/middleware/route-ratelimit.js +++ b/src/middleware/route-ratelimit.js @@ -26,7 +26,7 @@ const { RateLimiterRedis } = require('rate-limiter-flexible') const rateLimitOptions = { storeClient: redisClient, points: 100, // Number of points - duration: 1 // Per second + duration: 60 // Per second } // This hard-coded value is temporary. It will be swapped out with an environment diff --git a/test/v3/rate-limits.js b/test/v3/rate-limits.js index 8f2e173..01f8e37 100644 --- a/test/v3/rate-limits.js +++ b/test/v3/rate-limits.js @@ -94,6 +94,8 @@ describe('#route-ratelimits & jwt-auth', () => { let routeRateLimit = rateLimitMiddleware.routeRateLimit // const getInfo = controlRoute.testableComponents.getInfo + // NOTE: this test will fail if you run multiple integration tests in a + // short period. Because it talks to the Redis DB. it('should pass through rate-limit middleware', async () => { req.baseUrl = '/v3' req.path = '/control/getNetworkInfo' @@ -433,6 +435,8 @@ describe('#route-ratelimits & jwt-auth', () => { }) describe('#rateLimitByResource', () => { + // NOTE: this test will fail if you run multiple integration tests in a + // short period. Because it talks to the Redis DB. it('should pass through rate-limit middleware', async () => { req.baseUrl = '/v3' req.path = '/control/getNetworkInfo'