(state: {
revoked: Set<string>;
/** Reject every token, even a freshly minted one — a dead grant. */
rejectEverything?: boolean;
calls: string[];
})
| 1459 | * token works") is what lets a test assert that the RETRY succeeded — the |
| 1460 | * re-minted token is simply one the upstream never revoked. */ |
| 1461 | const makeRejectingPlugin = (state: { |
| 1462 | revoked: Set<string>; |
| 1463 | /** Reject every token, even a freshly minted one — a dead grant. */ |
| 1464 | rejectEverything?: boolean; |
| 1465 | calls: string[]; |
| 1466 | }) => |
| 1467 | definePlugin(() => ({ |
| 1468 | id: "acme" as const, |
| 1469 | storage: () => ({}), |
| 1470 | resolveTools: () => |
| 1471 | Effect.succeed({ tools: [{ name: ToolName.make("whoami"), description: "whoami" }] }), |
| 1472 | describeAuthMethods: () => [ |
| 1473 | { |
| 1474 | id: "oauth", |
| 1475 | label: "OAuth2", |
| 1476 | kind: "oauth" as const, |
| 1477 | template: String(TEMPLATE), |
| 1478 | oauth: { scopes: [] }, |
| 1479 | }, |
| 1480 | ], |
| 1481 | invokeTool: ({ credential }) => { |
| 1482 | const token = credential.value; |
| 1483 | state.calls.push(String(token)); |
| 1484 | if (token !== null && !state.rejectEverything && !state.revoked.has(token)) { |
| 1485 | return Effect.succeed(ToolResult.ok({ token })); |
| 1486 | } |
| 1487 | return Effect.succeed( |
| 1488 | authToolFailure({ |
| 1489 | code: "connection_rejected", |
| 1490 | status: 401, |
| 1491 | message: "Upstream rejected credentials with HTTP 401.", |
| 1492 | integration: { id: String(credential.integration) }, |
| 1493 | credential: { kind: "upstream", label: String(credential.connection) }, |
| 1494 | }), |
| 1495 | ); |
| 1496 | }, |
| 1497 | extension: (ctx) => ({ |
| 1498 | seed: () => ctx.core.integrations.register({ slug: INTEG, description: "Acme", config: {} }), |
| 1499 | }), |
| 1500 | }))(); |
| 1501 | |
| 1502 | /** Mint a connection against `server` and return the harness + call log. */ |
| 1503 | const connectRejecting = (options?: { readonly tokenExpiresInSeconds?: number }) => |
no test coverage detected