//go:build linux package host import ( "errors" "testing" "github.com/carlosframework/platform/internal/hostclaim" "github.com/carlosframework/platform/internal/hostguard" ) func TestPlan14ExecutionPreinstallationSourceGap(t *testing.T) { t.Parallel() for _, phase := range []string{hostclaim.PhaseStarting, hostclaim.PhaseReleasing, hostclaim.PhasePinning} { t.Run(phase, func(t *testing.T) { b := newParticipationBox(t) o := b.update(func(c *hostclaim.Claim) error { c.Op.Phase = phase c.Op.Exec = "src" if phase == hostclaim.PhasePinning { c.Op.Exec = "none" } return nil }) root := b.guard root.Root = hostguard.NewRootAuthority(&rollbackDisk{dir: t.TempDir()}) if _, err := root.Capture(o.Host); !errors.Is(err, hostguard.ErrNoRecord) { t.Fatalf("target unexpectedly has a root installation: %v", err) } if err := rootFirstInstallation(o.Claim, b.actor); err == nil { t.Fatal("first registration admitted before installation") } effects := RelocationEffects{Participation: b.p.Acknowledged} ack, err := effects.Acknowledge(t.Context(), o) if err != nil { t.Fatal("existing participation cannot acknowledge before installation:", err) } if ack.Op != o.Claim.Op.ID || ack.Enrollment != b.actor.Enrollment || ack.LeaseETag == "" { t.Fatalf("missing execution acknowledgement: %+v", ack) } if _, err := root.Capture(o.Host); !errors.Is(err, hostguard.ErrNoRecord) { t.Fatalf("participation fabricated a root installation: %v", err) } }) } }