54 lines
2.2 KiB
JavaScript
54 lines
2.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { describe, it } from "vitest";
|
|
|
|
import { formatPluginRuntimeLiveResult, verifyPluginRuntimeLiveEnv } from "./verify-plugin-runtime-live.mjs";
|
|
|
|
const trustKey = "aa".repeat(32);
|
|
|
|
describe("verify-plugin-runtime-live", () => {
|
|
it("fails closed when only worker topology is present", () => {
|
|
const result = verifyPluginRuntimeLiveEnv({
|
|
WORKER_ENABLED: "true",
|
|
WORKER_QUEUE_GROUP: "plugin",
|
|
DATABASE_URL: "postgresql://localhost/app",
|
|
BULLMQ_REDIS_URL: "redis://localhost:6379/0",
|
|
});
|
|
|
|
assert.match(result.failures.join("\n"), /PLUGIN_RUNTIME_PRODUCTION_ENABLED must be true/);
|
|
assert.match(result.failures.join("\n"), /PLUGIN_TRUSTED_PUBLIC_KEYS must contain/);
|
|
});
|
|
|
|
it("passes for a live plugin worker runtime gate", () => {
|
|
const result = verifyPluginRuntimeLiveEnv({
|
|
PLUGIN_RUNTIME_PRODUCTION_ENABLED: "true",
|
|
PLUGIN_TRUSTED_PUBLIC_KEYS: trustKey,
|
|
WORKER_ENABLED: "true",
|
|
WORKER_QUEUE_GROUP: "plugin",
|
|
DATABASE_URL: "postgresql://localhost/app",
|
|
BULLMQ_REDIS_URL: "redis://localhost:6379/0",
|
|
});
|
|
|
|
assert.deepEqual(result.failures, []);
|
|
assert.match(formatPluginRuntimeLiveResult(result), /^PASS plugin runtime live verification/);
|
|
});
|
|
|
|
it("requires general worker fanout and capability-use persistence for live runtime", () => {
|
|
const result = verifyPluginRuntimeLiveEnv({
|
|
PLUGIN_RUNTIME_PRODUCTION_ENABLED: "true",
|
|
PLUGIN_TRUSTED_PUBLIC_KEYS: trustKey,
|
|
WORKER_ENABLED: "true",
|
|
WORKER_QUEUE_GROUP: "general",
|
|
DATABASE_URL: "postgresql://localhost/app",
|
|
BULLMQ_REDIS_URL: "redis://localhost:6379/0",
|
|
OUTBOX_DISPATCHER_ENABLED: "false",
|
|
PLUGIN_HOOK_FANOUT_ENABLED: "false",
|
|
PLUGIN_CAPABILITY_USE_ENABLED: "false",
|
|
});
|
|
|
|
assert.match(result.failures.join("\n"), /OUTBOX_DISPATCHER_ENABLED must be true/);
|
|
assert.match(result.failures.join("\n"), /PLUGIN_HOOK_FANOUT_REQUIRED must be true/);
|
|
assert.match(result.failures.join("\n"), /PLUGIN_HOOK_FANOUT_ENABLED must be unset or true/);
|
|
assert.match(result.failures.join("\n"), /PLUGIN_CAPABILITY_USE_ENABLED must be unset or true/);
|
|
});
|
|
});
|