| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "os" |
| 5 | "path/filepath" |
| 6 | "testing" |
| 7 | |
| 8 | "github.com/sylvinus/agent-vm/internal/cage" |
| 9 | ) |
| 10 | |
| 11 | func TestWindowsEntryDropsOpenSSHAncestorDescriptors(t *testing.T) { |
| 12 | names := []string{"OPENSSH_STDIO_MODE", "c28fc6f98a2c44abbbd89d6a3037d0d9_POSIX_FD_STATE"} |
| 13 | for _, name := range names { |
| 14 | t.Setenv(name, "ancestor-state") |
| 15 | } |
| 16 | |
| 17 | |
| 18 | t.Setenv(cage.ConfigEnv, filepath.Join(t.TempDir(), "missing.json")) |
| 19 | previous := os.Args |
| 20 | os.Args = []string{"cage", "check"} |
| 21 | t.Cleanup(func() { os.Args = previous }) |
| 22 | if code := run(); code != 1 { |
| 23 | t.Fatalf("missing configuration returned %d", code) |
| 24 | } |
| 25 | for _, name := range names { |
| 26 | if _, exists := os.LookupEnv(name); exists { |
| 27 | t.Errorf("%s survived Windows runtime initialization", name) |
| 28 | } |
| 29 | } |
| 30 | } |