forked from mtusi2026/mtusi2026lab4
lab4: компенсация без потери объекта при потере ответа COMMIT, полный декод изображений (sharp) в proxy и direct complete
This commit is contained in:
@@ -18,7 +18,7 @@ import {
|
||||
json,
|
||||
postMessage,
|
||||
} from './support/e2e.js';
|
||||
import { pixelBombPng } from './support/png.js';
|
||||
import { noisePng, pixelBombPng } from './support/png.js';
|
||||
|
||||
const png = readFileSync(
|
||||
new URL('../../tests/fixtures/sample.png', import.meta.url),
|
||||
@@ -243,6 +243,34 @@ describe('direct upload (presigned PUT)', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
['truncated PNG', () => png.subarray(0, png.length - 100)],
|
||||
[
|
||||
'PNG damaged after the first 64 KiB',
|
||||
() => {
|
||||
const data = noisePng(1_048_576);
|
||||
data[700_000] ^= 0xff;
|
||||
return data;
|
||||
},
|
||||
],
|
||||
])('rejects a %s even with a matching checksum', async (_name, make) => {
|
||||
// The declaration and the signed checksum match the bytes exactly:
|
||||
// only a check of the whole image can tell they are not an image.
|
||||
const data = make();
|
||||
const ticket = await initOk(data);
|
||||
expect((await put(ticket, data)).status).toBe(200);
|
||||
expectError(
|
||||
await complete(alice.token, ticket.attachment_id),
|
||||
415,
|
||||
'unsupported_media_type',
|
||||
);
|
||||
expectError(
|
||||
await complete(alice.token, ticket.attachment_id),
|
||||
404,
|
||||
'not_found',
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects a pixel bomb on complete', async () => {
|
||||
const bomb = pixelBombPng();
|
||||
const ticket = await initOk(bomb);
|
||||
|
||||
Reference in New Issue
Block a user