mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
chore(repo): remove dead code and useless tests (#3375)
This commit is contained in:
1 parent
7e177a1c90
commit
1cd62eb661
1391 files changed
+783
-120415
No files matched your search
@@ -56,27 +56,6 @@ describe('Auth IP Authorization Resend', () => {
|
||||
return ipAuthResp;
|
||||
}
|
||||
describe('Resend rate limit enforcement', () => {
|
||||
it('returns 429 when resend is attempted immediately after ticket creation', async () => {
|
||||
const email = createUniqueEmail('ip-resend-immediate');
|
||||
const password = 'a-strong-password';
|
||||
await registerUser(harness, {
|
||||
email,
|
||||
username: createUniqueUsername('resendimm'),
|
||||
global_name: 'Resend Immediate User',
|
||||
password,
|
||||
date_of_birth: '2000-01-01',
|
||||
consent: true,
|
||||
});
|
||||
const newIP = '10.200.210.220';
|
||||
const ipAuthResp = await triggerIpAuthorization(email, password, newIP);
|
||||
const errorResp = await createBuilderWithoutAuth<ResendErrorResponse>(harness)
|
||||
.post('/auth/ip-authorization/resend')
|
||||
.body({ticket: ipAuthResp.ticket})
|
||||
.header('x-forwarded-for', newIP)
|
||||
.expect(HTTP_TOO_MANY_REQUESTS)
|
||||
.execute();
|
||||
expect(errorResp.code).toBe(APIErrorCodes.IP_AUTHORIZATION_RESEND_COOLDOWN);
|
||||
});
|
||||
it('returns resend_available_in and a matching Retry-After header when rate limited', async () => {
|
||||
const email = createUniqueEmail('ip-resend-cooldown');
|
||||
const password = 'a-strong-password';
|
||||
@@ -103,30 +82,6 @@ describe('Auth IP Authorization Resend', () => {
|
||||
expect(errorResp.retry_after).toBe(errorResp.resend_available_in);
|
||||
});
|
||||
});
|
||||
describe('Multiple resend attempts handling', () => {
|
||||
it('returns 429 for multiple consecutive resend attempts', async () => {
|
||||
const email = createUniqueEmail('ip-multi-resend');
|
||||
const password = 'a-strong-password';
|
||||
await registerUser(harness, {
|
||||
email,
|
||||
username: createUniqueUsername('multiresend'),
|
||||
global_name: 'Multi Resend User',
|
||||
password,
|
||||
date_of_birth: '2000-01-01',
|
||||
consent: true,
|
||||
});
|
||||
const newIP = '10.30.31.32';
|
||||
const ipAuthResp = await triggerIpAuthorization(email, password, newIP);
|
||||
for (let i = 0; i < 3; i++) {
|
||||
await createBuilderWithoutAuth(harness)
|
||||
.post('/auth/ip-authorization/resend')
|
||||
.body({ticket: ipAuthResp.ticket})
|
||||
.header('x-forwarded-for', newIP)
|
||||
.expect(HTTP_TOO_MANY_REQUESTS)
|
||||
.execute();
|
||||
}
|
||||
});
|
||||
});
|
||||
describe('Resend with already-used ticket', () => {
|
||||
it('returns 400 when resend flag is already set on the ticket', async () => {
|
||||
const email = createUniqueEmail('ip-resend-used');
|
||||
@@ -198,25 +153,7 @@ describe('Auth IP Authorization Resend', () => {
|
||||
.execute();
|
||||
});
|
||||
});
|
||||
describe('Resend with empty ticket', () => {
|
||||
it('returns 400 when ticket is empty string', async () => {
|
||||
await createBuilderWithoutAuth(harness)
|
||||
.post('/auth/ip-authorization/resend')
|
||||
.body({ticket: ''})
|
||||
.expect(HTTP_STATUS.BAD_REQUEST)
|
||||
.execute();
|
||||
});
|
||||
});
|
||||
describe('Resend with invalid ticket', () => {
|
||||
it('returns 400 when ticket does not exist', async () => {
|
||||
const errorResp = await createBuilderWithoutAuth<ResendErrorResponse>(harness)
|
||||
.post('/auth/ip-authorization/resend')
|
||||
.body({ticket: 'invalid-ticket-xyz-12345'})
|
||||
.expect(HTTP_STATUS.BAD_REQUEST)
|
||||
.execute();
|
||||
expect(errorResp.code).toBeDefined();
|
||||
expect(errorResp.message).toBeDefined();
|
||||
});
|
||||
it('returns 400 when ticket has expired', async () => {
|
||||
const email = createUniqueEmail('ip-ticket-expired');
|
||||
const password = 'a-strong-password';
|
||||
@@ -242,75 +179,4 @@ describe('Auth IP Authorization Resend', () => {
|
||||
.execute();
|
||||
});
|
||||
});
|
||||
describe('Resend response format validation', () => {
|
||||
it('returns proper error structure with code and message on rate limit', async () => {
|
||||
const email = createUniqueEmail('ip-resend-format');
|
||||
const password = 'a-strong-password';
|
||||
await registerUser(harness, {
|
||||
email,
|
||||
username: createUniqueUsername('resendformat'),
|
||||
global_name: 'Resend Format User',
|
||||
password,
|
||||
date_of_birth: '2000-01-01',
|
||||
consent: true,
|
||||
});
|
||||
const newIP = '10.231.241.251';
|
||||
const ipAuthResp = await triggerIpAuthorization(email, password, newIP);
|
||||
const errorResp = await createBuilderWithoutAuth<ResendErrorResponse>(harness)
|
||||
.post('/auth/ip-authorization/resend')
|
||||
.body({ticket: ipAuthResp.ticket})
|
||||
.header('x-forwarded-for', newIP)
|
||||
.expect(HTTP_TOO_MANY_REQUESTS)
|
||||
.execute();
|
||||
expect(errorResp.code).toBe(APIErrorCodes.IP_AUTHORIZATION_RESEND_COOLDOWN);
|
||||
expect(typeof errorResp.message).toBe('string');
|
||||
expect(errorResp.message!.length).toBeGreaterThan(0);
|
||||
});
|
||||
it('returns proper error structure when ticket is invalid', async () => {
|
||||
const errorResp = await createBuilderWithoutAuth<ResendErrorResponse>(harness)
|
||||
.post('/auth/ip-authorization/resend')
|
||||
.body({ticket: 'nonexistent-ticket-abc'})
|
||||
.expect(HTTP_STATUS.BAD_REQUEST)
|
||||
.execute();
|
||||
expect(typeof errorResp.code).toBe('string');
|
||||
expect(typeof errorResp.message).toBe('string');
|
||||
});
|
||||
it('returns proper error structure when resend limit exceeded', async () => {
|
||||
const email = createUniqueEmail('ip-limit-format');
|
||||
const password = 'a-strong-password';
|
||||
const reg = await registerUser(harness, {
|
||||
email,
|
||||
username: createUniqueUsername('limitformat'),
|
||||
global_name: 'Limit Format User',
|
||||
password,
|
||||
date_of_birth: '2000-01-01',
|
||||
consent: true,
|
||||
});
|
||||
const ticket = `ticket-limit-${Date.now()}`;
|
||||
const token = `token-limit-${Date.now()}`;
|
||||
await createBuilderWithoutAuth(harness)
|
||||
.post('/test/auth/ip-authorization')
|
||||
.body({
|
||||
ticket,
|
||||
token,
|
||||
user_id: reg.user_id,
|
||||
email,
|
||||
username: 'limit-format-user',
|
||||
client_ip: '203.0.113.20',
|
||||
user_agent: 'IntegrationTest/1.0',
|
||||
client_location: 'Testland',
|
||||
resend_used: true,
|
||||
created_at: Date.now() - 2 * 60 * 1000,
|
||||
ttl_seconds: 900,
|
||||
})
|
||||
.execute();
|
||||
const errorResp = await createBuilderWithoutAuth<ResendErrorResponse>(harness)
|
||||
.post('/auth/ip-authorization/resend')
|
||||
.body({ticket})
|
||||
.expect(HTTP_STATUS.BAD_REQUEST)
|
||||
.execute();
|
||||
expect(errorResp.code).toBe(APIErrorCodes.IP_AUTHORIZATION_RESEND_LIMIT_EXCEEDED);
|
||||
expect(typeof errorResp.message).toBe('string');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user