(options?: { readonly tokenExpiresInSeconds?: number })
| 2406 | |
| 2407 | /** Mint a connection against `server` and return the harness + call log. */ |
| 2408 | const 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 | |
| 2457 | const ADDRESS = ToolAddress.make("tools.acme.org.mine.whoami"); |
| 2458 |
no test coverage detected