forked from mtusi2026/mtusi2026lab4
lab4: компенсация без потери объекта при потере ответа COMMIT, полный декод изображений (sharp) в proxy и direct complete
This commit is contained in:
@@ -21,7 +21,13 @@ import {
|
||||
upload,
|
||||
uploadRaw,
|
||||
} from './support/e2e.js';
|
||||
import { noisePng, padPngTo, pixelBombPng } from './support/png.js';
|
||||
import { jpegWithoutScanData } from './support/jpeg.js';
|
||||
import {
|
||||
noisePng,
|
||||
padPngTo,
|
||||
pixelBombPng,
|
||||
pngWithGarbageIdat,
|
||||
} from './support/png.js';
|
||||
|
||||
const png = readFileSync(
|
||||
new URL('../../tests/fixtures/sample.png', import.meta.url),
|
||||
@@ -167,6 +173,8 @@ describe('attachments (proxy upload)', () => {
|
||||
flipped,
|
||||
Buffer.concat([png.subarray(0, 8), randomBytes(2048)]),
|
||||
Buffer.alloc(0),
|
||||
// Structure and CRCs are fine; the pixel data does not decode.
|
||||
pngWithGarbageIdat(),
|
||||
];
|
||||
for (const data of cases)
|
||||
expectError(
|
||||
@@ -176,6 +184,24 @@ describe('attachments (proxy upload)', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
['baseline', jpeg],
|
||||
['progressive', progressive],
|
||||
])('rejects a %s JPEG without scan data', async (_name, data) => {
|
||||
expectError(
|
||||
await upload(
|
||||
alice.token,
|
||||
leftoverChatId,
|
||||
jpegWithoutScanData(data),
|
||||
{
|
||||
contentType: 'image/jpeg',
|
||||
},
|
||||
),
|
||||
415,
|
||||
'unsupported_media_type',
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects a content type that does not match the bytes', async () => {
|
||||
const gif = Buffer.from('GIF89a' + 'x'.repeat(64));
|
||||
const cases: [Buffer, string][] = [
|
||||
|
||||
Reference in New Issue
Block a user