diff --git a/src/commands.ts b/src/commands.ts index f73fc00..91a8afa 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -520,10 +520,10 @@ export async function setup(ctx: Context, options: SetupOptions): Promise { + const removeRemote = async (link: AgentLink, name: string, strict = link.server !== server) => { const token = link.server === server ? session.token : state.servers[link.server]?.session?.token; if (!token) { leftBehind.push({ name, server: link.server }); diff --git a/test/targets.test.ts b/test/targets.test.ts index 8cea611..56ab1d1 100644 --- a/test/targets.test.ts +++ b/test/targets.test.ts @@ -661,6 +661,19 @@ describe("agents on several servers", () => { expect(errors()).toContain(`Could not confirm removal of the old Cursor authorization (agent-1) at ${CLOUD}.`); }); + it("does not treat a 403 from another server as revoked when turning an agent off", async () => { + const { local, ctx, cloud } = await cursorOnCloud({ local: true }); + const routed = network(local, cloud); + const { ctx: other } = context(((input: string | URL | Request, init?: RequestInit) => + init?.method === "DELETE" && String(input).startsWith(CLOUD) + ? Promise.resolve(Response.json({ message: "Forbidden" }, { status: 403 })) + : routed(input, init)) as typeof fetch); + await expect(setup({ ...ctx, api: other.api }, { local: true, disable: "cursor" })).rejects.toThrow( + `Disabled locally, but remote cleanup failed. Remove Cursor authorization (agent-1) in the Toolstile dashboard at ${CLOUD}.`, + ); + expect(cloud.agents.size).toBe(1); + }); + it("says where to remove access it could not revoke", async () => { const { cloud, ctx, output } = await cursorOnCloud({ local: true }); await logout(ctx, { server: CLOUD });