(options?: { readonly tokenExpiresInSeconds?: number })
| 2534 | |
| 2535 | /** Mint a connection against `server` and return the harness + call log. */ |
| 2536 | const connectRejecting = (options?: { readonly tokenExpiresInSeconds?: number }) => |
| 2537 | Effect.gen(function* () { |
| 2538 | const server = yield* serveOAuthTestServer({ |
| 2539 | scopes: ["read"], |
| 2540 | ...(options?.tokenExpiresInSeconds !== undefined |
| 2541 | ? { tokenExpiresInSeconds: options.tokenExpiresInSeconds } |
| 2542 | : {}), |
| 2543 | }); |
| 2544 | const state = { |
| 2545 | revoked: new Set<string>(), |
| 2546 | rejectEverything: false, |
| 2547 | calls: [] as string[], |
| 2548 | }; |
| 2549 | const issuedLatest = Effect.gen(function* () { |
| 2550 | const issued = yield* server.issuedAccessTokens; |
| 2551 | return issued.length > 0 ? issued[issued.length - 1]! : null; |
| 2552 | }); |
| 2553 | const harness = yield* makeTestWorkspaceHarness({ |
| 2554 | plugins: [memoryCredentialsPlugin(), makeRejectingPlugin(state)] as const, |
| 2555 | }); |
| 2556 | const { executor, config } = harness; |
| 2557 | yield* executor.acme.seed(); |
| 2558 | yield* executor.oauth.createClient({ |
| 2559 | owner: "org", |
| 2560 | slug: CLIENT, |
| 2561 | authorizationUrl: server.authorizationEndpoint, |
| 2562 | tokenUrl: server.tokenEndpoint, |
| 2563 | grant: "authorization_code", |
| 2564 | clientId: "test-client", |
| 2565 | clientSecret: "test-secret", |
| 2566 | }); |
| 2567 | const started = yield* executor.oauth.start({ |
| 2568 | owner: "org", |
| 2569 | client: CLIENT, |
| 2570 | clientOwner: "org", |
| 2571 | name: ConnectionName.make("mine"), |
| 2572 | integration: INTEG, |
| 2573 | template: TEMPLATE, |
| 2574 | }); |
| 2575 | if (started.status !== "redirect") { |
| 2576 | return yield* Effect.die("expected a redirect-status OAuth start"); |
| 2577 | } |
| 2578 | const callback = yield* server.completeAuthorizationCodeFlow({ |
| 2579 | authorizationUrl: started.authorizationUrl, |
| 2580 | }); |
| 2581 | yield* executor.oauth.complete({ state: started.state, code: callback.code }); |
| 2582 | return { server, state, executor, config, issuedLatest }; |
| 2583 | }); |
| 2584 | |
| 2585 | const ADDRESS = ToolAddress.make("tools.acme.org.mine.whoami"); |
| 2586 |
no test coverage detected