mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 11:00:34 +00:00
refactor(test): reuse directive per-agent allowlist config
This commit is contained in:
@@ -8,23 +8,8 @@ import {
|
|||||||
} from "./reply.directive.directive-behavior.e2e-harness.js";
|
} from "./reply.directive.directive-behavior.e2e-harness.js";
|
||||||
import { getReplyFromConfig } from "./reply.js";
|
import { getReplyFromConfig } from "./reply.js";
|
||||||
|
|
||||||
describe("directive behavior", () => {
|
function makeWorkElevatedAllowlistConfig(home: string) {
|
||||||
installDirectiveBehaviorE2EHooks();
|
return {
|
||||||
|
|
||||||
it("requires per-agent allowlist in addition to global", async () => {
|
|
||||||
await withTempHome(async (home) => {
|
|
||||||
const res = await getReplyFromConfig(
|
|
||||||
{
|
|
||||||
Body: "/elevated on",
|
|
||||||
From: "+1222",
|
|
||||||
To: "+1222",
|
|
||||||
Provider: "whatsapp",
|
|
||||||
SenderE164: "+1222",
|
|
||||||
SessionKey: "agent:work:main",
|
|
||||||
CommandAuthorized: true,
|
|
||||||
},
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
agents: {
|
agents: {
|
||||||
defaults: {
|
defaults: {
|
||||||
model: "anthropic/claude-opus-4-5",
|
model: "anthropic/claude-opus-4-5",
|
||||||
@@ -48,7 +33,26 @@ describe("directive behavior", () => {
|
|||||||
},
|
},
|
||||||
channels: { whatsapp: { allowFrom: ["+1222", "+1333"] } },
|
channels: { whatsapp: { allowFrom: ["+1222", "+1333"] } },
|
||||||
session: { store: path.join(home, "sessions.json") },
|
session: { store: path.join(home, "sessions.json") },
|
||||||
|
} as const;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("directive behavior", () => {
|
||||||
|
installDirectiveBehaviorE2EHooks();
|
||||||
|
|
||||||
|
it("requires per-agent allowlist in addition to global", async () => {
|
||||||
|
await withTempHome(async (home) => {
|
||||||
|
const res = await getReplyFromConfig(
|
||||||
|
{
|
||||||
|
Body: "/elevated on",
|
||||||
|
From: "+1222",
|
||||||
|
To: "+1222",
|
||||||
|
Provider: "whatsapp",
|
||||||
|
SenderE164: "+1222",
|
||||||
|
SessionKey: "agent:work:main",
|
||||||
|
CommandAuthorized: true,
|
||||||
},
|
},
|
||||||
|
{},
|
||||||
|
makeWorkElevatedAllowlistConfig(home),
|
||||||
);
|
);
|
||||||
|
|
||||||
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
||||||
@@ -69,31 +73,7 @@ describe("directive behavior", () => {
|
|||||||
CommandAuthorized: true,
|
CommandAuthorized: true,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
{
|
makeWorkElevatedAllowlistConfig(home),
|
||||||
agents: {
|
|
||||||
defaults: {
|
|
||||||
model: "anthropic/claude-opus-4-5",
|
|
||||||
workspace: path.join(home, "openclaw"),
|
|
||||||
},
|
|
||||||
list: [
|
|
||||||
{
|
|
||||||
id: "work",
|
|
||||||
tools: {
|
|
||||||
elevated: {
|
|
||||||
allowFrom: { whatsapp: ["+1333"] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
tools: {
|
|
||||||
elevated: {
|
|
||||||
allowFrom: { whatsapp: ["+1222", "+1333"] },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
channels: { whatsapp: { allowFrom: ["+1222", "+1333"] } },
|
|
||||||
session: { store: path.join(home, "sessions.json") },
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
const text = Array.isArray(res) ? res[0]?.text : res?.text;
|
||||||
|
|||||||
Reference in New Issue
Block a user