(options?: { readonly tokenExpiresInSeconds?: number })
| 1501 | |
| 1502 | /** Mint a connection against `server` and return the harness + call log. */ |
| 1503 | const connectRejecting = (options?: { readonly tokenExpiresInSeconds?: number }) => |
| 1504 | Effect.gen(function* () { |
| 1505 | const server = yield* serveOAuthTestServer({ |
| 1506 | scopes: ["read"], |
| 1507 | ...(options?.tokenExpiresInSeconds !== undefined |
| 1508 | ? { tokenExpiresInSeconds: options.tokenExpiresInSeconds } |
| 1509 | : {}), |
| 1510 | }); |
| 1511 | const state = { |
| 1512 | revoked: new Set<string>(), |
| 1513 | rejectEverything: false, |
| 1514 | calls: [] as string[], |
| 1515 | }; |
| 1516 | const issuedLatest = Effect.gen(function* () { |
| 1517 | const issued = yield* server.issuedAccessTokens; |
| 1518 | return issued.length > 0 ? issued[issued.length - 1]! : null; |
| 1519 | }); |
| 1520 | const harness = yield* makeTestWorkspaceHarness({ |
| 1521 | plugins: [memoryCredentialsPlugin(), makeRejectingPlugin(state)] as const, |
| 1522 | }); |
| 1523 | const { executor, config } = harness; |
| 1524 | yield* executor.acme.seed(); |
| 1525 | yield* executor.oauth.createClient({ |
| 1526 | owner: "org", |
| 1527 | slug: CLIENT, |
| 1528 | authorizationUrl: server.authorizationEndpoint, |
| 1529 | tokenUrl: server.tokenEndpoint, |
| 1530 | grant: "authorization_code", |
| 1531 | clientId: "test-client", |
| 1532 | clientSecret: "test-secret", |
| 1533 | }); |
| 1534 | const started = yield* executor.oauth.start({ |
| 1535 | owner: "org", |
| 1536 | client: CLIENT, |
| 1537 | clientOwner: "org", |
| 1538 | name: ConnectionName.make("mine"), |
| 1539 | integration: INTEG, |
| 1540 | template: TEMPLATE, |
| 1541 | }); |
| 1542 | if (started.status !== "redirect") { |
| 1543 | return yield* Effect.die("expected a redirect-status OAuth start"); |
| 1544 | } |
| 1545 | const callback = yield* server.completeAuthorizationCodeFlow({ |
| 1546 | authorizationUrl: started.authorizationUrl, |
| 1547 | }); |
| 1548 | yield* executor.oauth.complete({ state: started.state, code: callback.code }); |
| 1549 | return { server, state, executor, config, issuedLatest }; |
| 1550 | }); |
| 1551 | |
| 1552 | const ADDRESS = ToolAddress.make("tools.acme.org.mine.whoami"); |
| 1553 |
no test coverage detected