Skip to content

Commit 49ed343

Browse files
committed
Document that a stored empty oauth2 scope list fails config decode
scopes is a NonEmptyArray, so a hand-written `scopes: []` row does not degrade to a scope-less oauth method — it makes the whole integration config undecodable, and the integration then offers no auth method at all. The editor codec already omits the key for an empty list; these tests pin that constraint so it is visible at the place that must respect it.
1 parent f67a9a3 commit 49ed343

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

packages/plugins/mcp/src/react/auth-method-config.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, expect, it } from "@effect/vitest";
22
import type { AuthTemplateEditorValue } from "@executor-js/react/components/auth-template-editor";
33

4+
import { parseMcpIntegrationConfig } from "../sdk/types";
45
import {
56
authMethodsFromConfig,
67
editorValueFromMcpAuthMethod,
@@ -86,6 +87,35 @@ describe("mcpAuthMethodInputFromEditorValue", () => {
8687
});
8788
});
8889

90+
describe("a stored oauth2 row's scope list", () => {
91+
const storedConfig = (method: Record<string, unknown>) => ({
92+
transport: "remote",
93+
endpoint: "https://mcp.example.com/mcp",
94+
authenticationTemplate: [method],
95+
});
96+
97+
it("decodes whether the key is declared or absent", () => {
98+
expect(
99+
parseMcpIntegrationConfig(storedConfig({ slug: "oauth2", kind: "oauth2" })),
100+
).not.toBeNull();
101+
expect(
102+
parseMcpIntegrationConfig(storedConfig({ slug: "oauth2", kind: "oauth2", scopes: ["mcp"] })),
103+
).not.toBeNull();
104+
});
105+
106+
it("fails the WHOLE config when the row stores an empty list", () => {
107+
// `scopes` is a NonEmptyArray, so `[]` is not "declares no scopes" — it is
108+
// an invalid row. Decoding is all-or-nothing: one such row does not
109+
// degrade to a scope-less oauth method, it makes the entire integration
110+
// config undecodable, and the integration then presents no auth method at
111+
// all. That is the whole reason the editor codec omits the key rather than
112+
// writing `[]`; this test is here so the constraint is not invisible.
113+
expect(
114+
parseMcpIntegrationConfig(storedConfig({ slug: "oauth2", kind: "oauth2", scopes: [] })),
115+
).toBeNull();
116+
});
117+
});
118+
89119
describe("editorValueFromMcpAuthMethod", () => {
90120
it("round-trips an apikey method, making the shared token variable explicit", () => {
91121
expect(

0 commit comments

Comments
 (0)