fix tests isues

This commit is contained in:
root
2026-06-11 01:43:25 -04:00
parent 64df4439d3
commit b22983650d
16 changed files with 10 additions and 1485 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ export function detectImageType(buffer: Buffer): DetectedFile | null {
function assertSafeImageContent(file: Express.Multer.File) {
const detected = detectImageType(file.buffer)
if (!detected || !ALLOWED_IMAGE_TYPES.has(detected.mime)) {
throw new ValidationError(`Unsupported or spoofed image file: ${file.name}`)
throw new ValidationError(`Unsupported or spoofed image file: ${file.originalname}`)
}
if (file.mimetype !== detected.mime) {
+1 -1
View File
@@ -36,6 +36,6 @@ describe('upload assertions', () => {
expect(() => assertImageFiles([
file({ originalname: 'front.png', mimetype: 'image/png', buffer: Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]) }),
file({ originalname: 'report.pdf', mimetype: 'application/pdf', buffer: Buffer.from('%PDF') }),
])).toThrow(`Unsupported or spoofed image file: ${overrides.name}`)
])).toThrow('Unsupported or spoofed image file: report.pdf')
})
})