Files
outline/server/queues/tasks/RevokeDynamicOAuthClientsTask.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

73 lines
2.2 KiB
TypeScript

import { Scope } from "@shared/types";
import { OAuthAuthentication, OAuthAuthorizationCode } from "@server/models";
import {
buildOAuthAuthentication,
buildOAuthAuthorizationCode,
buildOAuthClient,
buildUser,
} from "@server/test/factories";
import RevokeDynamicOAuthClientsTask from "./RevokeDynamicOAuthClientsTask";
describe("RevokeDynamicOAuthClientsTask", () => {
it("should revoke tokens and codes held by dynamic clients", async () => {
const user = await buildUser();
const client = await buildOAuthClient({
teamId: user.teamId,
createdById: null,
});
const authentication = await buildOAuthAuthentication({
user,
oauthClientId: client.id,
scope: [Scope.Read],
});
const code = await buildOAuthAuthorizationCode({
userId: user.id,
oauthClientId: client.id,
});
const task = new RevokeDynamicOAuthClientsTask();
await task.perform({ teamId: user.teamId });
expect(await OAuthAuthentication.findByPk(authentication.id)).toBeNull();
expect(await OAuthAuthorizationCode.findByPk(code.id)).toBeNull();
});
it("should not revoke tokens held by user created clients", async () => {
const user = await buildUser();
const client = await buildOAuthClient({ teamId: user.teamId });
const authentication = await buildOAuthAuthentication({
user,
oauthClientId: client.id,
scope: [Scope.Read],
});
const task = new RevokeDynamicOAuthClientsTask();
await task.perform({ teamId: user.teamId });
expect(
await OAuthAuthentication.findByPk(authentication.id)
).not.toBeNull();
});
it("should not revoke tokens held by dynamic clients in another team", async () => {
const user = await buildUser();
const other = await buildUser();
const client = await buildOAuthClient({
teamId: other.teamId,
createdById: null,
});
const authentication = await buildOAuthAuthentication({
user: other,
oauthClientId: client.id,
scope: [Scope.Read],
});
const task = new RevokeDynamicOAuthClientsTask();
await task.perform({ teamId: user.teamId });
expect(
await OAuthAuthentication.findByPk(authentication.id)
).not.toBeNull();
});
});