(state: {
revoked: Set<string>;
/** Reject every token, even a freshly minted one — a dead grant. */
rejectEverything?: boolean;
calls: string[];
})
| 2108 | * token works") is what lets a test assert that the RETRY succeeded — the |
| 2109 | * re-minted token is simply one the upstream never revoked. */ |
| 2110 | const makeRejectingPlugin = (state: { |
| 2111 | revoked: Set<string>; |
| 2112 | /** Reject every token, even a freshly minted one — a dead grant. */ |
| 2113 | rejectEverything?: boolean; |
| 2114 | calls: string[]; |
| 2115 | }) => |
| 2116 | definePlugin(() => ({ |
| 2117 | id: "acme" as const, |
| 2118 | storage: () => ({}), |
| 2119 | resolveTools: () => |
| 2120 | Effect.succeed({ tools: [{ name: ToolName.make("whoami"), description: "whoami" }] }), |
| 2121 | describeAuthMethods: () => [ |
| 2122 | { |
| 2123 | id: "oauth", |
| 2124 | label: "OAuth2", |
| 2125 | kind: "oauth" as const, |
| 2126 | template: String(TEMPLATE), |
| 2127 | oauth: { scopes: [] }, |
| 2128 | }, |
| 2129 | ], |
| 2130 | invokeTool: ({ credential }) => { |
| 2131 | const token = credential.value; |
| 2132 | state.calls.push(String(token)); |
| 2133 | if (token !== null && !state.rejectEverything && !state.revoked.has(token)) { |
| 2134 | return Effect.succeed(ToolResult.ok({ token })); |
| 2135 | } |
| 2136 | return Effect.succeed( |
| 2137 | authToolFailure({ |
| 2138 | code: "connection_rejected", |
| 2139 | status: 401, |
| 2140 | message: "Upstream rejected credentials with HTTP 401.", |
| 2141 | integration: { id: String(credential.integration) }, |
| 2142 | credential: { kind: "upstream", label: String(credential.connection) }, |
| 2143 | }), |
| 2144 | ); |
| 2145 | }, |
| 2146 | extension: (ctx) => ({ |
| 2147 | seed: () => ctx.core.integrations.register({ slug: INTEG, description: "Acme", config: {} }), |
| 2148 | }), |
| 2149 | }))(); |
| 2150 | |
| 2151 | /** Mint a connection against `server` and return the harness + call log. */ |
| 2152 | const connectRejecting = (options?: { readonly tokenExpiresInSeconds?: number }) => |
no test coverage detected