mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-30 16:39:33 +01:00
test(auth): multi-user still challenges a header-less request during lockout
The single-user suite pinned this; the multi-user one only showed that header-less requests are not counted. Fill the per-IP bucket with malformed headers, then expect 401 + challenge for no header and 429 for another malformed one. Fails on master. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cc2b7d9c25
commit
5ff018772e
1 file changed
+14
@@ -304,6 +304,20 @@ describe('multi-user auth', () => {
|
||||
expect((await malformed()).statusCode).toBe(429);
|
||||
});
|
||||
|
||||
it('requests without credentials still get the challenge while the IP is locked out', async () => {
|
||||
const { app } = await startIpServer();
|
||||
const ip = '203.0.113.42';
|
||||
const malformed = () =>
|
||||
app.inject({ method: 'GET', url: '/api/status', headers: { authorization: 'Bearer x' }, remoteAddress: ip });
|
||||
for (let i = 0; i < AUTH_IP_FAILURE_MAX; i++) await malformed();
|
||||
|
||||
// A 429 never makes a browser show its login dialog; a 401 challenge does.
|
||||
const bare = await app.inject({ method: 'GET', url: '/api/status', remoteAddress: ip });
|
||||
expect(bare.statusCode).toBe(401);
|
||||
expect(bare.headers['www-authenticate']).toBe('Basic realm="Codeman"');
|
||||
expect((await malformed()).statusCode).toBe(429);
|
||||
});
|
||||
|
||||
it('per-IP pre-gate: a concurrent burst from one IP reaches the verify at most AUTH_IP_FAILURE_MAX times', async () => {
|
||||
const { login, buckets } = await startIpServer();
|
||||
const ip = '203.0.113.40';
|
||||
|
||||
Reference in new issue
Block a user