(initialKeys: ReadonlyArray<JWK>)
| 44 | } |
| 45 | |
| 46 | const 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 | |
| 68 | describe("createCachedRemoteJWKSet", () => { |
| 69 | it("FAILING-WITHOUT-CACHE: N verifications hit JWKS endpoint only once within TTL", async () => { |
no outgoing calls
no test coverage detected