refactor: strengthen client boundaries and quality gates
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user