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

Quelle  auth-mode-policy.test.ts

  Sprache: JAVA
 

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

import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import {
  assertExplicitGatewayAuthModeWhenBothConfigured,
  EXPLICIT_GATEWAY_AUTH_MODE_REQUIRED_ERROR,
  hasAmbiguousGatewayAuthModeConfig,
} from "./auth-mode-policy.js";

describe("gateway auth mode policy", () => {
  it("does not flag config when auth mode is explicit", () => {
    const cfg: OpenClawConfig = {
      gateway: {
        auth: {
          mode: "token",
          token: "token-value",
          password: "password-value", // pragma: allowlist secret
        },
      },
    };
    expect(hasAmbiguousGatewayAuthModeConfig(cfg)).toBe(false);
  });

  it("does not flag config when only one auth credential is configured", () => {
    const cfg: OpenClawConfig = {
      gateway: {
        auth: {
          token: "token-value",
        },
      },
    };
    expect(hasAmbiguousGatewayAuthModeConfig(cfg)).toBe(false);
  });

  it("flags config when both token and password are configured and mode is unset", () => {
    const cfg: OpenClawConfig = {
      gateway: {
        auth: {
          token: "token-value",
          password: "password-value", // pragma: allowlist secret
        },
      },
    };
    expect(hasAmbiguousGatewayAuthModeConfig(cfg)).toBe(true);
  });

  it("flags config when both token/password SecretRefs are configured and mode is unset", () => {
    const cfg: OpenClawConfig = {
      gateway: {
        auth: {
          token: { source: "env", provider: "default", id: "GW_TOKEN" },
          password: { source: "env", provider: "default", id: "GW_PASSWORD" },
        },
      },
      secrets: {
        providers: {
          default: { source: "env" },
        },
      },
    };
    expect(hasAmbiguousGatewayAuthModeConfig(cfg)).toBe(true);
  });

  it("throws the shared explicit-mode error for ambiguous dual auth config", () => {
    const cfg: OpenClawConfig = {
      gateway: {
        auth: {
          token: "token-value",
          password: "password-value", // pragma: allowlist secret
        },
      },
    };
    expect(() => assertExplicitGatewayAuthModeWhenBothConfigured(cfg)).toThrow(
      EXPLICIT_GATEWAY_AUTH_MODE_REQUIRED_ERROR,
    );
  });
});

¤ Dauer der Verarbeitung: 0.1 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.