Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions test/routes-decompress.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,31 @@ describe('When using routes `decompress` settings :', async () => {
})
equal(usedCustomGlobal, false)

equal(response.statusCode, 400)
t.assert.match(response.json().message, /is not valid JSON/)
})

test('it should return FST_ERR_CTP_INVALID_CONTENT_LENGTH when Content-Length mismatches payload', async (t) => {
t.plan(2)
const equal = t.assert.equal

const fastify = Fastify()
await fastify.register(compressPlugin)

fastify.post('/length', (request, reply) => {
reply.send({ ok: true })
})

const response = await fastify.inject({
url: '/length',
method: 'POST',
headers: {
'content-type': 'application/json',
'content-length': '100',
},
payload: JSON.stringify({ hello: 'world' })
})

equal(response.statusCode, 400)
t.assert.deepEqual(response.json(), {
statusCode: 400,
Expand Down