//go:build testbuild package thin import ( "context" "slices" "testing" "time" "amadan.net/oficina/equipo/internal/runner/mac" "amadan.net/oficina/equipo/internal/runner/mac/fprobe" "amadan.net/oficina/equipo/internal/runner/provider" "amadan.net/oficina/equipo/internal/wire" ) // Whole-branch fix 2, #5: every candidate's object scan runs gitleaks // under the checks profile P2 proves, so a Mac is ready for Engineering // only with P2 denied: with F1 to F7 passed and P2 not run or not // denied it says so (P2 named) and carries no claude tag, so the // instance places no Engineering there. func TestMacEngineeringNeedsP2(t *testing.T) { x := newEngRig(t) h := &macHost{version: "v-test", probes: newMacProbes("v-test", "", nil, func() bool { return true }), creds: x.m, taint: x.m.taint, turns: x.m.turns} h.eng = newMacEngineering(h) sims := []wire.Simulator{{Name: "iPhone 17 Pro", Runtime: "iOS 27.2", UDID: "ABCDEF01-2345-6789-ABCD-EF0123456789", State: "Shutdown"}} xcode := wire.Xcode{Version: "27.2", Build: "27B52"} now := time.Now() h.eng.now = func() time.Time { return now } in := fprobe.NewInputs("v-test", true, xcode, sims) for _, l := range fprobe.Launches { r := fprobe.Result{Launch: l, Inputs: in, At: now} for _, id := range wire.EngineeringProbeIDs { if fprobe.LaunchOf(id) == l { r.Probes = append(r.Probes, wire.Probe{ID: id, Verdict: wire.EngineeringProbeSuccess(id), Detail: wire.ProbeDetail("f1_denied")}) } } h.eng.store.Put(r) } h.eng.bind(x.w, x.conns, nil) live := wire.Capabilities{Tags: []string{wire.TagMacOS, wire.TagXcode}, Simulators: sims, Xcode: xcode, Harness: wire.Harness{Claude: provider.ClaudeVersion}} h.eng.live = func(context.Context) wire.Capabilities { return live } compose := func() wire.Capabilities { c := live c.Tags = slices.Clone(live.Tags) h.eng.compose(&c) if err := wire.ValidCapabilities(c); err != nil { t.Fatal(err) } return c } if c := compose(); *c.Engineering != (wire.EngineeringStatus{State: wire.EngineeringProbesPending, Reason: "P2"}) || slices.Contains(c.Tags, wire.TagClaude) { t.Fatalf("P2 not run: %+v %v", c.Engineering, c.Tags) } h.probes.last = mac.Report{Version: "v-test", Profile: mac.ProfileDigest(), At: now, SRT: srtPinned, Probes: []wire.Probe{{ID: "P2", Verdict: wire.ProbeFailed}}} if c := compose(); *c.Engineering != (wire.EngineeringStatus{State: wire.EngineeringProbesFailed, Reason: "P2"}) || slices.Contains(c.Tags, wire.TagClaude) { t.Fatalf("P2 not denied: %+v %v", c.Engineering, c.Tags) } if st := h.eng.statusNow(context.Background()); st.State == wire.EngineeringReady { t.Fatalf("ready at use with P2 not denied: %+v", st) } h.probes.last.Probes[0].Verdict = wire.ProbeDenied if c := compose(); *c.Engineering != (wire.EngineeringStatus{State: wire.EngineeringReady}) || !slices.Contains(c.Tags, wire.TagClaude) { t.Fatalf("P2 denied: %+v %v", c.Engineering, c.Tags) } }