//go:build linux package host import ( "net/http" "os" "os/exec" "sync/atomic" "testing" ) // TestProbeRefusesForeignPeer (Review Focus 4, ruling H12): the moves owner // set binds no readiness of its own, so the probe's readiness is the claim's // (claimProbeSocketReady) on the path Select read from the app's manifest. A // listener in this test process answers 200 on that path, but its peer is // not in the spawned process's tree: the check refuses and the app's // listener is never asked. func TestProbeRefusesForeignPeer(t *testing.T) { if (&movesProbeOwners{}).MovesOwners(&movesProbeAttempts{}).ProbeReady != nil { t.Fatal("the moves owners replace the claim's probe readiness") } group := plan9D3SelfCgroup(t) status := new(atomic.Int32) status.Store(http.StatusOK) rt, hits := plan9D3Server(t, status) spawned := exec.Command("sleep", "5") if err := spawned.Start(); err != nil { t.Fatal(err) } t.Cleanup(func() { spawned.Process.Kill(); spawned.Wait() }) if err := plan9D3Ready(t, plan9D3Cmd(t, spawned.Process.Pid), rt, "/ready", group); err == nil { t.Fatal("a peer outside the spawned tree was accepted") } if hits.Load() != 0 { t.Fatal("the foreign listener was asked") } // The same listener, answering as the spawned process, passes. if err := plan9D3Ready(t, plan9D3Cmd(t, os.Getpid()), rt, "/ready", group); err != nil { t.Fatalf("the spawned process itself: %v", err) } }