(r: RunningServer)
| 92 | } |
| 93 | |
| 94 | function appOf(r: RunningServer): { |
| 95 | inject: (req: unknown) => Promise<{ statusCode: number; json: () => unknown }>; |
| 96 | } { |
| 97 | const app = r.services.invokeFunction((a) => { |
| 98 | const gw = a.get(IRestGateway); |
| 99 | return gw.app as unknown as { |
| 100 | inject: (req: unknown) => Promise<{ statusCode: number; json: () => unknown }>; |
| 101 | }; |
| 102 | }); |
| 103 | // Auto-attach the fixed bearer token so the M5.1 auth hook passes. A |
| 104 | // caller-supplied `authorization` header wins, so explicit token tests keep |
| 105 | // working; every other header (Range, content-type, …) is preserved. |
| 106 | return { |
| 107 | inject(req: unknown) { |
| 108 | const q = req as { headers?: Record<string, string | string[] | undefined> }; |
| 109 | return app.inject({ |
| 110 | ...q, |
| 111 | headers: { authorization: 'Bearer test-token', ...q.headers }, |
| 112 | }); |
| 113 | }, |
| 114 | }; |
| 115 | } |
| 116 | |
| 117 | function envelopeOf<T>(body: unknown): { code: number; msg: string; data: T | null; request_id: string; details?: unknown } { |
| 118 | return body as { code: number; msg: string; data: T | null; request_id: string; details?: unknown }; |
no test coverage detected