Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Count team members as members of their team scope (#2215)

Joshua Francea6b00474779e
diff --git a/src/api/app-helpers.ts b/src/api/app-helpers.ts
index 0cadd7ad3..b0f41f057 100644
--- a/src/api/app-helpers.ts
+++ b/src/api/app-helpers.ts
@@ -415,6 +415,7 @@ export function createAppHelpers(deps: AppDeps, app: App) {
...(deps.projects ? { managedGroups: deps.projects } : {}),
...(deps.directory ? { directory: deps.directory } : {}),
...(deps.identity ? { identity: deps.identity } : {}),
+ ...(deps.teams ? { teams: deps.teams } : {}),
};
const principalCanReadScope = createCanReadScope(scopeMembershipDeps);
diff --git a/test/scope-resources-authz.test.ts b/test/scope-resources-authz.test.ts
index 6b62e7777..d94fcbd7d 100644
--- a/test/scope-resources-authz.test.ts
+++ b/test/scope-resources-authz.test.ts
@@ -302,3 +302,13 @@ test("webhook secrets are redacted by the route, not the app layer", async () =>
const out = await app.listScopeResources(U1, channelScope);
assert.equal(out!.webhooks[0]!.verification.secret, "topsecret");
});
+
+test("team members belong to their team scope", async () => {
+ const deps = makeDeps();
+ const teams = { isMember: async (principalId: string, teamId: string) => principalId === U1 && teamId === "labs" };
+ const app = createApp({ ...deps, teams } as unknown as AppDeps);
+
+ assert.equal(await app.belongsToScope(U1, scopeId("team", "labs")), true);
+ assert.equal(await app.belongsToScope("U2", scopeId("team", "labs")), false);
+ assert.equal(await app.belongsToScope(U1, scopeId("team", "other")), false);
+});