(r: RunningServer)
| 51 | } |
| 52 | |
| 53 | function appOf(r: RunningServer): { |
| 54 | inject: (req: unknown) => Promise<{ statusCode: number; json: () => unknown }>; |
| 55 | } { |
| 56 | const app = r.services.invokeFunction((a) => { |
| 57 | const gw = a.get(IRestGateway); |
| 58 | return gw.app as unknown as { |
| 59 | inject: (req: unknown) => Promise<{ statusCode: number; json: () => unknown }>; |
| 60 | }; |
| 61 | }); |
| 62 | // Auto-attach the fixed bearer token so the M5.1 auth hook passes. A |
| 63 | // caller-supplied `authorization` header wins, so explicit token tests keep |
| 64 | // working; every other header (Range, content-type, …) is preserved. |
| 65 | return { |
| 66 | inject(req: unknown) { |
| 67 | const q = req as { headers?: Record<string, string | string[] | undefined> }; |
| 68 | return app.inject({ |
| 69 | ...q, |
| 70 | headers: { authorization: 'Bearer test-token', ...q.headers }, |
| 71 | }); |
| 72 | }, |
| 73 | }; |
| 74 | } |
| 75 | |
| 76 | function envelopeOf<T>(body: unknown): { |
| 77 | code: number; |
no test coverage detected