Skip to content

Commit

Permalink
Add todo comments to login tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed Sep 29, 2024
1 parent 76653f6 commit 636325e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/backend/admin/auth/login.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ it('Returns a token when correct credentials are provided', async () => {
});

it('Blocks logins with non-existent usernames', async () => {
await expect(api().admin.auth.login(credentials.username + 'hi', credentials.password))
await expect(api().admin.auth.login('invalid user', credentials.password))
.rejects.toMatchObject({ code: 401 });
});

Expand All @@ -47,7 +47,7 @@ it('Errors if fields are empty', async () => {
});

it('Blocks logins with incorrect passwords', async () => {
await expect(api().admin.auth.login(credentials.username, credentials.password + 'hi'))
await expect(api().admin.auth.login(credentials.username, 'incorrect password'))
.rejects.toMatchObject({ code: 401 });
});

Expand All @@ -72,6 +72,10 @@ it('Has random variance in the timing for failed passwords', async () => {
let slowest = -1;
// Run many logins, and check that there is more than 10ms difference between the
// fastest and slowest
// FIXME: Reduce this number so that the number of unsuccessful logins before a
// ban is reduced
// and perhaps find a way to get vitest to retry it a number of times if it
// fails
for (let i = 0; i < 25; i++) {
const start = Date.now();
try {
Expand Down

0 comments on commit 636325e

Please sign in to comment.