|
| 1 | +import { checkAutoApproval } from ".." |
| 2 | + |
| 3 | +describe("Destructive Command Guard auto-approval precedence", () => { |
| 4 | + const baseState = { |
| 5 | + autoApprovalEnabled: true, |
| 6 | + alwaysAllowExecute: true, |
| 7 | + alwaysAllowReadOnly: false, |
| 8 | + alwaysAllowReadOnlyOutsideWorkspace: false, |
| 9 | + alwaysAllowWrite: false, |
| 10 | + alwaysAllowWriteOutsideWorkspace: false, |
| 11 | + alwaysAllowWriteProtected: false, |
| 12 | + alwaysAllowMcp: false, |
| 13 | + alwaysAllowModeSwitch: false, |
| 14 | + alwaysAllowSubtasks: false, |
| 15 | + alwaysAllowFollowupQuestions: false, |
| 16 | + allowedCommands: ["echo"], |
| 17 | + deniedCommands: ["rm"], |
| 18 | + alwaysAllowCommandsExceptDenied: false, |
| 19 | + destructiveCommandGuardEnabled: true, |
| 20 | + mcpServers: [], |
| 21 | + } |
| 22 | + |
| 23 | + it("ignores Zoo's deny list while DCG is enabled", async () => { |
| 24 | + expect(await checkAutoApproval({ state: baseState, ask: "command", text: "rm file" })).toEqual({ |
| 25 | + decision: "ask", |
| 26 | + }) |
| 27 | + }) |
| 28 | + |
| 29 | + it("requires explicit approval for a DCG-protected command", async () => { |
| 30 | + expect( |
| 31 | + await checkAutoApproval({ state: baseState, ask: "command", text: "echo safe", isProtected: true }), |
| 32 | + ).toEqual({ decision: "ask" }) |
| 33 | + }) |
| 34 | + |
| 35 | + it("retains ordinary allowlist auto-approval for DCG-allowed commands", async () => { |
| 36 | + expect(await checkAutoApproval({ state: baseState, ask: "command", text: "echo safe" })).toEqual({ |
| 37 | + decision: "approve", |
| 38 | + }) |
| 39 | + }) |
| 40 | +}) |
0 commit comments