mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 09:01:33 +00:00
fix(github-copilot): format legacy oauth credentials
This commit is contained in:
@@ -174,6 +174,20 @@ function registerProviderWithPluginConfig(pluginConfig: Record<string, unknown>)
|
||||
}
|
||||
|
||||
describe("github-copilot plugin", () => {
|
||||
it("formats legacy OAuth profiles with the durable GitHub credential", () => {
|
||||
const provider = registerProviderWithPluginConfig({});
|
||||
|
||||
expect(
|
||||
provider.formatApiKey?.({
|
||||
type: "oauth",
|
||||
provider: "github-copilot",
|
||||
access: "short-lived-copilot-token",
|
||||
refresh: " durable-github-token ",
|
||||
expires: Date.now() + 60_000,
|
||||
}),
|
||||
).toBe("durable-github-token");
|
||||
});
|
||||
|
||||
it("preserves the source token supplied by the auth layer for runtime auth", async () => {
|
||||
mocks.resolveCopilotRuntimeAuth.mockResolvedValueOnce({
|
||||
apiKey: "github-source-token",
|
||||
|
||||
@@ -600,6 +600,7 @@ export default definePluginEntry({
|
||||
prepareDynamicModel: dynamicModels.prepareDynamicModel,
|
||||
resolveDynamicModel: dynamicModels.resolveDynamicModel,
|
||||
preferRuntimeResolvedModel: dynamicModels.preferRuntimeResolvedModel,
|
||||
formatApiKey: (credential) => (credential.type === "oauth" ? credential.refresh.trim() : ""),
|
||||
wrapStreamFn: wrapCopilotProviderStream,
|
||||
buildReplayPolicy: ({ modelId }) => buildGithubCopilotReplayPolicy(modelId),
|
||||
sanitizeReplayHistory: sanitizeGithubCopilotReplayHistory,
|
||||
|
||||
Reference in New Issue
Block a user