History

fix tests

Rhys Sullivan committed 7 months ago

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

Showing the changes to packages (6 of 6 files). Show all

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
283 secretRegistry: SecretMaterialRegistry;283 secretRegistry: SecretMaterialRegistry;
284}) =>284}) =>
285 async (source: Source): Promise<SourceCallContext> => {285 async (source: Source): Promise<SourceCallContext> => {
286 if (source.auth.kind === "none") {286 switch (source.auth.kind) {
287 return { auth: { kind: "none" } };287 case "none":
288 }288 return { auth: { kind: "none" } };
289 289 case "bearer": {
290 if (source.auth.kind === "oauth2_authorized_user") {290 const token = await input.secretRegistry.get({ ref: source.auth.token });
291 throw new Error("oauth2_authorized_user auth requires persistence-backed runtime resolution");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");
292 }317 }
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 };
307 };318 };
308 319
309const createProviderInvoker = (): ProviderInvoker => ({320const createProviderInvoker = (): ProviderInvoker => ({
packages/drivers/catalog-builders/package.json+1−1
@@ -8,7 +8,7 @@ · 7 unmodified lines
8 },8 },
9 "scripts": {9 "scripts": {
10 "typecheck": "bunx tsc --noEmit -p tsconfig.json",10 "typecheck": "bunx tsc --noEmit -p tsconfig.json",
11 "test": "vitest run",11 "test": "vitest run --passWithNoTests",
12 "test:watch": "vitest"12 "test:watch": "vitest"
13 },13 },
14 "dependencies": {14 "dependencies": {
packages/drivers/openapi/src/openapi-real-spec-coverage.test.ts+1−1
@@ -15,7 +15,7 @@ import type { · 14 unmodified lines
15 15
16const readFixture = (name: string): string =>16const readFixture = (name: string): string =>
17 readFileSync(17 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),
19 "utf8",19 "utf8",
20 );20 );
21 21
packages/drivers/openapi/src/openapi-tool-presentation.test.ts+1−1
@@ -10,7 +10,7 @@ import { buildOpenApiToolPresentation } from "./openapi-tool-presentation"; · 9 unmodified lines
10 10
11const readFixture = (name: string): string =>11const readFixture = (name: string): string =>
12 readFileSync(12 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),
14 "utf8",14 "utf8",
15 );15 );
16 16
packages/platform/control-plane/src/runtime/execution/ir-execution.ts+7−1
@@ -396,10 +396,16 @@ const planHttpInvocation = (input: { · 395 unmodified lines
396const executeHttpPlan = (requestPlan: HttpInvocationRequestPlan) =>396const executeHttpPlan = (requestPlan: HttpInvocationRequestPlan) =>
397 Effect.tryPromise({397 Effect.tryPromise({
398 try: async () => {398 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;
399 const response = await fetch(requestPlan.url, {405 const response = await fetch(requestPlan.url, {
400 method: requestPlan.method,406 method: requestPlan.method,
401 headers: requestPlan.headers,407 headers: requestPlan.headers,
402 ...(requestPlan.body !== undefined ? { body: requestPlan.body } : {}),408 ...(body !== undefined ? { body } : {}),
403 });409 });
404 const responseBody = await decodeFetchBody(response);410 const responseBody = await decodeFetchBody(response);
405 return executionEnvelope({411 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
57const FIXTURE_WORKSPACE_ID = WorkspaceIdSchema.make("ws_source_fixture_matrix");57const FIXTURE_WORKSPACE_ID = WorkspaceIdSchema.make("ws_source_fixture_matrix");
58 58
59const readFixture = (name: string): string =>59const readFixture = (name: string): string =>
60 readFileSync(new URL(`./fixtures/${name}`, import.meta.url), "utf8");60 readFileSync(new URL(`../fixtures/${name}`, import.meta.url), "utf8");
61 61
62const makeSource = (input: {62const makeSource = (input: {
63 id: string;63 id: string;