Files
outline/server/queues/processors/TeamUpdatedProcessor.test.ts
Tom MoorandClaude Opus 5 c74fd2e649 fix: Apply MCP preference to dynamically registered OAuth clients (#13418)
* fix: Apply MCP preference to dynamically registered OAuth clients

Dynamically registered clients exist only to serve MCP, but the preference
was only consulted at registration time. They are now unreadable once the
preference is off, and their outstanding grants are revoked at the point it
changes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: Keep default retry options on revocation task

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* refactor: Rename MCPDisabledProcessor to TeamUpdatedProcessor

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 21:43:56 -04:00

72 lines
2.1 KiB
TypeScript

import { TeamPreference } from "@shared/types";
import { buildTeam } from "@server/test/factories";
import RevokeDynamicOAuthClientsTask from "../tasks/RevokeDynamicOAuthClientsTask";
import TeamUpdatedProcessor from "./TeamUpdatedProcessor";
const ip = "127.0.0.1";
afterEach(() => {
vi.restoreAllMocks();
});
describe("TeamUpdatedProcessor", () => {
it("should schedule revocation when the MCP preference is disabled", async () => {
const team = await buildTeam();
const spy = vi.spyOn(RevokeDynamicOAuthClientsTask.prototype, "schedule");
const processor = new TeamUpdatedProcessor();
await processor.perform({
name: "teams.update",
teamId: team.id,
actorId: team.id,
ip,
changes: {
attributes: { preferences: { [TeamPreference.MCP]: false } },
previous: { preferences: { [TeamPreference.MCP]: true } },
},
});
expect(spy).toHaveBeenCalledWith({ teamId: team.id });
});
it("should not schedule revocation when the MCP preference is enabled", async () => {
const team = await buildTeam();
const spy = vi.spyOn(RevokeDynamicOAuthClientsTask.prototype, "schedule");
const processor = new TeamUpdatedProcessor();
await processor.perform({
name: "teams.update",
teamId: team.id,
actorId: team.id,
ip,
changes: {
attributes: { preferences: { [TeamPreference.MCP]: true } },
previous: { preferences: { [TeamPreference.MCP]: false } },
},
});
expect(spy).not.toHaveBeenCalled();
});
it("should not schedule revocation for an unrelated preference change", async () => {
const team = await buildTeam();
const spy = vi.spyOn(RevokeDynamicOAuthClientsTask.prototype, "schedule");
const processor = new TeamUpdatedProcessor();
await processor.perform({
name: "teams.update",
teamId: team.id,
actorId: team.id,
ip,
changes: {
attributes: {
preferences: { [TeamPreference.ViewersCanExport]: false },
},
previous: { preferences: { [TeamPreference.ViewersCanExport]: true } },
},
});
expect(spy).not.toHaveBeenCalled();
});
});