(r: RunningServer)
| 69 | } |
| 70 | |
| 71 | function appOf(r: RunningServer): { |
| 72 | inject: (req: unknown) => Promise<{ statusCode: number; json: () => unknown }>; |
| 73 | } { |
| 74 | const app = r.services.invokeFunction((a) => { |
| 75 | const gw = a.get(IRestGateway); |
| 76 | return gw.app as unknown as { |
| 77 | inject: (req: unknown) => Promise<{ statusCode: number; json: () => unknown }>; |
| 78 | }; |
| 79 | }); |
| 80 | // Auto-attach the fixed bearer token so the M5.1 auth hook passes. A |
| 81 | // caller-supplied `authorization` header wins, so explicit token tests keep |
| 82 | // working; every other header (Range, content-type, …) is preserved. |
| 83 | return { |
| 84 | inject(req: unknown) { |
| 85 | const q = req as { headers?: Record<string, string | string[] | undefined> }; |
| 86 | return app.inject({ |
| 87 | ...q, |
| 88 | headers: { authorization: 'Bearer test-token', ...q.headers }, |
| 89 | }); |
| 90 | }, |
| 91 | }; |
| 92 | } |
| 93 | |
| 94 | function envelopeOf<T>(body: unknown): { |
| 95 | code: number; |
no test coverage detected