mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
more content length test inputs
This commit is contained in:
@@ -319,23 +319,28 @@ describe('/upload', () => {
|
|||||||
expect(body).toEqual(errorDto.badRequest('Quota has been exceeded!'));
|
expect(body).toEqual(errorDto.badRequest('Quota has been exceeded!'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reject when request body is larger than declared content length', async () => {
|
// The current implementation depends on the web server to enforce
|
||||||
const length = 1024 * 1024;
|
// this as this case does not even reach app code, but we test a few
|
||||||
const content = randomBytes(length);
|
// values here to make sure it stays that way.
|
||||||
|
it.each([1337, 27, 1024 * 1024 + 5, 512 * 512 + 1])(
|
||||||
|
'should reject when request body is larger than declared content length of %d bytes',
|
||||||
|
async (length) => {
|
||||||
|
const content = randomBytes(length);
|
||||||
|
|
||||||
const { status } = await request(app)
|
const { status } = await request(app)
|
||||||
.post('/upload')
|
.post('/upload')
|
||||||
.set('Authorization', `Bearer ${user.accessToken}`)
|
.set('Authorization', `Bearer ${user.accessToken}`)
|
||||||
.set('Upload-Draft-Interop-Version', '8')
|
.set('Upload-Draft-Interop-Version', '8')
|
||||||
.set('X-Immich-Asset-Data', assetData)
|
.set('X-Immich-Asset-Data', assetData)
|
||||||
.set('Repr-Digest', `sha=:${createHash('sha1').update(content).digest('base64')}:`)
|
.set('Repr-Digest', `sha=:${createHash('sha1').update(content).digest('base64')}:`)
|
||||||
.set('Upload-Complete', '?0')
|
.set('Upload-Complete', '?0')
|
||||||
.set('Upload-Length', length.toString())
|
.set('Upload-Length', length.toString())
|
||||||
.set('Content-Length', (length - 1).toString())
|
.set('Content-Length', (length - 1).toString())
|
||||||
.send(content);
|
.send(content);
|
||||||
|
|
||||||
expect(status).toBe(400);
|
expect(status).toBe(400);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('resumeUpload', () => {
|
describe('resumeUpload', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user