mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 17:44:33 +00:00
Doctor: keep allowFrom account-scoped in multi-account configs
This commit is contained in:
@@ -99,3 +99,72 @@ describe("resolveTelegramAccount", () => {
|
||||
expect(lines).toContain("resolve { accountId: 'work', enabled: true, tokenSource: 'config' }");
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveTelegramAccount allowFrom precedence", () => {
|
||||
it("prefers accounts.default allowlists over top-level for default account", () => {
|
||||
const resolved = resolveTelegramAccount({
|
||||
cfg: {
|
||||
channels: {
|
||||
telegram: {
|
||||
allowFrom: ["top"],
|
||||
groupAllowFrom: ["top-group"],
|
||||
accounts: {
|
||||
default: {
|
||||
botToken: "123:default",
|
||||
allowFrom: ["default"],
|
||||
groupAllowFrom: ["default-group"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
accountId: "default",
|
||||
});
|
||||
|
||||
expect(resolved.config.allowFrom).toEqual(["default"]);
|
||||
expect(resolved.config.groupAllowFrom).toEqual(["default-group"]);
|
||||
});
|
||||
|
||||
it("falls back to top-level allowlists for named account without overrides", () => {
|
||||
const resolved = resolveTelegramAccount({
|
||||
cfg: {
|
||||
channels: {
|
||||
telegram: {
|
||||
allowFrom: ["top"],
|
||||
groupAllowFrom: ["top-group"],
|
||||
accounts: {
|
||||
work: { botToken: "123:work" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
accountId: "work",
|
||||
});
|
||||
|
||||
expect(resolved.config.allowFrom).toEqual(["top"]);
|
||||
expect(resolved.config.groupAllowFrom).toEqual(["top-group"]);
|
||||
});
|
||||
|
||||
it("does not inherit default account allowlists for named account when top-level is absent", () => {
|
||||
const resolved = resolveTelegramAccount({
|
||||
cfg: {
|
||||
channels: {
|
||||
telegram: {
|
||||
accounts: {
|
||||
default: {
|
||||
botToken: "123:default",
|
||||
allowFrom: ["default"],
|
||||
groupAllowFrom: ["default-group"],
|
||||
},
|
||||
work: { botToken: "123:work" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
accountId: "work",
|
||||
});
|
||||
|
||||
expect(resolved.config.allowFrom).toBeUndefined();
|
||||
expect(resolved.config.groupAllowFrom).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user