Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
[CHOO-3906] Cover the organization members routes end to end
Petr Bauchbb67e63f06c9
diff --git a/console/tooling-e2e/src/clients/switch-client.ts b/console/tooling-e2e/src/clients/switch-client.tsindex 7e30d3250..e7ac76e22 100644--- a/console/tooling-e2e/src/clients/switch-client.ts+++ b/console/tooling-e2e/src/clients/switch-client.ts@@ -814,6 +814,26 @@ export class SwitchClient {}));}+ /** `GET /gateway/organizations/current/members` — the organization of the bound workspace, `org_admin` only. */+ async organizationMembers(): Promise<{ user_id: string; role: string }[]> {+ return this.gateway<{ user_id: string; role: string }[]>(+ "GET",+ "/organizations/current/members",+ );+ }++ /** `PATCH /gateway/organizations/current/members/{user_id}` — grant or take back `org_admin`. */+ async setOrganizationRole(+ userId: string,+ role: "org_admin" | "member",+ ): Promise<{ user_id: string; role: string }> {+ return this.gateway<{ user_id: string; role: string }>(+ "PATCH",+ `/organizations/current/members/${encodeURIComponent(userId)}`,+ { role },+ );+ }+/** `GET /gateway/auth/session` — the workspace this admin session is bound to. */async tenantId(): Promise<string> {const state = await this.gateway<{diff --git a/console/tooling-e2e/src/fast/index.ts b/console/tooling-e2e/src/fast/index.tsindex acab1dd96..0db013a10 100644--- a/console/tooling-e2e/src/fast/index.ts+++ b/console/tooling-e2e/src/fast/index.ts@@ -5,6 +5,7 @@ import { followUps } from "./follow-ups.ts";import { addressedDelivery, unaddressedHistory } from "./agent-messaging.ts";import { mattermostRoundtrip } from "./mattermost-roundtrip.ts";import { operationsFrontDoor } from "./operations.ts";+import { organizationMembers } from "./organization-members.ts";import { roomCapture } from "./room-capture.ts";import { roomGroupPaths } from "./room-groups.ts";import type { FastScenario } from "./scenario.ts";@@ -21,4 +22,5 @@ export const FAST_SCENARIOS: readonly FastScenario[] = [clientMistakes,roomCapture,followUps,+ organizationMembers,];diff --git a/console/tooling-e2e/src/fast/organization-members.ts b/console/tooling-e2e/src/fast/organization-members.tsnew file mode 100644index 000000000..68eda1dab--- /dev/null+++ b/console/tooling-e2e/src/fast/organization-members.ts@@ -0,0 +1,69 @@+import { expect } from 'vitest';+import { SwitchHttpError, errorDetail } from '../clients/switch-client.ts';+import type { FastScenario } from './scenario.ts';++/**+ * An organization's admins manage who else is one: the harness admin, the+ * default workspace's organization admin, lists its members, makes a+ * colleague organization admin, and takes it back. The colleague can list+ * the members only while they hold the role.+ *+ * Users cannot be deleted, so this runs only on a stack thrown away after+ * the run.+ */+export const organizationMembers: FastScenario = {+ header: {+ id: 'organization-members',+ covers: [+ 'GET /gateway/organizations/current/members',+ 'PATCH /gateway/organizations/current/members/{user_id}',+ ],+ lane: 'fast',+ environments: ['ephemeral'],+ owner: 'platform',+ requires: [],+ },+ async run({ names, switchClient }) {+ const password = `e2e-${names.runId}-${crypto.randomUUID()}`;+ const email = `${names.name('colleague')}@e2e.invalid`;+ const { id } = await switchClient.createUser({+ name: 'E2E colleague',+ email,+ password,+ role: 'user',+ });+ const colleague = switchClient.as(email, password);+ // Signing in joins the default workspace, and so its organization.+ await colleague.tenantId();++ const refused = async (): Promise<number> => {+ try {+ await colleague.organizationMembers();+ } catch (error) {+ if (error instanceof SwitchHttpError) return error.status;+ throw error;+ }+ return 200;+ };++ const before = await switchClient.organizationMembers();+ expect(before.find((row) => row.user_id === id)?.role, 'a new member').toBe('member');+ expect(await refused(), 'a member listing the organization').toBe(403);++ const granted = await switchClient.setOrganizationRole(id, 'org_admin');+ expect(granted.role).toBe('org_admin');+ expect(await refused(), 'an organization admin listing the organization').toBe(200);++ const taken = await switchClient.setOrganizationRole(id, 'member');+ expect(taken.role).toBe('member');+ expect(await refused(), 'a member again').toBe(403);++ try {+ await switchClient.setOrganizationRole(id, 'owner' as 'member');+ throw new Error('an unknown organization role was accepted');+ } catch (error) {+ if (!(error instanceof SwitchHttpError)) throw error;+ expect(error.status, errorDetail(error.body)).toBe(422);+ }+ },+};diff --git a/console/tooling-e2e/surface/server-surface.json b/console/tooling-e2e/surface/server-surface.jsonindex 71677bf8d..5d37b1b35 100644--- a/console/tooling-e2e/surface/server-surface.json+++ b/console/tooling-e2e/surface/server-surface.json@@ -581,6 +581,11 @@"auth": "none","flags": []},+ {+ "route": "GET /gateway/organizations/current/members",+ "auth": "session",+ "flags": []+ },{"route": "GET /gateway/packages","auth": "session",@@ -867,6 +872,11 @@"agent_management"]},+ {+ "route": "PATCH /gateway/organizations/current/members/{user_id}",+ "auth": "session",+ "flags": []+ },{"route": "PATCH /gateway/packages/{package_id}","auth": "session",