forked from mtusi2026/mtusi2026lab4
lab4: исправления по ревью (парсеры image/text только на upload, rejected-статус прямой загрузки, диапазон 64 KiB, отчёт)
This commit is contained in:
@@ -325,6 +325,21 @@ describe('attachments (proxy upload)', () => {
|
||||
expectError(await variant('bogus'), 400, 'invalid_request');
|
||||
});
|
||||
|
||||
it('answers 4xx, not 500, for raw image or text bodies on JSON routes', async () => {
|
||||
for (const [type, status, code] of [
|
||||
['image/png', 415, 'unsupported_media_type'],
|
||||
['image/jpeg', 415, 'unsupported_media_type'],
|
||||
['text/plain', 400, 'invalid_request'],
|
||||
] as const) {
|
||||
const result = await http<ApiErrorBody>('/api/v1/users', {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': type },
|
||||
body: 'x',
|
||||
});
|
||||
expectError(result, status, code);
|
||||
}
|
||||
});
|
||||
|
||||
it('removes the pending row when the client drops the connection', async () => {
|
||||
const data = noisePng(2 * 1024 * 1024);
|
||||
const url = new URL(baseUrl);
|
||||
|
||||
@@ -228,6 +228,19 @@ describe('direct upload (presigned PUT)', () => {
|
||||
404,
|
||||
'not_found',
|
||||
);
|
||||
// The URL is still valid: a re-PUT must stay tracked so the sweeper
|
||||
// removes the new object too.
|
||||
expect((await put(ticket, jpeg)).status).toBe(200);
|
||||
const row = await db.query<{ status: string }>(
|
||||
'SELECT status FROM attachments WHERE id = $1',
|
||||
[ticket.attachment_id],
|
||||
);
|
||||
expect(row.rows[0]?.status).toBe('rejected');
|
||||
expectError(
|
||||
await complete(alice.token, ticket.attachment_id),
|
||||
404,
|
||||
'not_found',
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects a pixel bomb on complete', async () => {
|
||||
|
||||
Reference in New Issue
Block a user