lab4: исправления второго ревью (40 Мп в tmpfs, таймауты S3, параллельный complete, auth до Content-Type, лимит на пользователя, бюджет памяти декода)

This commit is contained in:
2026-10-23 17:09:49 +03:00
parent a06471a6c6
commit 4b53e03fd6
27 changed files with 642 additions and 141 deletions
@@ -3,7 +3,11 @@ import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
import { jpegWithoutScanData } from '../../../test/support/jpeg.js';
import { noisePng, pngWithGarbageIdat } from '../../../test/support/png.js';
import {
maxPixelsRgba16Png,
noisePng,
pngWithGarbageIdat,
} from '../../../test/support/png.js';
import { ImageDecoder } from './image-decoder.js';
import { ImageInspector, ImageRejectedError } from './image-inspector.js';
@@ -48,4 +52,19 @@ describe('ImageDecoder', () => {
ImageRejectedError,
);
});
it('accepts the heaviest valid input: 40 MP RGBA 16-bit', async () => {
await decoder.verify(await maxPixelsRgba16Png());
});
it('drops an aborted waiter from the queue without running its decode', async () => {
const busy = decoder.verify(noisePng(4_000_000));
const controller = new AbortController();
const waiting = decoder.verify(png, controller.signal);
controller.abort();
await expect(waiting).rejects.toMatchObject({ status: 503 });
await busy;
// The slot was not leaked: the next decode runs.
await decoder.verify(png);
});
});