MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / connectRejecting

Function connectRejecting

packages/core/sdk/src/oauth-flow.test.ts:2408–2455  ·  view source on GitHub ↗
(options?: { readonly tokenExpiresInSeconds?: number })

Source from the content-addressed store, hash-verified

2406
2407/** Mint a connection against `server` and return the harness + call log. */
2408const connectRejecting = (options?: { readonly tokenExpiresInSeconds?: number }) =>
2409 Effect.gen(function* () {
2410 const server = yield* serveOAuthTestServer({
2411 scopes: ["read"],
2412 ...(options?.tokenExpiresInSeconds !== undefined
2413 ? { tokenExpiresInSeconds: options.tokenExpiresInSeconds }
2414 : {}),
2415 });
2416 const state = {
2417 revoked: new Set<string>(),
2418 rejectEverything: false,
2419 calls: [] as string[],
2420 };
2421 const issuedLatest = Effect.gen(function* () {
2422 const issued = yield* server.issuedAccessTokens;
2423 return issued.length > 0 ? issued[issued.length - 1]! : null;
2424 });
2425 const harness = yield* makeTestWorkspaceHarness({
2426 plugins: [memoryCredentialsPlugin(), makeRejectingPlugin(state)] as const,
2427 });
2428 const { executor, config } = harness;
2429 yield* executor.acme.seed();
2430 yield* executor.oauth.createClient({
2431 owner: "org",
2432 slug: CLIENT,
2433 authorizationUrl: server.authorizationEndpoint,
2434 tokenUrl: server.tokenEndpoint,
2435 grant: "authorization_code",
2436 clientId: "test-client",
2437 clientSecret: "test-secret",
2438 });
2439 const started = yield* executor.oauth.start({
2440 owner: "org",
2441 client: CLIENT,
2442 clientOwner: "org",
2443 name: ConnectionName.make("mine"),
2444 integration: INTEG,
2445 template: TEMPLATE,
2446 });
2447 if (started.status !== "redirect") {
2448 return yield* Effect.die("expected a redirect-status OAuth start");
2449 }
2450 const callback = yield* server.completeAuthorizationCodeFlow({
2451 authorizationUrl: started.authorizationUrl,
2452 });
2453 yield* executor.oauth.complete({ state: started.state, code: callback.code });
2454 return { server, state, executor, config, issuedLatest };
2455 });
2456
2457const ADDRESS = ToolAddress.make("tools.acme.org.mine.whoami");
2458

Callers 1

oauth-flow.test.tsFile · 0.85

Calls 5

serveOAuthTestServerFunction · 0.90
makeTestWorkspaceHarnessFunction · 0.90
makeRejectingPluginFunction · 0.85
completeMethod · 0.80
startMethod · 0.65

Tested by

no test coverage detected