openclaw/extensions/github-copilot/domain.test.ts
Tobias Oort 0307deacfa
feat(github-copilot): support GitHub Enterprise data-residency Copilot auth (#99221)
Adds GitHub Enterprise data-residency support to the existing bundled GitHub Copilot provider.

Maintainer proof:
- GitHub CI green on head 54010a6538f1543a7fcf161f0c46169bf059213b
- `check-lint`, `check-additional-extension-bundled`, and `check-shrinkwrap` passed in CI
- local `pnpm lint:extensions:bundled`, `pnpm lint`, and focused GitHub Copilot Vitest passed
- AWS Crabbox proof passed
- live microsoft.ghe.com device-flow/token-exchange/model-catalog proof passed

Co-authored-by: Tobias Oort <tobias.oort@ict.nl>
Co-authored-by: Gio Della-Libera <235387111+giodl73-repo@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-07-08 18:59:41 -07:00

38 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { PUBLIC_GITHUB_COPILOT_DOMAIN, resolveGithubCopilotDomain } from "./domain.js";
describe("github-copilot domain resolution", () => {
const withDomain = (githubDomain: string) =>
({
models: { providers: { "github-copilot": { params: { githubDomain } } } },
}) as never;
it("defaults to the public github.com host", () => {
expect(PUBLIC_GITHUB_COPILOT_DOMAIN).toBe("github.com");
expect(resolveGithubCopilotDomain({ env: {} })).toBe("github.com");
});
it("resolves domain by precedence env > config > default", () => {
expect(resolveGithubCopilotDomain({ env: {}, config: withDomain("cfg.ghe.com") })).toBe(
"cfg.ghe.com",
);
expect(
resolveGithubCopilotDomain({
env: { COPILOT_GITHUB_DOMAIN: "env.ghe.com" },
config: withDomain("cfg.ghe.com"),
}),
).toBe("env.ghe.com");
});
it("fails closed to github.com for unsafe or non-tenant hosts", () => {
expect(resolveGithubCopilotDomain({ env: {}, config: withDomain("acme.ghe.co") })).toBe(
"github.com",
);
expect(resolveGithubCopilotDomain({ env: {}, config: withDomain("api.acme.ghe.com") })).toBe(
"github.com",
);
expect(resolveGithubCopilotDomain({ env: { COPILOT_GITHUB_DOMAIN: "evil.com" } })).toBe(
"github.com",
);
});
});