History

fix tests

Rhys Sullivan committed 7 months ago

Commit bbd71fa1 parent 644615b6 files · +42 −25Browse files

Unified · Split

6 files
  1. packages/dev/kitchen-sink/src/source-runtime.test.ts +31 −20
  2. packages/drivers/catalog-builders/package.json +1 −1
  3. packages/drivers/openapi/src/openapi-real-spec-coverage.test.ts +1 −1
  4. packages/drivers/openapi/src/openapi-tool-presentation.test.ts +1 −1
  5. packages/platform/control-plane/src/runtime/execution/ir-execution.ts +7 −1
  6. packages/platform/control-plane/src/runtime/sources/source-adapter-fixture-matrix.test.ts +1 −1
packages/dev/kitchen-sink/src/source-runtime.test.ts+31−20
@@ -283,27 +283,38 @@ const resolveSourceCallContext = (input: { · 282 unmodified lines
283283 secretRegistry: SecretMaterialRegistry;
284284 }) =>
285285 async (source: Source): Promise<SourceCallContext> => {
286− if (source.auth.kind === "none") {
287− return { auth: { kind: "none" } };
288− }
289−
290− if (source.auth.kind === "oauth2_authorized_user") {
291− throw new Error("oauth2_authorized_user auth requires persistence-backed runtime resolution");
286+ switch (source.auth.kind) {
287+ case "none":
288+ return { auth: { kind: "none" } };
289+ case "bearer": {
290+ const token = await input.secretRegistry.get({ ref: source.auth.token });
291+ return {
292+ auth: {
293+ kind: "headers",
294+ headers: {
295+ [source.auth.headerName]: `${source.auth.prefix}${token}`,
296+ },
297+ },
298+ };
299+ }
300+ case "oauth2": {
301+ const token = await input.secretRegistry.get({ ref: source.auth.accessToken });
302+ return {
303+ auth: {
304+ kind: "headers",
305+ headers: {
306+ [source.auth.headerName]: `${source.auth.prefix}${token}`,
307+ },
308+ },
309+ };
310+ }
311+ case "oauth2_authorized_user":
312+ throw new Error("oauth2_authorized_user auth requires persistence-backed runtime resolution");
313+ case "provider_grant_ref":
314+ throw new Error("provider_grant_ref auth requires persistence-backed runtime resolution");
315+ case "mcp_oauth":
316+ throw new Error("mcp_oauth auth requires persistence-backed runtime resolution");
292317 }
293−
294− const tokenRef = source.auth.kind === "bearer"
295− ? source.auth.token
296− : source.auth.accessToken;
297− const token = await input.secretRegistry.get({ ref: tokenRef });
298−
299− return {
300− auth: {
301− kind: "headers",
302− headers: {
303− [source.auth.headerName]: `${source.auth.prefix}${token}`,
304− },
305− },
306− };
307318 };
308319
309320 const createProviderInvoker = (): ProviderInvoker => ({
packages/drivers/catalog-builders/package.json+1−1
@@ -8,7 +8,7 @@ · 7 unmodified lines
88 },
99 "scripts": {
1010 "typecheck": "bunx tsc --noEmit -p tsconfig.json",
11− "test": "vitest run",
11+ "test": "vitest run --passWithNoTests",
1212 "test:watch": "vitest"
1313 },
1414 "dependencies": {
packages/drivers/openapi/src/openapi-real-spec-coverage.test.ts+1−1
@@ -15,7 +15,7 @@ import type { · 14 unmodified lines
1515
1616 const readFixture = (name: string): string =>
1717 readFileSync(
18− new URL(`../../control-plane/src/runtime/fixtures/${name}`, import.meta.url),
18+ new URL(`../../../platform/control-plane/src/runtime/fixtures/${name}`, import.meta.url),
1919 "utf8",
2020 );
2121
packages/drivers/openapi/src/openapi-tool-presentation.test.ts+1−1
@@ -10,7 +10,7 @@ import { buildOpenApiToolPresentation } from "./openapi-tool-presentation"; · 9 unmodified lines
1010
1111 const readFixture = (name: string): string =>
1212 readFileSync(
13− new URL(`../../control-plane/src/runtime/fixtures/${name}`, import.meta.url),
13+ new URL(`../../../platform/control-plane/src/runtime/fixtures/${name}`, import.meta.url),
1414 "utf8",
1515 );
1616
packages/platform/control-plane/src/runtime/execution/ir-execution.ts+7−1
@@ -396,10 +396,16 @@ const planHttpInvocation = (input: { · 395 unmodified lines
396396 const executeHttpPlan = (requestPlan: HttpInvocationRequestPlan) =>
397397 Effect.tryPromise({
398398 try: async () => {
399+ const body =
400+ requestPlan.body === undefined
401+ ? undefined
402+ : typeof requestPlan.body === "string"
403+ ? requestPlan.body
404+ : new Uint8Array(requestPlan.body).buffer;
399405 const response = await fetch(requestPlan.url, {
400406 method: requestPlan.method,
401407 headers: requestPlan.headers,
402− ...(requestPlan.body !== undefined ? { body: requestPlan.body } : {}),
408+ ...(body !== undefined ? { body } : {}),
403409 });
404410 const responseBody = await decodeFetchBody(response);
405411 return executionEnvelope({
packages/platform/control-plane/src/runtime/sources/source-adapter-fixture-matrix.test.ts+1−1
@@ -57,7 +57,7 @@ import { · 56 unmodified lines
5757 const FIXTURE_WORKSPACE_ID = WorkspaceIdSchema.make("ws_source_fixture_matrix");
5858
5959 const readFixture = (name: string): string =>
60− readFileSync(new URL(`./fixtures/${name}`, import.meta.url), "utf8");
60+ readFileSync(new URL(`../fixtures/${name}`, import.meta.url), "utf8");
6161
6262 const makeSource = (input: {
6363 id: string;