Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Openclaw/src/plugins/   (KI Agentensystem Version 22©)  Datei vom 26.3.2026 mit Größe 2 kB image not shown  

Quelle  provider-auth-env-trust.test.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import { describe, expect, it, vi } from "vitest";

const getProviderEnvVars = vi.hoisted(() => vi.fn(() => ["WHISPERX_API_KEY"]));

vi.mock("../secrets/provider-env-vars.js", () => ({
  getProviderEnvVars,
}));

describe("provider auth env trust", () => {
  it("buildApiKeyCredential excludes untrusted workspace plugin env vars for ref mode", async () => {
    const { buildApiKeyCredential } = await import("./provider-auth-helpers.js");
    const config = { plugins: {} };

    const credential = buildApiKeyCredential("whisperx", "secret-value", undefined, {
      secretInputMode: "ref",
      config,
    });

    expect(getProviderEnvVars).toHaveBeenCalledWith("whisperx", {
      config,
      includeUntrustedWorkspacePlugins: false,
    });
    expect(credential).toMatchObject({
      keyRef: { source: "env", provider: "default", id: "WHISPERX_API_KEY" },
    });
  });

  it("buildApiKeyCredential keeps secret-ref-like input literal in plaintext mode", async () => {
    const { buildApiKeyCredential } = await import("./provider-auth-helpers.js");

    const credential = buildApiKeyCredential("ollama", "${AWS_SECRET_ACCESS_KEY}", undefined, {
      secretInputMode: "plaintext",
    });

    expect(credential).toEqual({
      type: "api_key",
      provider: "ollama",
      key: "${AWS_SECRET_ACCESS_KEY}",
    });
  });

  it("resolveRefFallbackInput excludes untrusted workspace plugin env vars", async () => {
    const { resolveRefFallbackInput } = await import("./provider-auth-ref.js");
    const config = { plugins: {} };

    const result = resolveRefFallbackInput({
      config,
      provider: "whisperx",
      env: { WHISPERX_API_KEY: "test-secret" },
    });

    expect(getProviderEnvVars).toHaveBeenCalledWith("whisperx", {
      config,
      includeUntrustedWorkspacePlugins: false,
    });
    expect(result).toMatchObject({
      ref: { source: "env", provider: "default", id: "WHISPERX_API_KEY" },
      resolvedValue: "test-secret",
    });
  });

  it("promptSecretRefForSetup keeps config-aware trusted env var suggestions", async () => {
    const { promptSecretRefForSetup } = await import("./provider-auth-ref.js");
    const config = { plugins: { allow: ["workspace-audio"] } };
    const prompter = {
      select: vi.fn(async () => "env"),
      text: vi.fn(async () => "WHISPERX_API_KEY"),
      note: vi.fn(async () => {}),
    };

    const result = await promptSecretRefForSetup({
      config,
      provider: "whisperx",
      prompter: prompter as never,
      env: { WHISPERX_API_KEY: "test-secret" },
    });

    expect(getProviderEnvVars).toHaveBeenCalledWith("whisperx", {
      config,
      includeUntrustedWorkspacePlugins: false,
    });
    expect(result).toMatchObject({
      ref: { source: "env", provider: "default", id: "WHISPERX_API_KEY" },
      resolvedValue: "test-secret",
    });
  });
});

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.