History

update tests for decoupled OAuth, GraphQL sources, and workspace execution

Adapt the server integration test to the new standalone OAuth endpoints that store secrets without creating a source. Add workspace execution environment tests for GraphQL tool loading and invocation. Update auth service and control-plane runtime tests for the refactored APIs.

Rhys Sullivan committed 8 months ago

Commit 4cb06d01 parent 956c74b5 files · +801 −26Browse files

Showing the changes to apps (1 of 5 files). Show all

Unified · Split

apps/executor/src/server/server.test.ts+15−19
@@ -802,7 +802,7 @@ describe("local-executor-server", () => { · 801 unmodified lines
802802 }),
803803 );
804804
805− it.scoped("starts MCP OAuth from the sources API and completes the popup callback flow", () =>
805+ it.scoped("starts source OAuth without creating a source and stores secrets on callback", () =>
806806 Effect.gen(function* () {
807807 const oauthServer = yield* Effect.acquireRelease(
808808 Effect.promise(() => startOAuthProtectedMcpServer()),
@@ -820,16 +820,15 @@ describe("local-executor-server", () => { · 11 unmodified lines
820820 const installation = yield* bootstrapClient.local.installation({});
821821
822822 const startResponse = yield* Effect.promise(() =>
823− fetch(`${server.baseUrl}/v1/workspaces/${encodeURIComponent(installation.workspaceId)}/sources/mcp/oauth/start`, {
823+ fetch(`${server.baseUrl}/v1/workspaces/${encodeURIComponent(installation.workspaceId)}/oauth/source-auth/start`, {
824824 method: "POST",
825825 headers: {
826826 "content-type": "application/json",
827827 "x-executor-account-id": installation.accountId,
828828 },
829829 body: JSON.stringify({
830+ provider: "mcp",
830831 endpoint: oauthServer.endpoint,
831− name: "Axiom",
832− namespace: "axiom",
833832 transport: "auto",
834833 }),
835834 }),
@@ -837,29 +836,26 @@ describe("local-executor-server", () => { · 1 unmodified line
837836
838837 assertTrue(startResponse.ok);
839838 const started: {
840− kind: "connected" | "oauth_required";
841− source: { id: string; status: string; auth: { kind: string } };
842− authorizationUrl?: string;
839+ sessionId: string;
840+ authorizationUrl: string;
843841 } = yield* Effect.promise(() => startResponse.json() as Promise<{
844− kind: "connected" | "oauth_required";
845− source: { id: string; status: string; auth: { kind: string } };
846− authorizationUrl?: string;
842+ sessionId: string;
843+ authorizationUrl: string;
847844 }>);
848845
849− expect(started.kind).toBe("oauth_required");
850− expect(started.source.status).toBe("auth_required");
846+ expect(started.sessionId).toBeTruthy();
851847 expect(started.authorizationUrl).toBeDefined();
852848
853849 const callbackResponse = yield* Effect.promise(() =>
854− fetch(started.authorizationUrl!, {
850+ fetch(started.authorizationUrl, {
855851 redirect: "follow",
856852 }),
857853 );
858854
859855 assertTrue(callbackResponse.ok);
860856 const callbackHtml = yield* Effect.promise(() => callbackResponse.text());
861− expect(callbackHtml).toContain("Source connected:");
862− expect(callbackHtml).toContain("executor-v3:source-oauth-result");
857+ expect(callbackHtml).toContain("OAuth connected");
858+ expect(callbackHtml).toContain("executor-v3:oauth-result");
863859
864860 const client = yield* createControlPlaneClient({
865861 baseUrl: server.baseUrl,
@@ -870,12 +866,12 @@ describe("local-executor-server", () => { · 4 unmodified lines
870866 workspaceId: installation.workspaceId,
871867 },
872868 });
873− const source = sources.find((candidate) => candidate.id === started.source.id);
874869
875− assertTrue(Boolean(source));
870+ expect(sources).toHaveLength(0);
876871
877− expect(source?.status).toBe("connected");
878− expect(source?.auth.kind).toBe("oauth2");
872+ const secrets = yield* bootstrapClient.local.listSecrets({});
873+ expect(secrets.some((secret) => secret.purpose === "oauth_access_token")).toBe(true);
874+ expect(secrets.some((secret) => secret.purpose === "oauth_refresh_token")).toBe(true);
879875 }),
880876 );
881877

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t