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

Quelle  manifest-owner-policy.test.ts

  Sprache: JAVA
 

import { describe, expect, it } from "vitest";
import { normalizePluginsConfig } from "./config-state.js";
import {
  hasExplicitManifestOwnerTrust,
  isActivatedManifestOwner,
  isBundledManifestOwner,
  passesManifestOwnerBasePolicy,
} from "./manifest-owner-policy.js";

describe("manifest owner policy", () => {
  it("treats bundled owners as bundled and others as non-bundled", () => {
    expect(isBundledManifestOwner({ origin: "bundled" })).toBe(true);
    expect(isBundledManifestOwner({ origin: "workspace" })).toBe(false);
  });

  it("respects enabled, denylist, explicit disable, and allowlist bounds", () => {
    const normalizedConfig = normalizePluginsConfig({
      enabled: true,
      allow: ["demo"],
      deny: ["blocked"],
      entries: {
        disabled: { enabled: false },
        enabled: { enabled: true },
      },
    });

    expect(
      passesManifestOwnerBasePolicy({
        plugin: { id: "demo" },
        normalizedConfig,
      }),
    ).toBe(true);
    expect(
      passesManifestOwnerBasePolicy({
        plugin: { id: "blocked" },
        normalizedConfig,
      }),
    ).toBe(false);
    expect(
      passesManifestOwnerBasePolicy({
        plugin: { id: "disabled" },
        normalizedConfig,
      }),
    ).toBe(false);

    const explicitlyTrustedDisabledConfig = normalizePluginsConfig({
      enabled: true,
      allow: ["disabled"],
      entries: {
        disabled: { enabled: false },
      },
    });
    expect(
      passesManifestOwnerBasePolicy({
        plugin: { id: "disabled" },
        normalizedConfig: explicitlyTrustedDisabledConfig,
        allowExplicitlyDisabled: true,
      }),
    ).toBe(true);
    expect(
      passesManifestOwnerBasePolicy({
        plugin: { id: "other" },
        normalizedConfig,
      }),
    ).toBe(false);
  });

  it("detects explicit manifest owner trust from allowlist or explicit enablement", () => {
    const allowlistConfig = normalizePluginsConfig({
      allow: ["demo"],
    });
    const entriesConfig = normalizePluginsConfig({
      entries: {
        demo: { enabled: true },
      },
    });

    expect(
      hasExplicitManifestOwnerTrust({
        plugin: { id: "demo" },
        normalizedConfig: allowlistConfig,
      }),
    ).toBe(true);
    expect(
      hasExplicitManifestOwnerTrust({
        plugin: { id: "demo" },
        normalizedConfig: entriesConfig,
      }),
    ).toBe(true);
    expect(
      hasExplicitManifestOwnerTrust({
        plugin: { id: "demo" },
        normalizedConfig: normalizePluginsConfig({}),
      }),
    ).toBe(false);
  });

  it("uses effective activation state for activated manifest owners", () => {
    expect(
      isActivatedManifestOwner({
        plugin: {
          id: "demo",
          origin: "bundled",
          enabledByDefault: true,
        },
        normalizedConfig: normalizePluginsConfig({}),
      }),
    ).toBe(true);

    expect(
      isActivatedManifestOwner({
        plugin: {
          id: "demo",
          origin: "bundled",
          enabledByDefault: true,
        },
        normalizedConfig: normalizePluginsConfig({
          enabled: false,
        }),
      }),
    ).toBe(false);
  });
});

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-09) ¤

*© 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.