(hubUrl)
| 479 | }); |
| 480 | |
| 481 | function freshHubClient(hubUrl) { |
| 482 | // Do NOT clear hubFetch from the cache — its module-level seam |
| 483 | // (`_setFetchImplForTest`) is what these tests rely on. Clearing |
| 484 | // would tear out the stub installed in beforeEach. |
| 485 | const pat = /[\\/]src[\\/](atp[\\/]hubClient|gep[\\/]a2aProtocol|proxy[\\/]server[\\/]settings)\b/; |
| 486 | for (const k of Object.keys(require.cache)) { |
| 487 | if (pat.test(k)) delete require.cache[k]; |
| 488 | } |
| 489 | const a2aPath = require.resolve('../src/gep/a2aProtocol'); |
| 490 | require.cache[a2aPath] = { |
| 491 | id: a2aPath, filename: a2aPath, loaded: true, |
| 492 | exports: { |
| 493 | getNodeId: () => 'node_test', |
| 494 | getHubUrl: () => hubUrl, |
| 495 | buildHubHeaders: () => ({ 'Authorization': 'Bearer SECRET_VALUE' }), |
| 496 | }, |
| 497 | }; |
| 498 | const settingsPath = require.resolve('../src/proxy/server/settings'); |
| 499 | require.cache[settingsPath] = { |
| 500 | id: settingsPath, filename: settingsPath, loaded: true, |
| 501 | exports: { |
| 502 | getProxyUrl: () => null, // force direct hub path, skip _proxyRequest |
| 503 | getProxyToken: () => null, |
| 504 | }, |
| 505 | }; |
| 506 | return require('../src/atp/hubClient'); |
| 507 | } |
| 508 | |
| 509 | it('placeOrder refuses to POST to http:// hub when EVOMAP_HUB_ALLOW_INSECURE unset', async () => { |
| 510 | await withEnv({ |
no outgoing calls
no test coverage detected