























@@ -2,10 +2,23 @@ import { describe, expect, it, vi } from "vitest";
22import type { AuthProfileStore } from "../../agents/auth-profiles/types.js";
33import { createModelListAuthIndex } from "./list.auth-index.js";
445-vi.mock("../../plugins/installed-plugin-index-store.js", () => ({
6-readPersistedInstalledPluginIndexSync: vi.fn(() => null),
5+const pluginRegistryMocks = vi.hoisted(() => ({
6+loadPluginRegistrySnapshotWithMetadata: vi.fn(() => ({
7+source: "persisted",
8+snapshot: { plugins: [] },
9+diagnostics: [],
10+})),
711}));
81213+vi.mock("../../plugins/plugin-registry.js", async (importOriginal) => {
14+const actual = await importOriginal<typeof import("../../plugins/plugin-registry.js")>();
15+return {
16+ ...actual,
17+loadPluginRegistrySnapshotWithMetadata:
18+pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata,
19+};
20+});
21+922const emptyStore: AuthProfileStore = {
1023version: 1,
1124profiles: {},
@@ -57,6 +70,18 @@ describe("createModelListAuthIndex", () => {
5770expect(index.hasProviderAuth("openai")).toBe(false);
5871});
597273+it("uses manifest env metadata for google vertex auth", () => {
74+const index = createModelListAuthIndex({
75+cfg: {},
76+authStore: emptyStore,
77+env: {
78+GOOGLE_CLOUD_API_KEY: "gcp-test",
79+},
80+});
81+82+expect(index.hasProviderAuth("google-vertex")).toBe(true);
83+});
84+6085it("records configured provider API keys", () => {
6186const index = createModelListAuthIndex({
6287cfg: {
@@ -108,4 +133,38 @@ describe("createModelListAuthIndex", () => {
108133109134expect(index.hasProviderAuth("codex")).toBe(true);
110135});
136+137+it("ignores derived synthetic auth snapshots", () => {
138+pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata.mockReturnValueOnce({
139+source: "derived",
140+snapshot: {
141+plugins: [{ enabled: true, syntheticAuthRefs: ["codex"] }],
142+},
143+diagnostics: [],
144+});
145+const index = createModelListAuthIndex({
146+cfg: {},
147+authStore: emptyStore,
148+env: {},
149+});
150+151+expect(index.hasProviderAuth("codex")).toBe(false);
152+});
153+154+it("ignores disabled synthetic auth snapshot entries", () => {
155+pluginRegistryMocks.loadPluginRegistrySnapshotWithMetadata.mockReturnValueOnce({
156+source: "persisted",
157+snapshot: {
158+plugins: [{ enabled: false, syntheticAuthRefs: ["codex"] }],
159+},
160+diagnostics: [],
161+});
162+const index = createModelListAuthIndex({
163+cfg: {},
164+authStore: emptyStore,
165+env: {},
166+});
167+168+expect(index.hasProviderAuth("codex")).toBe(false);
169+});
111170});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。