Files
outline/server/policies/oauthClient.test.ts
T
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

50 lines
1.7 KiB
TypeScript

import { TeamPreference } from "@shared/types";
import { buildOAuthClient, buildTeam, buildUser } from "@server/test/factories";
import { can } from "./index";
describe("policies/oauthClient", () => {
describe("read", () => {
it("should allow reading a client in the same team", async () => {
const team = await buildTeam();
const user = await buildUser({ teamId: team.id });
const oauthClient = await buildOAuthClient({ teamId: team.id });
expect(can(user, "read", oauthClient)).toBeTruthy();
});
it("should not allow reading a dynamically registered client when MCP is disabled", async () => {
const team = await buildTeam({
preferences: { [TeamPreference.MCP]: false },
});
const user = await buildUser({ teamId: team.id });
const oauthClient = await buildOAuthClient({
teamId: team.id,
createdById: null,
});
expect(can(user, "read", oauthClient)).toBeFalsy();
});
it("should allow reading a user created client when MCP is disabled", async () => {
const team = await buildTeam({
preferences: { [TeamPreference.MCP]: false },
});
const user = await buildUser({ teamId: team.id });
const oauthClient = await buildOAuthClient({ teamId: team.id });
expect(can(user, "read", oauthClient)).toBeTruthy();
});
it("should allow reading a dynamically registered client when MCP is enabled", async () => {
const team = await buildTeam();
const user = await buildUser({ teamId: team.id });
const oauthClient = await buildOAuthClient({
teamId: team.id,
createdById: null,
});
expect(can(user, "read", oauthClient)).toBeTruthy();
});
});
});