



























@@ -227,6 +227,21 @@ async function resolveCustomProviderAuth(
227227});
228228}
229229230+function expectAuthFields(
231+auth: Awaited<ReturnType<typeof resolveApiKeyForProvider>>,
232+expected: {
233+apiKey: string;
234+mode: "api-key" | "oauth";
235+source?: string;
236+},
237+) {
238+expect(auth.apiKey).toBe(expected.apiKey);
239+expect(auth.mode).toBe(expected.mode);
240+if (expected.source !== undefined) {
241+expect(auth.source).toBe(expected.source);
242+}
243+}
244+230245describe("resolveAwsSdkEnvVarName", () => {
231246it("prefers bearer token over access keys and profile", () => {
232247const env = {
@@ -735,7 +750,7 @@ describe("resolveApiKeyForProvider", () => {
735750}),
736751);
737752738-expect(resolved).toMatchObject({
753+expectAuthFields(resolved, {
739754apiKey: "plugin-web-fallback-key",
740755source: "plugins.entries.plugin-web.config.webSearch.apiKey",
741756mode: "api-key",
@@ -779,7 +794,7 @@ describe("resolveApiKeyForProvider", () => {
779794}),
780795);
781796782-expect(resolved).toMatchObject({
797+expectAuthFields(resolved, {
783798apiKey: "plugin-web-runtime-key",
784799source: "plugins.entries.plugin-web.config.webSearch.apiKey",
785800mode: "api-key",
@@ -861,7 +876,7 @@ describe("resolveApiKeyForProvider", () => {
861876},
862877});
863878864-expect(resolved).toMatchObject({
879+expectAuthFields(resolved, {
865880apiKey: "sk-config-live",
866881source: "models.json",
867882mode: "api-key",
@@ -885,7 +900,7 @@ describe("resolveApiKeyForProvider", () => {
885900}),
886901);
887902888-expect(resolved).toMatchObject({
903+expectAuthFields(resolved, {
889904apiKey: "ollama-local",
890905mode: "api-key",
891906});
@@ -1002,7 +1017,7 @@ describe("resolveApiKeyForProvider – synthetic local auth for custom providers
10021017store: { version: 1, profiles: {} },
10031018});
100410191005-expect(auth).toMatchObject({
1020+expectAuthFields(auth, {
10061021apiKey: "ollama-local",
10071022source: "models.json (local marker)",
10081023mode: "api-key",
@@ -1036,7 +1051,7 @@ describe("resolveApiKeyForProvider – synthetic local auth for custom providers
10361051store: { version: 1, profiles: {} },
10371052});
103810531039-expect(auth).toMatchObject({
1054+expectAuthFields(auth, {
10401055apiKey: "ollama-local",
10411056source: "models.providers.ollama-gpu1 (synthetic local key)",
10421057mode: "api-key",
@@ -1071,7 +1086,7 @@ describe("resolveApiKeyForProvider – synthetic local auth for custom providers
10711086store: { version: 1, profiles: {} },
10721087});
107310881074-expect(auth).toMatchObject({
1089+expectAuthFields(auth, {
10751090apiKey: CUSTOM_LOCAL_AUTH_MARKER,
10761091source: "models.json (local marker)",
10771092mode: "api-key",
@@ -1226,10 +1241,8 @@ describe("applyLocalNoAuthHeaderOverride", () => {
12261241},
12271242);
122812431229-expect(model.headers).toMatchObject({
1230-Authorization: null,
1231-"X-Test": "1",
1232-});
1244+expect(model.headers?.Authorization).toBeNull();
1245+expect(model.headers?.["X-Test"]).toBe("1");
12331246});
12341247});
12351248此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。