(state: {
revoked: Set<string>;
/** Reject every token, even a freshly minted one — a dead grant. */
rejectEverything?: boolean;
calls: string[];
})
| 1349 | * token works") is what lets a test assert that the RETRY succeeded — the |
| 1350 | * re-minted token is simply one the upstream never revoked. */ |
| 1351 | const makeRejectingPlugin = (state: { |
| 1352 | revoked: Set<string>; |
| 1353 | /** Reject every token, even a freshly minted one — a dead grant. */ |
| 1354 | rejectEverything?: boolean; |
| 1355 | calls: string[]; |
| 1356 | }) => |
| 1357 | definePlugin(() => ({ |
| 1358 | id: "acme" as const, |
| 1359 | storage: () => ({}), |
| 1360 | resolveTools: () => |
| 1361 | Effect.succeed({ tools: [{ name: ToolName.make("whoami"), description: "whoami" }] }), |
| 1362 | describeAuthMethods: () => [ |
| 1363 | { |
| 1364 | id: "oauth", |
| 1365 | label: "OAuth2", |
| 1366 | kind: "oauth" as const, |
| 1367 | template: String(TEMPLATE), |
| 1368 | oauth: { scopes: [] }, |
| 1369 | }, |
| 1370 | ], |
| 1371 | invokeTool: ({ credential }) => { |
| 1372 | const token = credential.value; |
| 1373 | state.calls.push(String(token)); |
| 1374 | if (token !== null && !state.rejectEverything && !state.revoked.has(token)) { |
| 1375 | return Effect.succeed(ToolResult.ok({ token })); |
| 1376 | } |
| 1377 | return Effect.succeed( |
| 1378 | authToolFailure({ |
| 1379 | code: "connection_rejected", |
| 1380 | status: 401, |
| 1381 | message: "Upstream rejected credentials with HTTP 401.", |
| 1382 | integration: { id: String(credential.integration) }, |
| 1383 | credential: { kind: "upstream", label: String(credential.connection) }, |
| 1384 | }), |
| 1385 | ); |
| 1386 | }, |
| 1387 | extension: (ctx) => ({ |
| 1388 | seed: () => ctx.core.integrations.register({ slug: INTEG, description: "Acme", config: {} }), |
| 1389 | }), |
| 1390 | }))(); |
| 1391 | |
| 1392 | /** Mint a connection against `server` and return the harness + call log. */ |
| 1393 | const connectRejecting = (options?: { readonly tokenExpiresInSeconds?: number }) => |
no test coverage detected