feat(api): Add safeguard when using formdata without a boundary

This commit is contained in:
Jesse Wierzbinski 2024-05-12 13:21:06 -10:00
parent 3f9ec0bc80
commit 67bee695e6
No known key found for this signature in database
3 changed files with 45 additions and 0 deletions

View file

@ -60,4 +60,29 @@ describe("API Tests", () => {
await db.delete(Emojis).where(eq(Emojis.shortcode, "test"));
});
});
test("Try sending FormData without a boundary", async () => {
const formData = new FormData();
formData.append("test", "test");
const response = await sendTestRequest(
new Request(
wrapRelativeUrl(`${base_url}/api/v1/custom_emojis`, base_url),
{
method: "GET",
headers: {
Authorization: `Bearer ${tokens[0].accessToken}`,
"Content-Type": "multipart/form-data",
},
body: formData,
},
),
);
expect(response.status).toBe(400);
const data = await response.json();
expect(data.error).toBeString();
expect(data.error).toContain("https://stackoverflow.com");
});
});