(options?: { readonly tokenExpiresInSeconds?: number })
| 1574 | |
| 1575 | /** Mint a connection against `server` and return the harness + call log. */ |
| 1576 | const connectRejecting = (options?: { readonly tokenExpiresInSeconds?: number }) => |
| 1577 | Effect.gen(function* () { |
| 1578 | const server = yield* serveOAuthTestServer({ |
| 1579 | scopes: ["read"], |
| 1580 | ...(options?.tokenExpiresInSeconds !== undefined |
| 1581 | ? { tokenExpiresInSeconds: options.tokenExpiresInSeconds } |
| 1582 | : {}), |
| 1583 | }); |
| 1584 | const state = { |
| 1585 | revoked: new Set<string>(), |
| 1586 | rejectEverything: false, |
| 1587 | calls: [] as string[], |
| 1588 | }; |
| 1589 | const issuedLatest = Effect.gen(function* () { |
| 1590 | const issued = yield* server.issuedAccessTokens; |
| 1591 | return issued.length > 0 ? issued[issued.length - 1]! : null; |
| 1592 | }); |
| 1593 | const harness = yield* makeTestWorkspaceHarness({ |
| 1594 | plugins: [memoryCredentialsPlugin(), makeRejectingPlugin(state)] as const, |
| 1595 | }); |
| 1596 | const { executor, config } = harness; |
| 1597 | yield* executor.acme.seed(); |
| 1598 | yield* executor.oauth.createClient({ |
| 1599 | owner: "org", |
| 1600 | slug: CLIENT, |
| 1601 | authorizationUrl: server.authorizationEndpoint, |
| 1602 | tokenUrl: server.tokenEndpoint, |
| 1603 | grant: "authorization_code", |
| 1604 | clientId: "test-client", |
| 1605 | clientSecret: "test-secret", |
| 1606 | }); |
| 1607 | const started = yield* executor.oauth.start({ |
| 1608 | owner: "org", |
| 1609 | client: CLIENT, |
| 1610 | clientOwner: "org", |
| 1611 | name: ConnectionName.make("mine"), |
| 1612 | integration: INTEG, |
| 1613 | template: TEMPLATE, |
| 1614 | }); |
| 1615 | if (started.status !== "redirect") { |
| 1616 | return yield* Effect.die("expected a redirect-status OAuth start"); |
| 1617 | } |
| 1618 | const callback = yield* server.completeAuthorizationCodeFlow({ |
| 1619 | authorizationUrl: started.authorizationUrl, |
| 1620 | }); |
| 1621 | yield* executor.oauth.complete({ state: started.state, code: callback.code }); |
| 1622 | return { server, state, executor, config, issuedLatest }; |
| 1623 | }); |
| 1624 | |
| 1625 | const ADDRESS = ToolAddress.make("tools.acme.org.mine.whoami"); |
| 1626 |
no test coverage detected