AI Implementation feature(873): Landing Page and Login/Register Modal 1.01 (#13)
This commit was merged in pull request #13.
This commit is contained in:
@@ -32,6 +32,25 @@ describe('RegistrationRateLimitService', () => {
|
||||
for (let i = 0; i < 10; i++) s.record('1.1.1.1', now + i);
|
||||
expect(s.isAllowed('2.2.2.2', now + 10)).toBe(true);
|
||||
});
|
||||
|
||||
it('tryConsume admits exactly 10 and rejects the 11th without double-recording', () => {
|
||||
const s = new RegistrationRateLimitService();
|
||||
const now = 1_000_000;
|
||||
for (let i = 0; i < 10; i++) {
|
||||
expect(s.tryConsume('1.1.1.1', now + i)).toBe(true);
|
||||
}
|
||||
expect(s.tryConsume('1.1.1.1', now + 10)).toBe(false);
|
||||
});
|
||||
|
||||
it('tryConsume admits again once the window rolls over', () => {
|
||||
const s = new RegistrationRateLimitService();
|
||||
const base = 1_000_000;
|
||||
for (let i = 0; i < 10; i++) {
|
||||
expect(s.tryConsume('1.1.1.1', base + i)).toBe(true);
|
||||
}
|
||||
expect(s.tryConsume('1.1.1.1', base + 10)).toBe(false);
|
||||
expect(s.tryConsume('1.1.1.1', base + 60_000)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('register-first-admin registration rate limit (integration)', () => {
|
||||
@@ -77,4 +96,4 @@ describe('register-first-admin registration rate limit (integration)', () => {
|
||||
.send({ username: 'noone', password: 'Sup3rSecret!Pass' })
|
||||
.expect(429);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user