Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Test: zip uploads to /api/files are accepted; keep an unsupported type rejected

AdityaUmale4022e4faface
diff --git a/server/index.test.ts b/server/index.test.ts
index 275dabd568..bdc82787a1 100644
--- a/server/index.test.ts
+++ b/server/index.test.ts
@@ -5313,10 +5313,21 @@ describe("harness HTTP API", () => {
expect(statSync(result.path).mode & 0o777).toBe(0o600);
}
- const unsupported = await fetch(`${BASE}/api/files?name=payload.zip`, {
+ const archive = Buffer.from("archive");
+ const zip = await fetch(`${BASE}/api/files?name=payload.zip`, {
method: "POST",
headers: { "content-type": "application/zip" },
- body: Buffer.from("archive"),
+ body: archive,
+ });
+ expect(zip.status).toBe(201);
+ const zipResult = (await zip.json()) as { path: string; name: string; mime: string; bytes: number };
+ expect(zipResult).toMatchObject({ name: "payload.zip", mime: "application/zip", bytes: archive.byteLength });
+ expect(zipResult.path).toMatch(/\.zip$/);
+
+ const unsupported = await fetch(`${BASE}/api/files?name=payload.exe`, {
+ method: "POST",
+ headers: { "content-type": "application/x-msdownload" },
+ body: Buffer.from("binary"),
});
expect(unsupported.status).toBe(400);