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

Function connectRejecting

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

Source from the content-addressed store, hash-verified

1391
1392/** Mint a connection against `server` and return the harness + call log. */
1393const connectRejecting = (options?: { readonly tokenExpiresInSeconds?: number }) =>
1394 Effect.gen(function* () {
1395 const server = yield* serveOAuthTestServer({
1396 scopes: ["read"],
1397 ...(options?.tokenExpiresInSeconds !== undefined
1398 ? { tokenExpiresInSeconds: options.tokenExpiresInSeconds }
1399 : {}),
1400 });
1401 const state = {
1402 revoked: new Set<string>(),
1403 rejectEverything: false,
1404 calls: [] as string[],
1405 };
1406 const issuedLatest = Effect.gen(function* () {
1407 const issued = yield* server.issuedAccessTokens;
1408 return issued.length > 0 ? issued[issued.length - 1]! : null;
1409 });
1410 const harness = yield* makeTestWorkspaceHarness({
1411 plugins: [memoryCredentialsPlugin(), makeRejectingPlugin(state)] as const,
1412 });
1413 const { executor, config } = harness;
1414 yield* executor.acme.seed();
1415 yield* executor.oauth.createClient({
1416 owner: "org",
1417 slug: CLIENT,
1418 authorizationUrl: server.authorizationEndpoint,
1419 tokenUrl: server.tokenEndpoint,
1420 grant: "authorization_code",
1421 clientId: "test-client",
1422 clientSecret: "test-secret",
1423 });
1424 const started = yield* executor.oauth.start({
1425 owner: "org",
1426 client: CLIENT,
1427 clientOwner: "org",
1428 name: ConnectionName.make("mine"),
1429 integration: INTEG,
1430 template: TEMPLATE,
1431 });
1432 if (started.status !== "redirect") {
1433 return yield* Effect.die("expected a redirect-status OAuth start");
1434 }
1435 const callback = yield* server.completeAuthorizationCodeFlow({
1436 authorizationUrl: started.authorizationUrl,
1437 });
1438 yield* executor.oauth.complete({ state: started.state, code: callback.code });
1439 return { server, state, executor, config, issuedLatest };
1440 });
1441
1442const ADDRESS = ToolAddress.make("tools.acme.org.mine.whoami");
1443

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