MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeFetchHarness

Function makeFetchHarness

apps/cloud/src/auth/jwks-cache.node.test.ts:46–66  ·  view source on GitHub ↗
(initialKeys: ReadonlyArray<JWK>)

Source from the content-addressed store, hash-verified

44}
45
46const makeFetchHarness = (initialKeys: ReadonlyArray<JWK>): FetchHarness => {
47 let keys: ReadonlyArray<JWK> = initialKeys;
48 let calls = 0;
49
50 const fetch: typeof globalThis.fetch = async () => {
51 calls++;
52 const body: JSONWebKeySet = { keys: keys.map((k) => ({ ...k })) };
53 return new Response(JSON.stringify(body), {
54 status: 200,
55 headers: { "content-type": "application/json" },
56 });
57 };
58
59 return {
60 fetch,
61 callCount: () => calls,
62 setKeys: (next) => {
63 keys = next;
64 },
65 };
66};
67
68describe("createCachedRemoteJWKSet", () => {
69 it("FAILING-WITHOUT-CACHE: N verifications hit JWKS endpoint only once within TTL", async () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected