Skip to content

Commit de9293a

Browse files
committed
test(goal): make unreadable archive fixture portable
Problem: The explicit legacy archive fail-closed test passed on Unix but failed on Windows because chmod zero does not make a file unreadable there. Root cause: The fixture relied on Unix permission semantics instead of creating a platform-independent archive read failure. Fix: Replace task_spec.json with a directory so archive decoding fails deterministically on every supported platform. Verification: go test ./internal/control -count=1 GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go test -c ./internal/control
1 parent a8a2a83 commit de9293a

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

internal/control/goal_legacy_restore_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -595,17 +595,16 @@ func TestMissingLegacyGoalCommandDoesNotStartProviderTurn(t *testing.T) {
595595
}
596596

597597
func TestUnreadableExplicitLegacyArchiveBlocks(t *testing.T) {
598-
if os.Geteuid() == 0 {
599-
t.Skip("root can bypass archive file permissions")
600-
}
601598
root := t.TempDir()
602599
const taskID = "unreadable-explicit-archive"
603600
taskRoot := writeLegacyGoalArchive(t, root, taskID, "never run an unreadable archive")
604601
specPath := filepath.Join(taskRoot, "state", "task_spec.json")
605-
if err := os.Chmod(specPath, 0); err != nil {
602+
if err := os.Remove(specPath); err != nil {
603+
t.Fatal(err)
604+
}
605+
if err := os.Mkdir(specPath, 0o755); err != nil {
606606
t.Fatal(err)
607607
}
608-
t.Cleanup(func() { _ = os.Chmod(specPath, 0o644) })
609608
c := New(Options{WorkspaceRoot: root})
610609
t.Cleanup(c.Close)
611610

0 commit comments

Comments
 (0)