|
1 | 1 | // Memory Host SDK tests cover embeddings remote client behavior. |
2 | 2 | import { describe, expect, it, vi } from "vitest"; |
3 | | -import { resolveRemoteEmbeddingBearerClient } from "./embeddings-remote-client.js"; |
| 3 | +import { |
| 4 | + OPENAI_EMBEDDINGS_API, |
| 5 | + resolveRemoteEmbeddingBearerClient, |
| 6 | +} from "./embeddings-remote-client.js"; |
| 7 | + |
| 8 | +const { resolveApiKeyForProviderMock } = vi.hoisted(() => ({ |
| 9 | + resolveApiKeyForProviderMock: vi.fn(async () => ({ apiKey: "sk-resolved", mode: "api-key" })), |
| 10 | +})); |
| 11 | + |
| 12 | +vi.mock("./openclaw-runtime-auth.js", async (importOriginal) => ({ |
| 13 | + ...(await importOriginal<typeof import("./openclaw-runtime-auth.js")>()), |
| 14 | + resolveApiKeyForProvider: resolveApiKeyForProviderMock, |
| 15 | +})); |
4 | 16 |
|
5 | 17 | describe("resolveRemoteEmbeddingBearerClient", () => { |
6 | 18 | it("uses configured OpenAI provider baseUrl for memory embeddings", async () => { |
@@ -54,4 +66,28 @@ describe("resolveRemoteEmbeddingBearerClient", () => { |
54 | 66 | "User-Agent": "openclaw/2026.3.22", |
55 | 67 | }); |
56 | 68 | }); |
| 69 | + |
| 70 | + it("declares the embeddings API route so provider auth mode is enforced", async () => { |
| 71 | + await resolveRemoteEmbeddingBearerClient({ |
| 72 | + provider: "openai", |
| 73 | + defaultBaseUrl: "https://api.openai.com/v1", |
| 74 | + options: { |
| 75 | + agentDir: "/tmp/openclaw-agent", |
| 76 | + config: { |
| 77 | + models: { |
| 78 | + providers: { |
| 79 | + openai: { |
| 80 | + baseUrl: "http://127.0.0.1:19556/v1", |
| 81 | + }, |
| 82 | + }, |
| 83 | + }, |
| 84 | + } as never, |
| 85 | + model: "text-embedding-3-small", |
| 86 | + }, |
| 87 | + }); |
| 88 | + |
| 89 | + expect(resolveApiKeyForProviderMock).toHaveBeenCalledWith( |
| 90 | + expect.objectContaining({ provider: "openai", modelApi: OPENAI_EMBEDDINGS_API }), |
| 91 | + ); |
| 92 | + }); |
57 | 93 | }); |
0 commit comments