Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openclaw/extensions/browser/src/browser/   (Openclaw AI Version 22©)  Datei vom 26.3.2026 mit Größe 2 kB image not shown  

Quelle  control-auth.test.ts

  Sprache: JAVA
 

import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../../test-support.js";
import { ensureBrowserControlAuth } from "./control-auth.js";

describe("ensureBrowserControlAuth", () => {
  async function expectNoAutoGeneratedAuth(cfg: OpenClawConfig): Promise<void> {
    const result = await ensureBrowserControlAuth({
      cfg,
      env: { NODE_ENV: "test" },
    });
    expect(result.generatedToken).toBeUndefined();
    expect(result.auth.token).toBeUndefined();
    expect(result.auth.password).toBeUndefined();
  }

  describe("trusted-proxy mode", () => {
    it("should skip auto-generation in test mode", async () => {
      const cfg: OpenClawConfig = {
        gateway: {
          auth: {
            mode: "trusted-proxy",
            trustedProxy: {
              userHeader: "x-forwarded-user",
            },
          },
          trustedProxies: ["192.168.1.1"],
        },
      };
      await expectNoAutoGeneratedAuth(cfg);
    });
  });

  describe("password mode", () => {
    it("should skip auto-generation in test mode", async () => {
      const cfg: OpenClawConfig = {
        gateway: {
          auth: {
            mode: "password",
          },
        },
      };
      await expectNoAutoGeneratedAuth(cfg);
    });
  });

  describe("none mode", () => {
    it("should skip auto-generation in test mode", async () => {
      const cfg: OpenClawConfig = {
        gateway: {
          auth: {
            mode: "none",
          },
        },
      };
      await expectNoAutoGeneratedAuth(cfg);
    });
  });

  describe("token mode", () => {
    it("should return existing token if configured", async () => {
      const cfg: OpenClawConfig = {
        gateway: {
          auth: {
            mode: "token",
            token: "existing-token-123",
          },
        },
      };

      const result = await ensureBrowserControlAuth({
        cfg,
        env: {} as NodeJS.ProcessEnv,
      });

      expect(result.generatedToken).toBeUndefined();
      expect(result.auth.token).toBe("existing-token-123");
    });

    it("should skip auto-generation in test environment", async () => {
      const cfg: OpenClawConfig = {
        gateway: {
          auth: {
            mode: "token",
          },
        },
      };

      const result = await ensureBrowserControlAuth({
        cfg,
        env: { NODE_ENV: "test" },
      });

      expect(result.generatedToken).toBeUndefined();
      expect(result.auth.token).toBeUndefined();
    });
  });
});

Messung V0.5 in Prozent
C=93 H=97 G=94

¤ Dauer der Verarbeitung: 0.14 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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.