-
Notifications
You must be signed in to change notification settings - Fork 489
Rate Testing #1605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Rate Testing #1605
Changes from all commits
98b05a0
5f07c60
f990077
2c0423f
f932890
91bd782
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| /* This file currently only tests the login route rate limiting functionality. | ||
| It ensures that repeated login attempts are blocked after | ||
| exceeding the configured rate limit. */ | ||
|
|
||
| // TODO: Create additonal rate limits tests for other OED Routes | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spelling: additonal |
||
|
|
||
| const { HTTP_CODE } = require('../util/readingsUtils'); | ||
| const { chai, mocha, expect, app } = require('../test/common'); | ||
| const { todo } = require('node:test'); | ||
|
|
||
| mocha.describe('Login Rate Limit', () => { | ||
| mocha.it('Should block repeated login attempts with 429', async () => { | ||
| const first = await chai.request(app) | ||
| .post('/api/login') | ||
| .send({ | ||
| username: 'invalidUser', | ||
| password: 'invalidPassword' | ||
| }); | ||
|
|
||
| //First request that makes it through to authentication | ||
| expect(first).to.have.status(HTTP_CODE.UNAUTHORIZED); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is failing on my machine. It is giving a 404/NOT_FOUND instead of 401/UNAUTHORIZED. I have not looked into why. Do you see that when you do I'm going to put off testing all the new package script choices until this is resolved. |
||
|
|
||
| const second = await chai.request(app) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redoing comment since code moved. I had:
I think discussing here that the limit should be 1 for an hour so this fails with a comment has value. |
||
| .post('/api/login') | ||
| .send({ | ||
| username: 'invalidUser', | ||
| password: 'invalidPassword' | ||
| }); | ||
|
|
||
| //Second request that triggers the rate limit of 1 request per hour | ||
| expect(second).to.have.status(HTTP_CODE.TOO_MANY_REQUESTS); | ||
| expect(second.text).to.include('Too many requests'); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misspelled: specifc, seperately & enviroment