Doctor: keep allowFrom account-scoped in multi-account configs

This commit is contained in:
Gustavo Madeira Santana
2026-02-26 05:31:51 -05:00
parent 97fa44dc82
commit 1ffc319831
12 changed files with 294 additions and 30 deletions

View File

@@ -2,9 +2,9 @@ import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { normalizeLegacyConfigValues } from "./doctor-legacy-config.js";
import { normalizeCompatibilityConfigValues } from "./doctor-legacy-config.js";
describe("normalizeLegacyConfigValues", () => {
describe("normalizeCompatibilityConfigValues", () => {
let previousOauthDir: string | undefined;
let tempOauthDir: string | undefined;
@@ -15,7 +15,7 @@ describe("normalizeLegacyConfigValues", () => {
const expectNoWhatsAppConfigForLegacyAuth = (setup?: () => void) => {
setup?.();
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
messages: { ackReaction: "👀", ackReactionScope: "group-mentions" },
});
expect(res.config.channels?.whatsapp).toBeUndefined();
@@ -41,7 +41,7 @@ describe("normalizeLegacyConfigValues", () => {
});
it("does not add whatsapp config when missing and no auth exists", () => {
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
messages: { ackReaction: "👀" },
});
@@ -50,7 +50,7 @@ describe("normalizeLegacyConfigValues", () => {
});
it("copies legacy ack reaction when whatsapp config exists", () => {
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
messages: { ackReaction: "👀", ackReactionScope: "group-mentions" },
channels: { whatsapp: {} },
});
@@ -91,7 +91,7 @@ describe("normalizeLegacyConfigValues", () => {
try {
writeCreds(customDir);
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
messages: { ackReaction: "👀", ackReactionScope: "group-mentions" },
channels: { whatsapp: { accounts: { work: { authDir: customDir } } } },
});
@@ -107,7 +107,7 @@ describe("normalizeLegacyConfigValues", () => {
});
it("migrates Slack dm.policy/dm.allowFrom to dmPolicy/allowFrom aliases", () => {
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
channels: {
slack: {
dm: { enabled: true, policy: "open", allowFrom: ["*"] },
@@ -125,7 +125,7 @@ describe("normalizeLegacyConfigValues", () => {
});
it("migrates Discord account dm.policy/dm.allowFrom to dmPolicy/allowFrom aliases", () => {
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
channels: {
discord: {
accounts: {
@@ -147,7 +147,7 @@ describe("normalizeLegacyConfigValues", () => {
});
it("migrates Discord streaming boolean alias to streaming enum", () => {
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
channels: {
discord: {
streaming: true,
@@ -173,7 +173,7 @@ describe("normalizeLegacyConfigValues", () => {
});
it("migrates Discord legacy streamMode into streaming enum", () => {
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
channels: {
discord: {
streaming: false,
@@ -191,7 +191,7 @@ describe("normalizeLegacyConfigValues", () => {
});
it("migrates Telegram streamMode into streaming enum", () => {
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
channels: {
telegram: {
streamMode: "block",
@@ -207,7 +207,7 @@ describe("normalizeLegacyConfigValues", () => {
});
it("migrates Slack legacy streaming keys to unified config", () => {
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
channels: {
slack: {
streaming: false,
@@ -226,7 +226,7 @@ describe("normalizeLegacyConfigValues", () => {
});
it("moves missing default account from single-account top-level config when named accounts already exist", () => {
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
channels: {
telegram: {
enabled: true,
@@ -264,7 +264,7 @@ describe("normalizeLegacyConfigValues", () => {
});
it("migrates browser ssrfPolicy allowPrivateNetwork to dangerouslyAllowPrivateNetwork", () => {
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
browser: {
ssrfPolicy: {
allowPrivateNetwork: true,
@@ -282,7 +282,7 @@ describe("normalizeLegacyConfigValues", () => {
});
it("normalizes conflicting browser SSRF alias keys without changing effective behavior", () => {
const res = normalizeLegacyConfigValues({
const res = normalizeCompatibilityConfigValues({
browser: {
ssrfPolicy: {
allowPrivateNetwork: true,