(r: RunningServer)
| 135 | } |
| 136 | |
| 137 | function appOf(r: RunningServer): { |
| 138 | inject: (req: unknown) => Promise<{ statusCode: number; json: () => unknown }>; |
| 139 | } { |
| 140 | const app = r.services.invokeFunction((a) => { |
| 141 | const gw = a.get(IRestGateway); |
| 142 | return gw.app as unknown as { |
| 143 | inject: (req: unknown) => Promise<{ statusCode: number; json: () => unknown }>; |
| 144 | }; |
| 145 | }); |
| 146 | // Auto-attach the fixed bearer token so the M5.1 auth hook passes. A |
| 147 | // caller-supplied `authorization` header wins, so explicit token tests keep |
| 148 | // working; every other header (Range, content-type, …) is preserved. |
| 149 | return { |
| 150 | inject(req: unknown) { |
| 151 | const q = req as { headers?: Record<string, string | string[] | undefined> }; |
| 152 | return app.inject({ |
| 153 | ...q, |
| 154 | headers: { authorization: 'Bearer test-token', ...q.headers }, |
| 155 | }); |
| 156 | }, |
| 157 | }; |
| 158 | } |
| 159 | |
| 160 | function envelopeOf<T>(body: unknown): { |
| 161 | code: number; |
no test coverage detected