mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 17:01:22 +00:00
fix(cron): prevent isolated hook session-key double-prefixing (land #27333, @MaheshBhushan)
Co-authored-by: MaheshBhushan <mkoduri73@gmail.com>
This commit is contained in:
28
src/cron/isolated-agent/run.session-key.test.ts
Normal file
28
src/cron/isolated-agent/run.session-key.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveCronAgentSessionKey } from "./run.js";
|
||||
|
||||
describe("resolveCronAgentSessionKey", () => {
|
||||
it("builds an agent-scoped key for legacy aliases", () => {
|
||||
expect(resolveCronAgentSessionKey({ sessionKey: "main", agentId: "main" })).toBe(
|
||||
"agent:main:main",
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves canonical agent keys instead of prefixing twice", () => {
|
||||
expect(resolveCronAgentSessionKey({ sessionKey: "agent:main:main", agentId: "main" })).toBe(
|
||||
"agent:main:main",
|
||||
);
|
||||
});
|
||||
|
||||
it("normalizes canonical keys to lowercase before reuse", () => {
|
||||
expect(
|
||||
resolveCronAgentSessionKey({ sessionKey: "AGENT:Main:Hook:Webhook:42", agentId: "x" }),
|
||||
).toBe("agent:main:hook:webhook:42");
|
||||
});
|
||||
|
||||
it("keeps hook keys scoped under the target agent", () => {
|
||||
expect(resolveCronAgentSessionKey({ sessionKey: "hook:webhook:42", agentId: "main" })).toBe(
|
||||
"agent:main:hook:webhook:42",
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user