diff --git a/src/lib/routes/index.ts b/src/lib/routes/index.ts index 3cee6a9805..94f3a4de5e 100644 --- a/src/lib/routes/index.ts +++ b/src/lib/routes/index.ts @@ -14,6 +14,7 @@ import { conditionalMiddleware } from '../middleware'; import EdgeController from './edge-api'; import { PublicInviteController } from './public-invite'; import { Db } from '../db/db'; +import { minutesToMilliseconds } from 'date-fns'; class IndexRouter extends Controller { constructor(config: IUnleashConfig, services: IUnleashServices, db: Db) { @@ -30,8 +31,8 @@ class IndexRouter extends Controller { '/auth/simple', new SimplePasswordProvider(config, services).router, rateLimit({ - windowMs: 1 * 60 * 1000, - max: 5, + windowMs: minutesToMilliseconds(1), + max: 10, standardHeaders: true, legacyHeaders: false, }), diff --git a/src/test/e2e/api/auth/simple-password-provider.e2e.test.ts b/src/test/e2e/api/auth/simple-password-provider.e2e.test.ts index 0b09d8babb..6b4f4bed86 100644 --- a/src/test/e2e/api/auth/simple-password-provider.e2e.test.ts +++ b/src/test/e2e/api/auth/simple-password-provider.e2e.test.ts @@ -30,7 +30,7 @@ const password = 'DtUYwi&l5I1KX4@Le'; let userService: UserService; let adminUser: IUser; -beforeAll(async () => { +beforeEach(async () => { db = await dbInit('simple_password_provider_api_serial', getLogger); stores = db.stores; app = await setupApp(stores); @@ -72,8 +72,8 @@ test('Can log in', async () => { .expect(200); }); -test('Gets rate limited after 5 tries', async () => { - for (let statusCode of [200, 200, 200, 200, 429]) { +test('Gets rate limited after 10 tries', async () => { + for (let statusCode of [...Array(10).fill(200), 429]) { await app.request .post('/auth/simple/login') .send({