Skip to content

Commit

Permalink
Fix wrong bruteforce detection in test server
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Aug 29, 2024
1 parent ce812da commit 1b9ecf0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test-client/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,19 @@ it('receives HTTP requests', async () => {
expect(response4.status).toEqual(404)
})

it('does not block login because of bruteforce', async () => {
server = new TestServer()
server.auth(({ userId }) => {
return userId === 'good'
})
await server.expectWrongCredentials('bad1')
await server.expectWrongCredentials('bad2')
await server.expectWrongCredentials('bad3')
await server.expectWrongCredentials('bad4')
await server.expectWrongCredentials('bad5')
await server.connect('good')
})

it('destroys on fatal', () => {
server = new TestServer()
// @ts-expect-error
Expand Down
4 changes: 4 additions & 0 deletions test-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,8 @@ export class TestServer extends BaseServer {
let { port } = server.address()
return fetch(`http://localhost:${port}${path}`, init)
}

isBruteforce() {
return false
}
}

0 comments on commit 1b9ecf0

Please sign in to comment.