29 lines
985 B
TypeScript
29 lines
985 B
TypeScript
import { BadRequestException } from '@nestjs/common';
|
|
import { strictValidationPipe } from '../common/strict-validation.pipe';
|
|
import { ClientFileUploadDto } from './client-files.dto';
|
|
|
|
describe('ClientFileUploadDto', () => {
|
|
it('accepts bounded client material paths and rejects traversal before storage', async () => {
|
|
await expect(
|
|
strictValidationPipe.transform(
|
|
{ purpose: 'drainage_report_material', prefix: 'drainage-materials/item-1' },
|
|
{
|
|
type: 'body',
|
|
metatype: ClientFileUploadDto,
|
|
data: undefined,
|
|
},
|
|
),
|
|
).resolves.toEqual(expect.objectContaining({ purpose: 'drainage_report_material' }));
|
|
await expect(
|
|
strictValidationPipe.transform(
|
|
{ purpose: 'enterprise_certification', prefix: '../admin' },
|
|
{
|
|
type: 'body',
|
|
metatype: ClientFileUploadDto,
|
|
data: undefined,
|
|
},
|
|
),
|
|
).rejects.toBeInstanceOf(BadRequestException);
|
|
});
|
|
});
|