mirror of https://github.com/openclaw/openclaw.git
test(gateway): cover default-agent transcript fallbacks
This commit is contained in:
parent
914d47f0a8
commit
8ce7cfdc12
|
|
@ -594,6 +594,22 @@ describe("resolveSessionTranscriptCandidates", () => {
|
|||
});
|
||||
|
||||
describe("resolveSessionTranscriptCandidates safety", () => {
|
||||
test("keeps cross-agent absolute sessionFile when storePath agent context differs", () => {
|
||||
const storePath = "/tmp/openclaw/agents/main/sessions/sessions.json";
|
||||
const sessionFile = "/tmp/openclaw/agents/ops/sessions/sess-safe.jsonl";
|
||||
const candidates = resolveSessionTranscriptCandidates("sess-safe", storePath, sessionFile);
|
||||
|
||||
expect(candidates.map((value) => path.resolve(value))).toContain(path.resolve(sessionFile));
|
||||
});
|
||||
|
||||
test("keeps cross-agent absolute sessionFile for custom per-agent store roots", () => {
|
||||
const storePath = "/srv/custom/agents/main/sessions/sessions.json";
|
||||
const sessionFile = "/srv/custom/agents/ops/sessions/sess-safe.jsonl";
|
||||
const candidates = resolveSessionTranscriptCandidates("sess-safe", storePath, sessionFile);
|
||||
|
||||
expect(candidates.map((value) => path.resolve(value))).toContain(path.resolve(sessionFile));
|
||||
});
|
||||
|
||||
test("drops unsafe session IDs instead of producing traversal paths", () => {
|
||||
const candidates = resolveSessionTranscriptCandidates(
|
||||
"../etc/passwd",
|
||||
|
|
|
|||
|
|
@ -70,6 +70,25 @@ describe("gateway session utils", () => {
|
|||
);
|
||||
});
|
||||
|
||||
test("resolveSessionStoreKey falls back to first list entry when no agent is marked default", () => {
|
||||
const cfg = {
|
||||
session: { mainKey: "main" },
|
||||
agents: { list: [{ id: "ops" }, { id: "review" }] },
|
||||
} as OpenClawConfig;
|
||||
expect(resolveSessionStoreKey({ cfg, sessionKey: "main" })).toBe("agent:ops:main");
|
||||
expect(resolveSessionStoreKey({ cfg, sessionKey: "discord:group:123" })).toBe(
|
||||
"agent:ops:discord:group:123",
|
||||
);
|
||||
});
|
||||
|
||||
test("resolveSessionStoreKey falls back to main when agents.list is missing", () => {
|
||||
const cfg = {
|
||||
session: { mainKey: "work" },
|
||||
} as OpenClawConfig;
|
||||
expect(resolveSessionStoreKey({ cfg, sessionKey: "main" })).toBe("agent:main:work");
|
||||
expect(resolveSessionStoreKey({ cfg, sessionKey: "thread-1" })).toBe("agent:main:thread-1");
|
||||
});
|
||||
|
||||
test("resolveSessionStoreKey normalizes session key casing", () => {
|
||||
const cfg = {
|
||||
session: { mainKey: "main" },
|
||||
|
|
|
|||
Loading…
Reference in New Issue