Skip to content

Commit aaa3a08

Browse files
committed
test: Tighten concurrent lockout test assertions
1 parent 9bbcb80 commit aaa3a08

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

spec/AccountLockoutPolicy.spec.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,21 @@ describe('Account Lockout Policy: ', () => {
374374
)
375375
);
376376

377-
const invalidPassword = results.filter(r => {
377+
const lockoutError =
378+
'Your account is locked due to multiple failed login attempts. Please try again after 5 minute(s)';
379+
const errors = results.map(r => {
378380
const body = typeof r.data === 'string' ? JSON.parse(r.data) : r.data;
379-
return body?.error === 'Invalid username/password.';
381+
return body?.error;
380382
});
383+
const invalidPassword = errors.filter(error => error === 'Invalid username/password.');
384+
const lockoutResponses = errors.filter(error => error === lockoutError);
381385

382-
// At most `threshold` requests should get "Invalid username/password"
383-
// The rest must get the lockout error
386+
expect(
387+
errors.every(
388+
error => error === 'Invalid username/password.' || error === lockoutError
389+
)
390+
).toBeTrue();
391+
expect(lockoutResponses.length).toBeGreaterThan(0);
384392
expect(invalidPassword.length).toBeLessThanOrEqual(threshold);
385393
});
386394
});

0 commit comments

Comments
 (0)