chore: import DH V2 D5.6.4 production baseline
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
inspectInspectionSignatureFile,
|
||||
MAX_INSPECTION_SIGNATURE_BYTES,
|
||||
} from '../../src/inspection-closing/inspection-signature-file';
|
||||
|
||||
const png = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 0]);
|
||||
|
||||
test('D5 signature accepts only PNG content and MIME', () => {
|
||||
assert.deepEqual(inspectInspectionSignatureFile({
|
||||
originalname: 'firma.png',
|
||||
mimetype: 'image/png',
|
||||
size: png.length,
|
||||
buffer: png,
|
||||
}), {
|
||||
originalName: 'firma.png',
|
||||
mimeType: 'image/png',
|
||||
extension: '.png',
|
||||
});
|
||||
assert.throws(() => inspectInspectionSignatureFile({
|
||||
originalname: 'firma.png',
|
||||
mimetype: 'image/png',
|
||||
size: 4,
|
||||
buffer: Buffer.from('test'),
|
||||
}));
|
||||
assert.throws(() => inspectInspectionSignatureFile({
|
||||
originalname: 'firma.png',
|
||||
mimetype: 'application/octet-stream',
|
||||
size: png.length,
|
||||
buffer: png,
|
||||
}));
|
||||
});
|
||||
|
||||
test('D5 signature rejects empty and oversized files', () => {
|
||||
assert.throws(() => inspectInspectionSignatureFile(undefined));
|
||||
assert.throws(() => inspectInspectionSignatureFile({
|
||||
originalname: 'firma.png',
|
||||
mimetype: 'image/png',
|
||||
size: MAX_INSPECTION_SIGNATURE_BYTES + 1,
|
||||
buffer: Buffer.concat([png, Buffer.alloc(MAX_INSPECTION_SIGNATURE_BYTES)]),
|
||||
}));
|
||||
});
|
||||
Reference in New Issue
Block a user