From 4f020f135216f776e85cf79466015b6c0f4d0dff Mon Sep 17 00:00:00 2001 From: Lordfirespeed <28568841+Lordfirespeed@users.noreply.github.com> Date: Tue, 20 Aug 2024 17:13:14 +0100 Subject: [PATCH] test(multipart): add tests to actually complete coverage of `split-multipart` --- tests/parsers/multipart.test.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/parsers/multipart.test.ts b/tests/parsers/multipart.test.ts index bca1d64..dbf4e76 100644 --- a/tests/parsers/multipart.test.ts +++ b/tests/parsers/multipart.test.ts @@ -177,6 +177,38 @@ it('should reject multipart form data with non-linear-whitespace characters on a 'epilogue', ].join('\r\n') + expect(() => { + parseMultipart(Buffer.from(multipart), 'boundary') + }).toThrow() +}) + +it('should reject multipart form data with parts after a close delimiter', () => { + const multipart = [ + 'preamble', + '--boundary', + '', + '', + '--boundary--', + '', + '', + '--boundary', + 'epilogue', + ].join('\r\n') + + expect(() => { + parseMultipart(Buffer.from(multipart), 'boundary') + }).toThrow() +}) + +it('should reject multipart form data with non-linear-whitespace characters on a boundary line with no preamble', () => { + const multipart = [ + '--boundary eeee', + '', + '', + '--boundary--', + 'epilogue', + ].join('\r\n') + expect(() => { parseMultipart(Buffer.from(multipart), 'boundary') }).toThrow()