mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-16 03:31:10 +00:00
fix(github-copilot): send IDE auth headers on runtime requests (#60755)
* Fix Copilot IDE auth headers * fix(github-copilot): align tests and changelog * fix(changelog): scope copilot replacement entry --------- Co-authored-by: VACInc <3279061+VACInc@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { buildCopilotIdeHeaders } from "./copilot-dynamic-headers.js";
|
||||
import {
|
||||
deriveCopilotApiBaseUrlFromToken,
|
||||
resolveCopilotApiToken,
|
||||
@@ -45,4 +46,34 @@ describe("resolveCopilotApiToken", () => {
|
||||
|
||||
expect(result.expiresAt).toBe(12_345_678_901_000);
|
||||
});
|
||||
|
||||
it("sends IDE headers when exchanging the GitHub token", async () => {
|
||||
const fetchImpl = vi.fn(async () => ({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
token: "copilot-token",
|
||||
expires_at: Math.floor(Date.now() / 1000) + 3600,
|
||||
}),
|
||||
}));
|
||||
|
||||
await resolveCopilotApiToken({
|
||||
githubToken: "github-token",
|
||||
cachePath: "/tmp/github-copilot-token-test.json",
|
||||
loadJsonFileImpl: () => undefined,
|
||||
saveJsonFileImpl: () => undefined,
|
||||
fetchImpl: fetchImpl as unknown as typeof fetch,
|
||||
});
|
||||
|
||||
expect(fetchImpl).toHaveBeenCalledWith(
|
||||
"https://api.github.com/copilot_internal/v2/token",
|
||||
expect.objectContaining({
|
||||
method: "GET",
|
||||
headers: expect.objectContaining({
|
||||
Accept: "application/json",
|
||||
Authorization: "Bearer github-token",
|
||||
...buildCopilotIdeHeaders({ includeApiVersion: true }),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user