Files
openclaw/src/cli/message-secret-scope.test.ts
Josh Avant da34f81ce2 fix(secrets): scope message SecretRef resolution and harden doctor/status paths (#48728)
* fix(secrets): scope message runtime resolution and harden doctor/status

* docs: align message/doctor/status SecretRef behavior notes

* test(cli): accept scoped targetIds wiring in secret-resolution coverage

* fix(secrets): keep scoped allowedPaths isolation and tighten coverage gate

* fix(secrets): avoid default-account coercion in scoped target selection

* test(doctor): cover inactive telegram secretref inspect path

* docs

Signed-off-by: joshavant <830519+joshavant@users.noreply.github.com>

* changelog

Signed-off-by: joshavant <830519+joshavant@users.noreply.github.com>

---------

Signed-off-by: joshavant <830519+joshavant@users.noreply.github.com>
2026-03-17 00:01:34 -05:00

57 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { resolveMessageSecretScope } from "./message-secret-scope.js";
describe("resolveMessageSecretScope", () => {
it("prefers explicit channel/account inputs", () => {
expect(
resolveMessageSecretScope({
channel: "Discord",
accountId: "Ops",
}),
).toEqual({
channel: "discord",
accountId: "ops",
});
});
it("infers channel from a prefixed target", () => {
expect(
resolveMessageSecretScope({
target: "telegram:12345",
}),
).toEqual({
channel: "telegram",
});
});
it("infers a shared channel from target arrays", () => {
expect(
resolveMessageSecretScope({
targets: ["discord:one", "discord:two"],
}),
).toEqual({
channel: "discord",
});
});
it("does not infer a channel when target arrays mix channels", () => {
expect(
resolveMessageSecretScope({
targets: ["discord:one", "slack:two"],
}),
).toEqual({});
});
it("uses fallback channel/account when direct inputs are missing", () => {
expect(
resolveMessageSecretScope({
fallbackChannel: "Signal",
fallbackAccountId: "Chat",
}),
).toEqual({
channel: "signal",
accountId: "chat",
});
});
});