feat: harden CMPP delivery and platform workflows
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
import { FilesService } from './files.service';
|
||||
|
||||
describe('FilesService', () => {
|
||||
@@ -81,6 +82,26 @@ describe('FilesService', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects images over 2MB and other files over 10MB before object storage writes', async () => {
|
||||
const prisma = { fileObject: { create: jest.fn() } };
|
||||
const objectStorage = { putObject: jest.fn(), getBucket: jest.fn().mockReturnValue('bucket') };
|
||||
const service = new FilesService(prisma as never, objectStorage as never);
|
||||
|
||||
await expect(service.upload({ purpose: 'test' }, {
|
||||
originalname: 'large.png',
|
||||
mimetype: 'image/png',
|
||||
size: 2 * 1024 * 1024 + 1,
|
||||
buffer: Buffer.alloc(0),
|
||||
})).rejects.toBeInstanceOf(BadRequestException);
|
||||
await expect(service.upload({ purpose: 'test' }, {
|
||||
originalname: 'large.pdf',
|
||||
mimetype: 'application/pdf',
|
||||
size: 10 * 1024 * 1024 + 1,
|
||||
buffer: Buffer.alloc(0),
|
||||
})).rejects.toBeInstanceOf(BadRequestException);
|
||||
expect(objectStorage.putObject).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('downloads file content from object storage by FileObject id', async () => {
|
||||
const fileObject = {
|
||||
id: 'file-1',
|
||||
|
||||
Reference in New Issue
Block a user