返回 DeepSeek-Reasonix
shell_policy_test.go
根目录 / internal / sandbox / shell_policy_test.go
1 package sandbox
2
3 import "testing"
4
5 func TestWindowsShellPolicy(t *testing.T) {
6 for _, goos := range []string{"windows", "darwin", "linux"} {
7 for _, mode := range []string{"enforce", "off", ""} {
8 for _, readOnly := range []bool{false, true} {
9 for _, kind := range []ShellKind{ShellBash, ShellSh, ShellZsh, ShellPowerShell} {
10 spec := Spec{Mode: mode, ReadOnly: readOnly}
11 err := validateShellPolicy(goos, spec, Shell{Kind: kind, Path: "explicit-wrapper"})
12 wantDenied := goos == "windows" && mode == "enforce" && kind != ShellPowerShell
13 if (err != nil) != wantDenied {
14 t.Fatalf("%s %s readOnly=%v %s: err=%v", goos, mode, readOnly, kind, err)
15 }
16 }
17 }
18 }
19 }
20 }
21
21 lines GO