fix: provide capability for both SDK auth modes

This commit is contained in:
2026-07-11 14:59:00 +08:00
parent f065f9f978
commit ebf870249f
5 changed files with 28 additions and 7 deletions
+7 -2
View File
@@ -52,9 +52,10 @@ describe("run-scoped provider proxy", () => {
expect(serializedAgentEnv).not.toContain(String(address.port));
expect(lease.sdkEnv).toMatchObject({
ANTHROPIC_BASE_URL: expect.stringMatching(/^http:\/\/127\.0\.0\.1:\d+$/),
ANTHROPIC_AUTH_TOKEN: "",
ANTHROPIC_AUTH_TOKEN: expect.any(String),
ANTHROPIC_API_KEY: expect.any(String),
});
expect(lease.sdkEnv.ANTHROPIC_AUTH_TOKEN).toBe(lease.sdkEnv.ANTHROPIC_API_KEY);
const response = await fetch(`${lease.sdkEnv.ANTHROPIC_BASE_URL}/v1/messages`, {
method: "POST",
@@ -104,7 +105,11 @@ describe("run-scoped provider proxy", () => {
expect(response.status).toBe(401);
expect(upstreamRequests).toBe(0);
expect(diagnostics).toEqual([{ code: "provider_proxy_unauthorized", category: "authorization" }]);
expect(diagnostics).toEqual([{
code: "provider_proxy_unauthorized",
category: "authorization",
authShape: { bearerLength: 0, apiKeyLength: 0, expectedLength: 43 },
}]);
});
it("accepts the run capability in the Anthropic x-api-key header", async () => {