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