From 8f6fcc3c2e73f2f77a42e22c4251e9242c8bd1eb Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 7 Oct 2026 19:15:45 -0400 Subject: [PATCH] chore: Rename syncGroups policy to externalGroupSync --- app/scenes/Settings/Authentication.tsx | 2 +- server/policies/team.ts | 2 +- server/queues/tasks/SyncUserGroupsTask.test.ts | 17 ----------------- .../authenticationProviders.ts | 4 ++-- 4 files changed, 4 insertions(+), 21 deletions(-) diff --git a/app/scenes/Settings/Authentication.tsx b/app/scenes/Settings/Authentication.tsx index 2697ce9551..19ecec4fdc 100644 --- a/app/scenes/Settings/Authentication.tsx +++ b/app/scenes/Settings/Authentication.tsx @@ -200,7 +200,7 @@ function Authentication() { const showGroupSync = provider.isActive && provider.groupSyncSupported && - (!!can.syncGroups || !!provider.settings?.groupSyncEnabled); + (!!can.externalGroupSync || !!provider.settings?.groupSyncEnabled); return ( diff --git a/server/policies/team.ts b/server/policies/team.ts index ac9cc565e9..bbd3efed99 100644 --- a/server/policies/team.ts +++ b/server/policies/team.ts @@ -59,7 +59,7 @@ allow(User, "audit", Team, (actor, team) => ) ); -allow(User, "syncGroups", Team, (actor, team) => +allow(User, "externalGroupSync", Team, (actor, team) => and( // isTeamAdmin(actor, team), diff --git a/server/queues/tasks/SyncUserGroupsTask.test.ts b/server/queues/tasks/SyncUserGroupsTask.test.ts index 3af1f29af2..cd86121a69 100644 --- a/server/queues/tasks/SyncUserGroupsTask.test.ts +++ b/server/queues/tasks/SyncUserGroupsTask.test.ts @@ -1,10 +1,8 @@ import { vi } from "vitest"; -import { Plan } from "@shared/types"; import { AuthenticationProvider, Group, GroupUser, - Team, UserAuthentication, } from "@server/models"; import { buildUser } from "@server/test/factories"; @@ -40,10 +38,6 @@ async function setup() { describe("SyncUserGroupsTask", () => { const schedule = mockTaskSchedule(); - beforeEach(() => { - vi.spyOn(Team.prototype, "plan", "get").mockReturnValue(Plan.Business); - }); - afterEach(() => { vi.restoreAllMocks(); }); @@ -110,17 +104,6 @@ describe("SyncUserGroupsTask", () => { expect(fetchUserGroups).not.toHaveBeenCalled(); }); - it("should not sync groups when the team is not entitled to group sync", async () => { - const { authentication, fetchUserGroups } = await setup(); - vi.spyOn(Team.prototype, "plan", "get").mockReturnValue(Plan.Community); - - await new SyncUserGroupsTask().perform({ - userAuthenticationId: authentication.id, - }); - - expect(fetchUserGroups).not.toHaveBeenCalled(); - }); - it("should throw when the provider fails so the task is retried", async () => { const { authentication, fetchUserGroups } = await setup(); fetchUserGroups.mockRejectedValue(new Error("provider unavailable")); diff --git a/server/routes/api/authenticationProviders/authenticationProviders.ts b/server/routes/api/authenticationProviders/authenticationProviders.ts index 06ebfdcf45..ff836c9212 100644 --- a/server/routes/api/authenticationProviders/authenticationProviders.ts +++ b/server/routes/api/authenticationProviders/authenticationProviders.ts @@ -57,7 +57,7 @@ router.post( settings?.groupSyncEnabled === true && !authenticationProvider.settings?.groupSyncEnabled ) { - authorize(user, "syncGroups", user.team); + authorize(user, "externalGroupSync", user.team); const groupSyncProvider = PluginManager.getGroupSyncProvider( authenticationProvider.name @@ -108,7 +108,7 @@ router.post( ctx.input.body.id ); authorize(user, "update", authenticationProvider); - authorize(user, "syncGroups", user.team); + authorize(user, "externalGroupSync", user.team); const groupSyncProvider = PluginManager.getGroupSyncProvider( authenticationProvider.name