Skip to content

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

Let a paired phone delete one bot

arronlee-uyx76f9e61fa6fc
diff --git a/companion/test/routes.test.ts b/companion/test/routes.test.ts
index b3c1ed9938..e40e5ff24d 100644
--- a/companion/test/routes.test.ts
+++ b/companion/test/routes.test.ts
@@ -41,6 +41,7 @@ describe("what the app may do", () => {
["GET", "/api/bots"],
["POST", "/api/bots"],
["PATCH", "/api/bots/bot_123"],
+ ["DELETE", "/api/bots/bot_123"],
["PUT", "/api/bots/order"],
["POST", "/api/sidebar-sections"],
["POST", "/api/bots/bot_123/messages"],
@@ -281,7 +282,7 @@ describe("what it may not", () => {
it("allows a path only for the methods it was allowed for", () => {
expect(allowed("GET", "/api/bots")).toBe(true);
- expect(allowed("DELETE", "/api/bots/bot_123")).toBe(false);
+ expect(allowed("DELETE", "/api/bots")).toBe(false);
expect(allowed("POST", "/api/threads/th_1/messages")).toBe(false);
expect(allowed("GET", "/api/threads/th_1/messages/msg_2/file")).toBe(false);
expect(allowed("POST", "/api/threads/th_1/messages/msg_2/file/extra")).toBe(false);
@@ -356,6 +357,15 @@ describe("what it may not", () => {
] as const) expect(allowed(method, path), `${method} ${path}`).toBe(false);
});
+ it("lets a paired phone delete one bot, and nothing beside it", () => {
+ expect(allowed("DELETE", "/api/bots/bot_123")).toBe(true);
+ expect(allowed("DELETE", "/api/bots")).toBe(false);
+ expect(allowed("DELETE", "/api/bots/bot_123/extra")).toBe(false);
+ expect(allowed("DELETE", "/api/bots/../config")).toBe(false);
+ expect(allowed("GET", "/api/bots/bot_123")).toBe(false);
+ expect(ask("DELETE", "/api/bots/bot_123", false)?.status).toBe(401);
+ });
+
it("is not fooled by a prefix", () => {
expect(allowed("GET", "/api/bots/bot_123/computer")).toBe(false);
expect(allowed("GET", "/api/botsandthensome")).toBe(false);