fix(provider-auth): centralize copilot expiry parsing · openclaw/openclaw@4b6517d
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -156,4 +156,38 @@ describe("provider auth profile helpers", () => {
|
156 | 156 | { externalCli }, |
157 | 157 | ); |
158 | 158 | }); |
| 159 | + |
| 160 | +it("accepts plus-signed Copilot token expiry strings", async () => { |
| 161 | +vi.resetModules(); |
| 162 | + |
| 163 | +const saved: unknown[] = []; |
| 164 | +const fetchImpl = vi.fn( |
| 165 | +async () => |
| 166 | +new Response( |
| 167 | +JSON.stringify({ |
| 168 | +token: "token;proxy-ep=proxy.individual.githubcopilot.com", |
| 169 | +expires_at: "+2000000000", |
| 170 | +}), |
| 171 | +{ status: 200, headers: { "content-type": "application/json" } }, |
| 172 | +), |
| 173 | +); |
| 174 | + |
| 175 | +const { resolveCopilotApiToken } = await import("./provider-auth.js"); |
| 176 | + |
| 177 | +const result = await resolveCopilotApiToken({ |
| 178 | +githubToken: "github-token", |
| 179 | + fetchImpl, |
| 180 | +cachePath: "/tmp/copilot-token.json", |
| 181 | +loadJsonFileImpl: () => undefined, |
| 182 | +saveJsonFileImpl: (_path, value) => saved.push(value), |
| 183 | +}); |
| 184 | + |
| 185 | +expect(result.expiresAt).toBe(2_000_000_000_000); |
| 186 | +expect(saved).toEqual([ |
| 187 | +expect.objectContaining({ |
| 188 | +expiresAt: 2_000_000_000_000, |
| 189 | +token: "token;proxy-ep=proxy.individual.githubcopilot.com", |
| 190 | +}), |
| 191 | +]); |
| 192 | +}); |
159 | 193 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。