fix tests
This commit is contained in:
@@ -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')
|
||||
throw new ValidationError(`Unsupported or spoofed image file: ${file.name}`)
|
||||
}
|
||||
|
||||
if (file.mimetype !== detected.mime) {
|
||||
|
||||
@@ -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')
|
||||
])).toThrow(`Unsupported or spoofed image file: ${overrides.name}`)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user