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