mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 20:21:13 +00:00
fix(providers): classify copilot native endpoints (#59644)
* fix(providers): classify copilot native endpoints * fix(changelog): add copilot endpoint note * fix(providers): handle copilot proxy hints
This commit is contained in:
@@ -1,7 +1,31 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { resolveCopilotApiToken } from "./github-copilot-token.js";
|
||||
import {
|
||||
deriveCopilotApiBaseUrlFromToken,
|
||||
resolveCopilotApiToken,
|
||||
} from "./github-copilot-token.js";
|
||||
|
||||
describe("resolveCopilotApiToken", () => {
|
||||
it("derives native Copilot base URLs from Copilot proxy hints", () => {
|
||||
expect(
|
||||
deriveCopilotApiBaseUrlFromToken(
|
||||
"copilot-token;proxy-ep=https://proxy.individual.githubcopilot.com;",
|
||||
),
|
||||
).toBe("https://api.individual.githubcopilot.com");
|
||||
expect(deriveCopilotApiBaseUrlFromToken("copilot-token;proxy-ep=proxy.example.com;")).toBe(
|
||||
"https://api.example.com",
|
||||
);
|
||||
expect(deriveCopilotApiBaseUrlFromToken("copilot-token;proxy-ep=proxy.example.com:8443;")).toBe(
|
||||
"https://api.example.com",
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects malformed or non-http proxy hints", () => {
|
||||
expect(
|
||||
deriveCopilotApiBaseUrlFromToken("copilot-token;proxy-ep=javascript:alert(1);"),
|
||||
).toBeNull();
|
||||
expect(deriveCopilotApiBaseUrlFromToken("copilot-token;proxy-ep=://bad;")).toBeNull();
|
||||
});
|
||||
|
||||
it("treats 11-digit expires_at values as seconds epochs", async () => {
|
||||
const fetchImpl = vi.fn(async () => ({
|
||||
ok: true,
|
||||
|
||||
Reference in New Issue
Block a user