(state: {
revoked: Set<string>;
/** Reject every token, even a freshly minted one — a dead grant. */
rejectEverything?: boolean;
calls: string[];
})
| 1532 | * token works") is what lets a test assert that the RETRY succeeded — the |
| 1533 | * re-minted token is simply one the upstream never revoked. */ |
| 1534 | const makeRejectingPlugin = (state: { |
| 1535 | revoked: Set<string>; |
| 1536 | /** Reject every token, even a freshly minted one — a dead grant. */ |
| 1537 | rejectEverything?: boolean; |
| 1538 | calls: string[]; |
| 1539 | }) => |
| 1540 | definePlugin(() => ({ |
| 1541 | id: "acme" as const, |
| 1542 | storage: () => ({}), |
| 1543 | resolveTools: () => |
| 1544 | Effect.succeed({ tools: [{ name: ToolName.make("whoami"), description: "whoami" }] }), |
| 1545 | describeAuthMethods: () => [ |
| 1546 | { |
| 1547 | id: "oauth", |
| 1548 | label: "OAuth2", |
| 1549 | kind: "oauth" as const, |
| 1550 | template: String(TEMPLATE), |
| 1551 | oauth: { scopes: [] }, |
| 1552 | }, |
| 1553 | ], |
| 1554 | invokeTool: ({ credential }) => { |
| 1555 | const token = credential.value; |
| 1556 | state.calls.push(String(token)); |
| 1557 | if (token !== null && !state.rejectEverything && !state.revoked.has(token)) { |
| 1558 | return Effect.succeed(ToolResult.ok({ token })); |
| 1559 | } |
| 1560 | return Effect.succeed( |
| 1561 | authToolFailure({ |
| 1562 | code: "connection_rejected", |
| 1563 | status: 401, |
| 1564 | message: "Upstream rejected credentials with HTTP 401.", |
| 1565 | integration: { id: String(credential.integration) }, |
| 1566 | credential: { kind: "upstream", label: String(credential.connection) }, |
| 1567 | }), |
| 1568 | ); |
| 1569 | }, |
| 1570 | extension: (ctx) => ({ |
| 1571 | seed: () => ctx.core.integrations.register({ slug: INTEG, description: "Acme", config: {} }), |
| 1572 | }), |
| 1573 | }))(); |
| 1574 | |
| 1575 | /** Mint a connection against `server` and return the harness + call log. */ |
| 1576 | const connectRejecting = (options?: { readonly tokenExpiresInSeconds?: number }) => |
no test coverage detected