(request)
| 169 | using server = Bun.serve({ |
| 170 | port: 0, |
| 171 | async fetch(request) { |
| 172 | const url = new URL(request.url) |
| 173 | if (url.pathname === "/oauth/token") { |
| 174 | expect(await request.text()).toContain("refresh_token=refresh-old") |
| 175 | refreshRequests += 1 |
| 176 | await refreshReady |
| 177 | return Response.json({ |
| 178 | id_token: createTestJwt({ chatgpt_account_id: "acc-123" }), |
| 179 | access_token: "access-new", |
| 180 | refresh_token: "refresh-new", |
| 181 | expires_in: 3600, |
| 182 | }) |
| 183 | } |
| 184 | |
| 185 | if (url.pathname === "/backend-api/codex/responses") { |
| 186 | apiRequests.push({ |
| 187 | authorization: request.headers.get("authorization"), |
| 188 | accountId: request.headers.get("ChatGPT-Account-Id"), |
| 189 | }) |
| 190 | return new Response("{}", { status: 200 }) |
| 191 | } |
| 192 | |
| 193 | return new Response("unexpected request", { status: 500 }) |
| 194 | }, |
| 195 | }) |
| 196 | |
| 197 | const hooks = await CodexAuthPlugin( |
no test coverage detected