package checks import ( "bytes" "context" "os" "os/exec" "path/filepath" "testing" "amadan.net/oficina/equipo/internal/runner/provider" "amadan.net/oficina/equipo/internal/testci" ) func TestSandboxDisablesDetachedHelpers(t *testing.T) { root := t.TempDir() work := filepath.Join(root, "work") must(t, os.Mkdir(work, 0700)) testci.Tools(t, "codex", "bwrap", "python3", "sh") binary, err := exec.LookPath("codex") must(t, err) s, err := NewCodexSandbox(context.Background(), testSandboxConfig(t, binary, root)) must(t, err) policy := provider.ReadPolicy{ConfigHash: "policy", DeniedPaths: []string{filepath.Join(root, "secret")}} for _, tc := range []struct{ name, script string }{ {"telemetry", `test "$GOTELEMETRY" = off && test "$(go env GOTELEMETRY)" = off`}, {"maintenance", `test "$(git config --get maintenance.auto)" = false`}, {"gc", `test "$(git config --get gc.autoDetach)" = false`}, } { t.Run(tc.name, func(t *testing.T) { var out, stderr bytes.Buffer code, err := s.Run(context.Background(), Command{Argv: []string{"/bin/sh", "-c", tc.script}, Dir: ".", TimeoutSeconds: 10}, work, policy, &out, &stderr) must(t, err) if code != 0 { t.Fatalf("detached helper guard missing: code=%d out=%s err=%s", code, &out, &stderr) } }) } }