Merge remote-tracking branch 'origin/plan-2b' into plan-3
17 files changed,
+450
−64
docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md+111 −0internal/equipo/app.go+4 −2internal/equipo/runner_api.go+15 −1internal/equipotest/preparation_integration_test.go+7 −0internal/equipotest/release_test.go+41 −16internal/equipotest/runner_csrf_test.go+77 −0internal/equipotest/runner_release_test.go+37 −35internal/runner/checks/ci_fixture_test.go+11 −0internal/runner/checks/containment_test.go+51 −1internal/runner/checks/executor.go+4 −0internal/runner/checks/namespace.go+26 −5internal/runner/direct_workflow.go+1 −1internal/runner/events.go+17 −0internal/runner/journal_test.go+34 −0internal/runner/provider/check_policy.go+2 −2internal/runner/workspace/workspace.go+1 −1internal/runner/workspace/workspace_test.go+11 −0
CI failed — run details
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md| index e5849d16..216e2cff 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md |
| @@ -24508,3 +24508,114 @@ Both exited 0. Reference output: `reference scan: 535 text files, 972 matches, 0 |
| Commit subject: `feat: drive live certification and split the tool proxy helper`. |
| The task remains NEEDS_CONTEXT for the unresolved certification cases above. Production tuples remain disabled. |
| + |
| +## CI fix 2 A/B (2026-11-03) |
| + |
| +Translated host denies to mounted namespace paths; kept pin/symlink/overlap refusals and rejected host `/tmp` itself. Preserved baseline stderr and preparation causes. Release tests copy the tracked tree and share synthetic certification fixtures. Isolated verification also exposed the 128-event completion race; completion now drains all pending batches, retaining failed receipts. |
| + |
| +RED commands and results: |
| + |
| +```sh |
| +python3 - <<'PY_REPRO' |
| +import tempfile, subprocess, os |
| +with tempfile.TemporaryDirectory(prefix='e2b-ci.', dir='/tmp') as t: |
| + r = subprocess.run(['go', 'test', './internal/runner', '-run', '^TestDirectBugWorkflow$', '-count=1'], env={**os.environ, 'TMPDIR': t, 'CGO_ENABLED': '0'}) |
| + raise SystemExit(r.returncode) |
| +PY_REPRO |
| +# Initial provider_contract; diagnostic exposed missing /newroot/tmp/... bind mask. |
| +CGO_ENABLED=0 go test ./internal/runner/checks -run '^TestCheckNamespaceHostTmp$' -count=1 |
| +# Exit 1: inner bwrap bind mask failed. |
| +CGO_ENABLED=0 go test ./internal/runner/checks -run '^TestCheckFailureDiagnostic$' -count=1 |
| +# Exit 1: missing check diagnostic: provider_contract. |
| +CGO_ENABLED=0 go test ./internal/runner/workspace ./internal/runner/checks -run '^(TestPreparationDiagnostic|TestCheckCacheRejectsBroadHome)$' -count=1 |
| +# Exit 1: preparation lost cause; broad /tmp module cache accepted. |
| +CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseStampContract$' -count=1 |
| +# Exit 1: scripts/runner-release-check.py missing. |
| +CGO_ENABLED=0 go test ./internal/runner -run '^TestRunnerEventDrainBacklog$' -count=1 |
| +# Exit 1: uploaded=128; failure in last batch lost. |
| +``` |
| + |
| +Final GREEN commands and results (all exit 0): |
| + |
| +```sh |
| +CGO_ENABLED=0 TMPDIR=/tmp/e2b-ci.s4eaq7eh go test ./internal/runner -run '^TestDirectBugWorkflow$' -count=1 |
| +# ok amadan.net/oficina/equipo/internal/runner 23.886s |
| +CGO_ENABLED=0 TMPDIR=/tmp/e2b-ci.s4eaq7eh go test ./internal/equipotest -run '^(TestBugPreparationIntegration|TestBugPreparationCrashRealProtocolLocalGit|TestRunnerDirectEndToEnd|TestReleaseStampContract)$' -count=1 |
| +# ok amadan.net/oficina/equipo/internal/equipotest 36.346s |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/runner ./internal/equipotest -run '^(TestDirectBugWorkflow|TestBugPreparationIntegration|TestBugPreparationCrashRealProtocolLocalGit|TestRunnerDirectEndToEnd|TestReleaseStampContract|TestRunnerEventDrainBacklog)$' -count=1 |
| +# ok amadan.net/oficina/equipo/internal/runner 74.820s; ok amadan.net/oficina/equipo/internal/equipotest 47.904s |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/runner/checks ./internal/runner/workspace ./internal/runner/containment -run '^(TestPreparationDiagnostic|TestCheckFailureDiagnostic|TestCheckNamespaceHostTmp|TestCheckNamespaceDeniedHostAliases|TestCheckNamespaceDeniedMountAliases|TestCheckNamespaceGoRootInsideModuleCache|TestCheckCacheRejectsBroadHome|TestCheckCacheRejectsNamespaceScratch|TestCheckCacheRejectsSymlinkPathDiagnostic|TestCheckCacheIsolation|TestNamespacePinnedMountSwap|TestNamespaceRejectsBroadWorkspace|TestNamespaceMountEscape)$' -count=1 |
| +# ok amadan.net/oficina/equipo/internal/runner/checks 13.138s; ok amadan.net/oficina/equipo/internal/runner/workspace 0.040s; ok amadan.net/oficina/equipo/internal/runner/containment 0.062s |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go vet ./... |
| +# no output |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b git diff --check |
| +# no output |
| +``` |
| + |
| +Mutations, each compiled, failed the named test, then restored: |
| + |
| +```sh |
| +# M1-host-path-regression: internal/runner/checks/namespace.go; --- FAIL: TestCheckNamespaceHostTmp (1.24s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/runner/checks ./internal/equipotest -run '^(TestCheckNamespaceHostTmp|TestBugPreparationHostTmp)$' -count=1 |
| +# M2-ancestor-deny: internal/runner/checks/namespace.go; --- FAIL: TestCheckNamespaceDeniedHostAliases (1.17s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/runner/checks -run '^TestCheckNamespaceDeniedHostAliases$/ancestor$' -count=1 |
| +# M3-canonical-deny: internal/runner/checks/namespace.go; --- FAIL: TestCheckNamespaceDeniedHostAliases (0.97s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/runner/checks -run '^TestCheckNamespaceDeniedHostAliases$/symlink$' -count=1 |
| +# M4-mounted-child-deny: internal/runner/checks/namespace.go; --- FAIL: TestCheckNamespaceDeniedMountAliases (1.23s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/runner/checks -run '^TestCheckNamespaceDeniedMountAliases$' -count=1 |
| +# M5-broad-tmp: internal/runner/provider/check_policy.go; --- FAIL: TestCheckCacheRejectsBroadHome (0.00s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/runner/checks -run '^TestCheckCacheRejectsBroadHome$' -count=1 |
| +# M6-check-diagnostic: internal/runner/checks/executor.go; --- FAIL: TestCheckFailureDiagnostic (0.16s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/runner/checks -run '^TestCheckFailureDiagnostic$' -count=1 |
| +# M7-preparation-diagnostic: internal/runner/workspace/workspace.go; --- FAIL: TestPreparationDiagnostic (0.03s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/runner/workspace -run '^TestPreparationDiagnostic$' -count=1 |
| +# M8-release-input: internal/equipotest/release_test.go; --- FAIL: TestReleaseStampContract (0.23s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/equipotest -run '^TestReleaseStampContract$/defaults$' -count=1 |
| +# M9-versioned-release-name: Makefile; --- FAIL: TestReleaseStampContract (0.27s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/equipotest -run '^TestReleaseStampContract$/defaults$' -count=1 |
| +# M13-event-drain-batches: internal/runner/events.go; --- FAIL: TestRunnerEventDrainBacklog (8.11s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/runner -run '^TestRunnerEventDrainBacklog$' -count=1 |
| +# M14-event-drain-upload-failure: internal/runner/events.go; --- FAIL: TestRunnerEventDrainBacklog (3.99s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/runner -run '^TestRunnerEventDrainBacklog$/true$' -count=1 |
| +# M15-terminal-drain-call: internal/runner/direct_workflow.go; --- FAIL: TestDirectBugWorkflow (9.64s) |
| +CGO_ENABLED=0 TMPDIR=/tmp/e2b-ci.jpfjpa3w go test ./internal/runner -run '^TestDirectBugWorkflow$' -count=1 |
| +``` |
| + |
| +Full cause analysis, exact `/tmp` wrapper, mutation edits/output, copy inventory and cleanup: `.superpowers/sdd/2026-11-03-equipo-plan-2b-direct/ci-fix2-report.md`. No live gate or push. |
| + |
| +## CI fix 2 C (2026-11-03) |
| + |
| +Derived exact CSRF exemptions from the registered runner router. Real `AppWithExecution` coverage checks every runner POST, a valid originless heartbeat, runner cookie refusal, ordinary form CSRF and existing enrolment exemptions. Audited non-browser POST clients: only runner HTTP and enrolment target this app; no cookie route was exempted. |
| + |
| +RED commands and results: |
| + |
| +```sh |
| +CGO_ENABLED=0 go test ./internal/equipotest -run '^TestRunnerAppCSRF$' -count=1 |
| +# Exit 1: all runner POSTs refused by cookie CSRF (403). |
| +``` |
| + |
| +Final GREEN commands and results (all exit 0): |
| + |
| +```sh |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/equipo ./internal/equipotest -run 'TestRunnerAppCSRF|TestRunner|TestReleaseStampContract|TestDirectReleaseRequiresCertification|TestBugPreparationHostTmp' -count=1 |
| +# ok amadan.net/oficina/equipo/internal/equipo 0.053s; ok amadan.net/oficina/equipo/internal/equipotest 53.678s |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go vet ./... |
| +# no output |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b git diff --check |
| +# no output |
| +``` |
| + |
| +Mutations, each compiled, failed the named test, then restored: |
| + |
| +```sh |
| +# M10-runner-exemption: internal/equipo/runner_api.go; --- FAIL: TestRunnerAppCSRF (0.42s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/equipotest -run '^TestRunnerAppCSRF$' -count=1 |
| +# M11-form-csrf: internal/equipo/app.go; --- FAIL: TestRunnerAppCSRF (0.40s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/equipotest -run '^TestRunnerAppCSRF$' -count=1 |
| +# M12-runner-cookie-auth: internal/equipo/runner_api.go; --- FAIL: TestRunnerAppCSRF (0.58s) |
| +CGO_ENABLED=0 TMPDIR=/home/paulca/t/e2b go test ./internal/equipotest -run '^TestRunnerAppCSRF$' -count=1 |
| +``` |
| + |
| +The first form-CSRF mutation survived the original status-only check; requiring the middleware response made it fail. |
| + |
| +Full cause analysis, exact `/tmp` wrapper, mutation edits/output, copy inventory and cleanup: `.superpowers/sdd/2026-11-03-equipo-plan-2b-direct/ci-fix2-report.md`. No live gate or push. |
diff --git a/internal/equipo/app.go b/internal/equipo/app.go| index 172f25f5..f782cc99 100644 |
| --- a/internal/equipo/app.go |
| +++ b/internal/equipo/app.go |
| @@ -143,10 +143,12 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg |
| } |
| } |
| a.Use(a.live.Middleware) |
| - a.Use(csrf.Protect(cfg.Origin, csrf.Exempt("/api/enrolments", "/api/enrolments/token"))) |
| + runner := a.store.runnerRouter() |
| + exempt := append([]string{"/api/enrolments", "/api/enrolments/token"}, runnerCSRFExemptPaths(runner)...) |
| + a.Use(csrf.Protect(cfg.Origin, csrf.Exempt(exempt...))) |
| a.Post("/api/enrolments", a.beginEnrolment) |
| a.Post("/api/enrolments/token", a.exchangeEnrolment) |
| - a.Mount("/api/runner/v2", a.store.RunnerHandler()) |
| + a.Mount("/api/runner/v2", runner) |
| a.Get("/signin", func(w http.ResponseWriter, r *http.Request) { renderSignin(a.auth, w, r) }) |
| a.Post("/auth/begin", a.auth.Begin) |
| a.Get("/auth/callback", a.auth.Callback) |
diff --git a/internal/equipo/runner_api.go b/internal/equipo/runner_api.go| index ef676b01..afd81233 100644 |
| --- a/internal/equipo/runner_api.go |
| +++ b/internal/equipo/runner_api.go |
| @@ -13,7 +13,9 @@ import ( |
| // RunnerHandler exposes only outbound runner protocol endpoints. Normal app |
| // construction leaves execution unattached and these endpoints fail closed. |
| -func (s *Store) RunnerHandler() http.Handler { |
| +func (s *Store) RunnerHandler() http.Handler { return s.runnerRouter() } |
| + |
| +func (s *Store) runnerRouter() chi.Router { |
| r := chi.NewRouter() |
| r.Post("/poll", s.runnerPoll) |
| r.Post("/blobs", s.runnerPutBlob) |
| @@ -28,6 +30,18 @@ func (s *Store) RunnerHandler() http.Handler { |
| r.Get("/artifacts/{assignment}/{artifact}", s.runnerArtifact) |
| return r |
| } |
| +func runnerCSRFExemptPaths(r chi.Routes) []string { |
| + var paths []string |
| + // Use the registered bearer routes so additions inherit the exemption. |
| + _ = chi.Walk(r, func(method, route string, _ http.Handler, _ ...func(http.Handler) http.Handler) error { |
| + if method != http.MethodGet && method != http.MethodHead && method != http.MethodOptions { |
| + paths = append(paths, "/api/runner/v2"+route) |
| + } |
| + return nil |
| + }) |
| + return paths |
| +} |
| + |
| func runnerBody(w http.ResponseWriter, r *http.Request, v any, limit int64) bool { |
| content, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) |
| if err != nil || content != "application/json" || runnerproto.DecodeLimit(r.Body, v, limit) != nil { |
diff --git a/internal/equipotest/preparation_integration_test.go b/internal/equipotest/preparation_integration_test.go| index 906eb859..168a5e39 100644 |
| --- a/internal/equipotest/preparation_integration_test.go |
| +++ b/internal/equipotest/preparation_integration_test.go |
| @@ -33,6 +33,13 @@ func (r preparationRemote) Resolve(context.Context, string) (workspace.Remote, e |
| } |
| func TestBugPreparationCrashRealProtocolLocalGit(t *testing.T) { runPreparationSupervisor(t, true) } |
| func TestBugPreparationIntegration(t *testing.T) { runPreparationSupervisor(t, false) } |
| +func TestBugPreparationHostTmp(t *testing.T) { |
| + root, err := os.MkdirTemp("/tmp", "equipo-prep-") |
| + executionMust(t, err) |
| + t.Cleanup(func() { os.RemoveAll(root) }) |
| + t.Setenv("TMPDIR", root) |
| + runPreparationSupervisor(t, false) |
| +} |
| func runPreparationSupervisor(t *testing.T, crash bool) { |
| f := bugFixture(t) |
| task := bugTask(t, f) |
diff --git a/internal/equipotest/release_test.go b/internal/equipotest/release_test.go| index b895c211..868cdd2d 100644 |
| --- a/internal/equipotest/release_test.go |
| +++ b/internal/equipotest/release_test.go |
| @@ -11,10 +11,6 @@ import ( |
| ) |
| func TestReleaseStampContract(t *testing.T) { |
| - makefile, err := os.ReadFile("../../Makefile") |
| - if err != nil { |
| - t.Fatal(err) |
| - } |
| for _, tc := range []struct { |
| name, arch, dirty string |
| args []string |
| @@ -29,27 +25,31 @@ func TestReleaseStampContract(t *testing.T) { |
| } { |
| t.Run(tc.name, func(t *testing.T) { |
| dir := t.TempDir() |
| - bin := filepath.Join(dir, "bin") |
| - if err := os.Mkdir(bin, 0700); err != nil { |
| - t.Fatal(err) |
| - } |
| + copyReleaseTrackedTree(t, dir) |
| + bin := t.TempDir() |
| write := func(name, contents string, mode os.FileMode) { |
| t.Helper() |
| if err := os.WriteFile(filepath.Join(dir, name), []byte(contents), mode); err != nil { |
| t.Fatal(err) |
| } |
| } |
| - write("Makefile", string(makefile), 0600) |
| write("tracked", "original\n", 0600) |
| - write("bin/go", `#!/bin/sh |
| + writeBin := func(name, contents string) { |
| + t.Helper() |
| + executionMust(t, os.WriteFile(filepath.Join(bin, name), []byte(contents), 0700)) |
| + } |
| + writeBin("go", `#!/bin/sh |
| set -eu |
| if [ "$1" = test ]; then exit 0; fi |
| printf '%s\n' "CGO_ENABLED=$CGO_ENABLED" "GOOS=$GOOS" "GOARCH=$GOARCH" "$@" > "$RELEASE_CAPTURE" |
| -`, 0700) |
| +`) |
| // Catch an accidental deployment without invoking the real CLI. |
| - write("bin/carlos", "#!/bin/sh\ntouch \"$RELEASE_DEPLOYED\"\nexit 1\n", 0700) |
| - capture := filepath.Join(dir, "go.args") |
| - deployed := filepath.Join(dir, "carlos.called") |
| + writeBin("carlos", "#!/bin/sh\ntouch \"$RELEASE_DEPLOYED\"\nexit 1\n") |
| + writeBin("codex", "#!/bin/sh\necho 'codex-cli 0.165.0'\n") |
| + writeBin("bwrap", "#!/bin/sh\necho 'bubblewrap 0.11.0'\n") |
| + installed := releaseCertificationFixture(t, dir, bin, "clean") |
| + capture := filepath.Join(bin, "go.args") |
| + deployed := filepath.Join(bin, "carlos.called") |
| // Isolate Git and Make from the caller's repository and overrides. |
| env := []string{ |
| "PATH=" + bin + string(os.PathListSeparator) + os.Getenv("PATH"), |
| @@ -57,6 +57,7 @@ printf '%s\n' "CGO_ENABLED=$CGO_ENABLED" "GOOS=$GOOS" "GOARCH=$GOARCH" "$@" > "$ |
| "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null", |
| "RELEASE_CAPTURE=" + capture, "RELEASE_DEPLOYED=" + deployed, |
| } |
| + env = append(env, installed...) |
| run := func(name string, args ...string) ([]byte, error) { |
| cmd := exec.Command(name, args...) |
| cmd.Dir, cmd.Env = dir, env |
| @@ -73,7 +74,7 @@ printf '%s\n' "CGO_ENABLED=$CGO_ENABLED" "GOOS=$GOOS" "GOARCH=$GOARCH" "$@" > "$ |
| git("init", "--quiet") |
| git("config", "user.name", "Release test") |
| git("config", "user.email", "release@example.invalid") |
| - git("add", "Makefile", "tracked") |
| + git("add", "--force", ".") |
| git("commit", "--quiet", "-m", "Release fixture") |
| commit := git("rev-parse", "--short", "HEAD") |
| if tc.dirty != "" { |
| @@ -133,7 +134,7 @@ printf '%s\n' "CGO_ENABLED=$CGO_ENABLED" "GOOS=$GOOS" "GOARCH=$GOARCH" "$@" > "$ |
| if got := strings.Fields(strings.ReplaceAll(ldflags, "'", "")); !reflect.DeepEqual(got, wantFlags) { |
| t.Errorf("linker flags = %q, want %q", got, wantFlags) |
| } |
| - wantOutput := "releases/equipo-linux-" + tc.arch |
| + wantOutput := "releases/equipo-linux-" + tc.arch + "-" + commit |
| if output != wantOutput || source != "./cmd/equipo" { |
| t.Errorf("output/source = %q/%q, want %q/./cmd/equipo", output, source, wantOutput) |
| } |
| @@ -144,3 +145,27 @@ printf '%s\n' "CGO_ENABLED=$CGO_ENABLED" "GOOS=$GOOS" "GOARCH=$GOARCH" "$@" > "$ |
| }) |
| } |
| } |
| + |
| +func copyReleaseTrackedTree(t *testing.T, dest string) { |
| + t.Helper() |
| + root, err := filepath.Abs("../..") |
| + executionMust(t, err) |
| + cmd := exec.Command("git", "-C", root, "ls-files", "-z") |
| + files, err := cmd.Output() |
| + executionMust(t, err) |
| + for _, name := range strings.Split(strings.TrimSuffix(string(files), "\x00"), "\x00") { |
| + source, target := filepath.Join(root, name), filepath.Join(dest, name) |
| + info, err := os.Lstat(source) |
| + executionMust(t, err) |
| + executionMust(t, os.MkdirAll(filepath.Dir(target), 0700)) |
| + if info.Mode()&os.ModeSymlink != 0 { |
| + link, err := os.Readlink(source) |
| + executionMust(t, err) |
| + executionMust(t, os.Symlink(link, target)) |
| + continue |
| + } |
| + raw, err := os.ReadFile(source) |
| + executionMust(t, err) |
| + executionMust(t, os.WriteFile(target, raw, info.Mode().Perm())) |
| + } |
| +} |
diff --git a/internal/equipotest/runner_csrf_test.go b/internal/equipotest/runner_csrf_test.go| new file mode 100644 |
| index 00000000..756f4dc7 |
| --- /dev/null |
| +++ b/internal/equipotest/runner_csrf_test.go |
| @@ -0,0 +1,77 @@ |
| +package equipotest |
| + |
| +import ( |
| + "net/http" |
| + "net/http/httptest" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo" |
| + "github.com/go-chi/chi/v5" |
| +) |
| + |
| +func TestRunnerAppCSRF(t *testing.T) { |
| + f := runnerFixtureNew(t, false) |
| + token := runnerBearerFor(t, f) |
| + cfg := testConfig(testOrigin) |
| + cfg.ExecutionEnabled = true |
| + app, err := equipo.AppWithExecution(f.d, cfg, &capturingMailer{}, nil, f.x) |
| + executionMust(t, err) |
| + request := func(path, body, bearer, cookie, origin string) *httptest.ResponseRecorder { |
| + t.Helper() |
| + req := httptest.NewRequest(http.MethodPost, path, strings.NewReader(body)) |
| + req.Header.Set("Content-Type", "application/json") |
| + if bearer != "" { |
| + req.Header.Set("Authorization", "Bearer "+bearer) |
| + } |
| + if cookie != "" { |
| + req.Header.Set("Cookie", cookie) |
| + } |
| + if origin != "" { |
| + req.Header.Set("Origin", origin) |
| + } |
| + response := httptest.NewRecorder() |
| + app.ServeHTTP(response, req) |
| + return response |
| + } |
| + executionMust(t, chi.Walk(f.s.RunnerHandler().(chi.Routes), func(method, route string, _ http.Handler, _ ...func(http.Handler) http.Handler) error { |
| + if method != http.MethodPost { |
| + return nil |
| + } |
| + t.Run(route, func(t *testing.T) { |
| + response := request("/api/runner/v2"+route, "{", token, "", "") |
| + if response.Code != http.StatusUnprocessableEntity || !strings.Contains(response.Body.String(), "form.invalid") { |
| + t.Fatalf("bearer request blocked before runner body validation: %d %s", response.Code, response.Body) |
| + } |
| + for _, bearer := range []string{"", token} { |
| + response = request("/api/runner/v2"+route, "{}", bearer, "rastrillo_session=browser", "") |
| + if response.Code != http.StatusForbidden || !strings.Contains(response.Body.String(), "form.forbidden") { |
| + t.Fatalf("cookie request bypassed runner authentication: %d %s", response.Code, response.Body) |
| + } |
| + } |
| + }) |
| + return nil |
| + })) |
| + t.Run("heartbeat", func(t *testing.T) { |
| + response := request("/api/runner/v2/heartbeat", `{"version":2,"request_id":"csrf-heartbeat"}`, token, "", "") |
| + if response.Code != http.StatusOK { |
| + t.Fatalf("heartbeat: %d %s", response.Code, response.Body) |
| + } |
| + }) |
| + for _, path := range []string{"/projects", "/auth/begin", "/runners/enrol", "/api/runner/v2/poll/extra"} { |
| + t.Run("browser"+path, func(t *testing.T) { |
| + response := request(path, "{}", "", "rastrillo_session=browser", "https://other.example") |
| + if response.Code != http.StatusForbidden || !strings.Contains(response.Body.String(), "cross-origin form submission refused") { |
| + t.Fatalf("cross-origin form accepted: %d %s", response.Code, response.Body) |
| + } |
| + }) |
| + } |
| + for _, path := range []string{"/api/enrolments", "/api/enrolments/token"} { |
| + t.Run(path, func(t *testing.T) { |
| + response := request(path, "{", "", "", "") |
| + if response.Code != http.StatusUnprocessableEntity { |
| + t.Fatalf("device client blocked: %d %s", response.Code, response.Body) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/equipotest/runner_release_test.go b/internal/equipotest/runner_release_test.go| index 132171f4..20062b97 100644 |
| --- a/internal/equipotest/runner_release_test.go |
| +++ b/internal/equipotest/runner_release_test.go |
| @@ -69,12 +69,7 @@ func runnerPackagingScenarios(t *testing.T, target string, scenarios []string) { |
| root := t.TempDir() |
| bin := filepath.Join(root, "bin") |
| executionMust(t, os.Mkdir(bin, 0700)) |
| - for _, name := range []string{"Makefile", "packaging/equipo-runner.service", "internal/release/manifest.json", "scripts/runner-release-check.py", "internal/runner/provider/direct_requirements.json", "internal/runner/provider/claude/launcher.go", "internal/runner/provider/codex/launcher.go"} { |
| - raw, err := os.ReadFile("../../" + name) |
| - executionMust(t, err) |
| - executionMust(t, os.MkdirAll(filepath.Dir(filepath.Join(root, name)), 0700)) |
| - executionMust(t, os.WriteFile(filepath.Join(root, name), raw, 0600)) |
| - } |
| + copyReleaseTrackedTree(t, root) |
| scripts := map[string]string{ |
| "git": "#!/bin/sh\ncase \"$1\" in diff) [ \"$SCENARIO\" != dirty ];; rev-parse) echo abc1234;; ls-files) if [ \"$SCENARIO\" = untracked ]; then echo unsafe.go; fi;; esac\n", |
| "go": "#!/bin/sh\ncase \"$1\" in test) [ \"$SCENARIO\" != copy ];; build) printf '%s\\n' \"$GOOS/$GOARCH\" \"$@\" > \"$CAPTURE\"; while [ $# -gt 0 ]; do if [ \"$1\" = -o ]; then shift; cp \"$EQUIPO_TOOL_PROXY_PATH\" \"$1\"; fi; shift; done;; esac\n", |
| @@ -86,35 +81,7 @@ func runnerPackagingScenarios(t *testing.T, target string, scenarios []string) { |
| for name, script := range scripts { |
| executionMust(t, os.WriteFile(filepath.Join(bin, name), []byte(script), 0700)) |
| } |
| - var fixture release.Manifest |
| - rawManifest, err := os.ReadFile(filepath.Join(root, "internal/release/manifest.json")) |
| - executionMust(t, err) |
| - executionMust(t, json.Unmarshal(rawManifest, &fixture)) |
| - fixture.Binaries = nil |
| - var installed []string |
| - for name, version := range map[string]string{"claude": fixture.Claude, "codex": fixture.Codex, "codex-code-mode-host": fixture.Codex, "bwrap": fixture.BwrapVersion, "equipo-tool-proxy": fixture.LauncherVersion} { |
| - path := filepath.Join(bin, name) |
| - if name != "codex" && name != "bwrap" { |
| - executionMust(t, os.WriteFile(path, []byte("#!/bin/sh\nexit 0\n"), 0700)) |
| - } |
| - raw, err := os.ReadFile(path) |
| - executionMust(t, err) |
| - digest := fmt.Sprintf("%x", sha256.Sum256(raw)) |
| - fixture.Binaries = append(fixture.Binaries, release.BinaryDigest{Name: name, Version: version, SHA256: digest}) |
| - variable := map[string]string{"claude": "EQUIPO_CLAUDE_PATH", "codex": "EQUIPO_CODEX_PATH", "codex-code-mode-host": "EQUIPO_CODEX_CODE_MODE_HOST_PATH", "bwrap": "EQUIPO_BWRAP_PATH", "equipo-tool-proxy": "EQUIPO_TOOL_PROXY_PATH"}[name] |
| - installed = append(installed, variable+"="+path) |
| - } |
| - for _, name := range []string{"claude", "codex"} { |
| - version := fixture.Claude |
| - if name == "codex" { |
| - version = fixture.Codex |
| - } |
| - fixture.DirectPolicies = append(fixture.DirectPolicies, release.PolicyCertificate{Provider: name, ProviderVersion: version, LauncherVersion: fixture.LauncherVersion, BwrapVersion: fixture.BwrapVersion, PolicyHash: strings.Repeat("a", 64)}) |
| - } |
| - installCertificationFixture(t, root, &fixture, scenario) |
| - bytes, err := json.Marshal(fixture) |
| - executionMust(t, err) |
| - executionMust(t, os.WriteFile(filepath.Join(root, "internal/release/manifest.json"), bytes, 0600)) |
| + installed := releaseCertificationFixture(t, root, bin, scenario) |
| if scenario == "helper" { |
| executionMust(t, os.Remove(filepath.Join(bin, "codex-code-mode-host"))) |
| } |
| @@ -269,3 +236,38 @@ func installCertificationFixture(t *testing.T, root string, m *release.Manifest, |
| m.VerifiedIsolationTuples[0].PolicyVersion = "changed" |
| } |
| } |
| + |
| +func releaseCertificationFixture(t *testing.T, root, bin, scenario string) []string { |
| + t.Helper() |
| + var fixture release.Manifest |
| + rawManifest, err := os.ReadFile(filepath.Join(root, "internal/release/manifest.json")) |
| + executionMust(t, err) |
| + executionMust(t, json.Unmarshal(rawManifest, &fixture)) |
| + fixture.Binaries = nil |
| + var installed []string |
| + for name, version := range map[string]string{"claude": fixture.Claude, "codex": fixture.Codex, "codex-code-mode-host": fixture.Codex, "bwrap": fixture.BwrapVersion, "equipo-tool-proxy": fixture.LauncherVersion} { |
| + path := filepath.Join(bin, name) |
| + if name != "codex" && name != "bwrap" { |
| + executionMust(t, os.WriteFile(path, []byte("#!/bin/sh\nexit 0\n"), 0700)) |
| + } |
| + raw, err := os.ReadFile(path) |
| + executionMust(t, err) |
| + digest := fmt.Sprintf("%x", sha256.Sum256(raw)) |
| + fixture.Binaries = append(fixture.Binaries, release.BinaryDigest{Name: name, Version: version, SHA256: digest}) |
| + variable := map[string]string{"claude": "EQUIPO_CLAUDE_PATH", "codex": "EQUIPO_CODEX_PATH", "codex-code-mode-host": "EQUIPO_CODEX_CODE_MODE_HOST_PATH", "bwrap": "EQUIPO_BWRAP_PATH", "equipo-tool-proxy": "EQUIPO_TOOL_PROXY_PATH"}[name] |
| + installed = append(installed, variable+"="+path) |
| + } |
| + for _, name := range []string{"claude", "codex"} { |
| + version := fixture.Claude |
| + if name == "codex" { |
| + version = fixture.Codex |
| + } |
| + fixture.DirectPolicies = append(fixture.DirectPolicies, release.PolicyCertificate{Provider: name, ProviderVersion: version, LauncherVersion: fixture.LauncherVersion, BwrapVersion: fixture.BwrapVersion, PolicyHash: strings.Repeat("a", 64)}) |
| + } |
| + installCertificationFixture(t, root, &fixture, scenario) |
| + bytes, err := json.Marshal(fixture) |
| + executionMust(t, err) |
| + executionMust(t, os.WriteFile(filepath.Join(root, "internal/release/manifest.json"), bytes, 0600)) |
| + |
| + return installed |
| +} |
diff --git a/internal/runner/checks/ci_fixture_test.go b/internal/runner/checks/ci_fixture_test.go| index 7f61c01e..b8c7f964 100644 |
| --- a/internal/runner/checks/ci_fixture_test.go |
| +++ b/internal/runner/checks/ci_fixture_test.go |
| @@ -1,8 +1,11 @@ |
| package checks |
| import ( |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| "context" |
| + "errors" |
| "slices" |
| + "strings" |
| "testing" |
| ) |
| @@ -27,3 +30,11 @@ func TestSharedBaselineFixtureIsolation(t *testing.T) { |
| t.Fatal("changed fixture bypassed baseline capture") |
| } |
| } |
| + |
| +func TestCheckFailureDiagnostic(t *testing.T) { |
| + f := newFixture(t) |
| + _, _, _, err := f.e.run(context.Background(), Command{Argv: []string{"/bin/sh", "-c", "echo namespace-cause >&2; exit 7"}, Dir: ".", Parser: "go-test-json", TimeoutSeconds: 10}, f.base, "") |
| + if !errors.Is(err, provider.ErrContract) || !strings.Contains(err.Error(), "namespace-cause") || !strings.Contains(err.Error(), "exit 7") { |
| + t.Fatalf("missing check diagnostic: %v", err) |
| + } |
| +} |
diff --git a/internal/runner/checks/containment_test.go b/internal/runner/checks/containment_test.go| index ae2be617..272f43e7 100644 |
| --- a/internal/runner/checks/containment_test.go |
| +++ b/internal/runner/checks/containment_test.go |
| @@ -191,7 +191,7 @@ func TestCheckCacheRejectsBroadHome(t *testing.T) { |
| if err != nil { |
| t.Fatal(err) |
| } |
| - for _, root := range []string{home, "/home", "/"} { |
| + for _, root := range []string{home, "/home", "/", "/tmp"} { |
| _, err = provider.BuildCheckPolicy(provider.CheckPolicyInputs{Workspace: t.TempDir(), Binary: "/usr/bin/true", RunnerBinary: "/usr/bin/true", Bwrap: "/usr/bin/bwrap", GoRoot: t.TempDir(), ModuleCache: root, Argv: []string{"/opt/codex"}}) |
| if err == nil { |
| t.Fatalf("broad home accepted as module cache: %s", root) |
| @@ -275,3 +275,53 @@ func TestCheckCacheRejectsSymlinkPathDiagnostic(t *testing.T) { |
| t.Fatalf("refused module cache must retain policy class and identify path %q: %v", alias, err) |
| } |
| } |
| + |
| +func TestCheckNamespaceHostTmp(t *testing.T) { |
| + root, err := os.MkdirTemp("/tmp", "equipo-check-") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { os.RemoveAll(root) }) |
| + t.Setenv("TMPDIR", root) |
| + s, work, _, policy, _ := namespaceCheck(t) |
| + policy.DeniedPaths = append(policy.DeniedPaths, filepath.Join(policy.DeniedPaths[0], "config")) |
| + var out, stderr bytes.Buffer |
| + code, err := s.Run(context.Background(), checks.Command{Argv: []string{"/usr/bin/python3", "-c", "import os; assert not os.path.exists(" + strconv.Quote(root) + "); print('check ran')"}, Dir: ".", TimeoutSeconds: 10}, work, policy, &out, &stderr) |
| + if err != nil || code != 0 || !strings.Contains(out.String(), "check ran") { |
| + t.Fatalf("host /tmp check: code=%d err=%v stdout=%s stderr=%s", code, err, &out, &stderr) |
| + } |
| +} |
| + |
| +func TestCheckNamespaceDeniedHostAliases(t *testing.T) { |
| + for _, kind := range []string{"ancestor", "symlink"} { |
| + t.Run(kind, func(t *testing.T) { |
| + var mods string |
| + s, work, _, policy, _ := namespaceCheck(t, func(cfg *checks.SandboxConfig) { |
| + cfg.ModuleCache = filepath.Join(cfg.ModuleCache, "nested") |
| + if err := os.Mkdir(cfg.ModuleCache, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + mods = cfg.ModuleCache |
| + }) |
| + if err := os.WriteFile(filepath.Join(mods, "secret"), []byte("denied-sentinel"), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + denied := filepath.Dir(mods) |
| + if kind == "symlink" { |
| + denied = filepath.Join(filepath.Dir(work), "alias") |
| + if err := os.Symlink(filepath.Join(mods, "secret"), denied); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + policy.DeniedPaths = append(policy.DeniedPaths, denied) |
| + var out, stderr bytes.Buffer |
| + code, err := s.Run(context.Background(), checks.Command{Argv: []string{"/usr/bin/cat", "/opt/go-mod/secret"}, Dir: ".", TimeoutSeconds: 10}, work, policy, &out, &stderr) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if code == 0 || strings.Contains(out.String(), "denied-sentinel") { |
| + t.Fatalf("%s deny bypassed: %s", kind, &out) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/runner/checks/executor.go b/internal/runner/checks/executor.go| index f580b017..4d5d88b7 100644 |
| --- a/internal/runner/checks/executor.go |
| +++ b/internal/runner/checks/executor.go |
| @@ -4,6 +4,7 @@ import ( |
| "bytes" |
| "context" |
| "database/sql" |
| + "fmt" |
| "io" |
| "os" |
| "path/filepath" |
| @@ -214,6 +215,9 @@ func (e *Executor) run(ctx context.Context, c Command, work, symptom string) (*g |
| } else if err == nil && code != 0 { |
| err = provider.ErrContract |
| } |
| + if err != nil { |
| + err = fmt.Errorf("%w: check %q (exit %d), stderr: %s", err, c.Argv, code, stderr.String()) |
| + } |
| return result, code, logHash, err |
| } |
| func safeDir(root, rel string) error { |
diff --git a/internal/runner/checks/namespace.go b/internal/runner/checks/namespace.go| index 8faff554..e73e0c38 100644 |
| --- a/internal/runner/checks/namespace.go |
| +++ b/internal/runner/checks/namespace.go |
| @@ -16,12 +16,33 @@ import ( |
| func (s *CodexSandbox) runNamespace(ctx context.Context, c Command, work string, policy provider.ReadPolicy, stdout, stderr io.Writer) (int, error) { |
| roots := map[string]string{":minimal": "read", "/workspace": "write", "/tmp": "write", "/opt/go": "read", "/opt/go-mod": "read", "/opt/codex": "read", "/home/runner": "deny", filepath.Join(s.home, ".cache/go-build"): "deny"} |
| + // Host paths have meaning here only through an outer mount. In particular, |
| + // host /tmp is replaced by private scratch, so missing host deny paths must |
| + // not become masks inside that scratch directory. |
| + mounts := []provider.Mount{ |
| + {Source: work, Target: "/workspace"}, |
| + {Source: s.goRoot, Target: "/opt/go"}, |
| + {Source: s.direct.ModuleCache, Target: "/opt/go-mod"}, |
| + {Source: s.binary, Target: "/opt/codex"}, |
| + {Source: s.direct.RunnerBinary, Target: "/opt/equipo-runner"}, |
| + {Source: s.direct.RunnerBinary, Target: "/equipo-namespace"}, |
| + {Source: s.direct.Bwrap, Target: "/opt/bwrap"}, |
| + {Source: "/usr", Target: "/usr"}, |
| + {Source: "/etc", Target: "/etc"}, |
| + } |
| for _, path := range append(append([]string(nil), s.protected...), policy.DeniedPaths...) { |
| - roots[path] = "deny" |
| - for _, mount := range []provider.Mount{{Source: work, Target: "/workspace"}, {Source: s.goRoot, Target: "/opt/go"}, {Source: s.direct.ModuleCache, Target: "/opt/go-mod"}} { |
| - if within(mount.Source, path) { |
| - rel, _ := filepath.Rel(mount.Source, path) |
| - roots[filepath.Join(mount.Target, rel)] = "deny" |
| + resolved, err := canonicalPath(path) |
| + if err != nil { |
| + return -1, err |
| + } |
| + for _, denied := range []string{path, resolved} { |
| + for _, mount := range mounts { |
| + if within(denied, mount.Source) { |
| + roots[mount.Target] = "deny" |
| + } else if within(mount.Source, denied) { |
| + rel, _ := filepath.Rel(mount.Source, denied) |
| + roots[filepath.Join(mount.Target, rel)] = "deny" |
| + } |
| } |
| } |
| } |
diff --git a/internal/runner/direct_workflow.go b/internal/runner/direct_workflow.go| index 45bce351..95f8934d 100644 |
| --- a/internal/runner/direct_workflow.go |
| +++ b/internal/runner/direct_workflow.go |
| @@ -246,7 +246,7 @@ func (w *BugWorkflow) directModel(ctx context.Context, s *Supervisor, r *attempt |
| return errDirectUncertain |
| } |
| // AppendDirect committed the terminal event before publishing this notice. |
| - if err = pump.Flush(ctx, 128); err != nil { |
| + if err = pump.Drain(ctx); err != nil { |
| return err |
| } |
| r.InFlightAction = 0 |
diff --git a/internal/runner/events.go b/internal/runner/events.go| index 0dcdd93d..b337540e 100644 |
| --- a/internal/runner/events.go |
| +++ b/internal/runner/events.go |
| @@ -245,3 +245,20 @@ func (p *EventPump) storageFailure(ctx context.Context, err error) error { |
| defer cancel() |
| return errors.Join(err, p.Contain(cleanup)) |
| } |
| + |
| +// Drain waits for every pending event to be acknowledged, including terminal |
| +// receipts beyond the first upload batch. A failed upload stays pending. |
| +func (p *EventPump) Drain(ctx context.Context) error { |
| + for { |
| + if err := p.Flush(ctx, 128); err != nil { |
| + return err |
| + } |
| + pending, err := p.Journal.Pending(ctx, 1) |
| + if err != nil { |
| + return p.storageFailure(ctx, err) |
| + } |
| + if len(pending) == 0 { |
| + return nil |
| + } |
| + } |
| +} |
diff --git a/internal/runner/journal_test.go b/internal/runner/journal_test.go| index 00818563..851ab29e 100644 |
| --- a/internal/runner/journal_test.go |
| +++ b/internal/runner/journal_test.go |
| @@ -390,3 +390,37 @@ func TestRunnerEventReplayRejectsMalformedBeforeRedaction(t *testing.T) { |
| t.Fatal("redaction hid malformed event") |
| } |
| } |
| + |
| +func TestRunnerEventDrainBacklog(t *testing.T) { |
| + for _, failLast := range []bool{false, true} { |
| + t.Run(fmt.Sprint(failLast), func(t *testing.T) { |
| + j, err := OpenJournal(journalCtx, filepath.Join(t.TempDir(), "private", "journal.db")) |
| + mustJournal(t, err) |
| + defer j.Close() |
| + uploaded := 0 |
| + p := EventPump{Journal: j, Contain: func(context.Context) error { return nil }, Upload: func(_ context.Context, e Event) error { |
| + if e.ID == "event-129" && failLast { |
| + return provider.ErrUncertain |
| + } |
| + uploaded++ |
| + return nil |
| + }} |
| + for i := int64(1); i <= 129; i++ { |
| + mustJournal(t, p.Append(journalCtx, journalEvent(fmt.Sprintf("event-%d", i), i), nil)) |
| + } |
| + err = p.Drain(journalCtx) |
| + if failLast { |
| + if err != provider.ErrUncertain { |
| + t.Fatalf("last batch failure lost: %v", err) |
| + } |
| + pending, err := j.Pending(journalCtx, 128) |
| + mustJournal(t, err) |
| + if len(pending) != 1 || pending[0].ID != "event-129" { |
| + t.Fatalf("failed terminal ACKed: %+v", pending) |
| + } |
| + } else if err != nil || uploaded != 129 { |
| + t.Fatalf("backlog not drained before completion: uploaded=%d err=%v", uploaded, err) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/runner/provider/check_policy.go b/internal/runner/provider/check_policy.go| index 18f09d5a..557cad2f 100644 |
| --- a/internal/runner/provider/check_policy.go |
| +++ b/internal/runner/provider/check_policy.go |
| @@ -26,8 +26,8 @@ func BuildCheckPolicy(in CheckPolicyInputs) (Policy, error) { |
| } |
| m := effectiveManifest{Version: checkPolicyVersion, Workspace: in.Workspace, Argv: in.Argv, Env: in.Env, NamespaceArgs: NamespaceArguments()} |
| for _, path := range []string{in.Workspace, in.GoRoot, in.ModuleCache} { |
| - if path == "/" || withinPath(home, path) { |
| - return Policy{}, fmt.Errorf("%w: check directory %q includes the host home", ErrPolicy, path) |
| + if path == "/" || path == "/tmp" || withinPath(home, path) { |
| + return Policy{}, fmt.Errorf("%w: check directory %q includes a broad host directory", ErrPolicy, path) |
| } |
| f, err := pinDirectory(path) |
| if err != nil { |
diff --git a/internal/runner/workspace/workspace.go b/internal/runner/workspace/workspace.go| index daab970a..128534de 100644 |
| --- a/internal/runner/workspace/workspace.go |
| +++ b/internal/runner/workspace/workspace.go |
| @@ -274,7 +274,7 @@ func (m *Manager) Prepare(ctx context.Context, target team.TargetBinding) (Prepa |
| target.BaseRevision = base |
| p, err := m.cfg.Definitions(ctx, target, repo) |
| if err != nil { |
| - return PreparedBug{}, provider.ErrContract |
| + return PreparedBug{}, fmt.Errorf("%w: preparation definition/baseline: %w", provider.ErrContract, err) |
| } |
| s := sha256.Sum256(p.CheckDefinition) |
| if len(p.CheckDefinition) == 0 || len(p.CheckDefinition) > team.MaxArtifactBytes || hex.EncodeToString(s[:]) != p.CheckDefinitionHash || len(p.BaselineTestSetHash) != 64 || !objectID.MatchString(p.BaselineTestSetHash) { |
diff --git a/internal/runner/workspace/workspace_test.go b/internal/runner/workspace/workspace_test.go| index 81f3b888..4532ad15 100644 |
| --- a/internal/runner/workspace/workspace_test.go |
| +++ b/internal/runner/workspace/workspace_test.go |
| @@ -4,6 +4,7 @@ import ( |
| "context" |
| "crypto/sha256" |
| "encoding/hex" |
| + "errors" |
| "os" |
| "os/exec" |
| "path/filepath" |
| @@ -388,3 +389,13 @@ func TestWorkspaceHasNoCredentials(t *testing.T) { |
| t.Fatal("credential URL accepted or diagnostic leaked") |
| } |
| } |
| + |
| +func TestPreparationDiagnostic(t *testing.T) { |
| + f := setup(t) |
| + cause := errors.New("baseline setup cause") |
| + f.m.cfg.Definitions = func(context.Context, team.TargetBinding, string) (PreparedBug, error) { return PreparedBug{}, cause } |
| + _, err := f.m.Prepare(ctx, f.target) |
| + if !errors.Is(err, provider.ErrContract) || !errors.Is(err, cause) || !strings.Contains(err.Error(), "preparation definition/baseline") { |
| + t.Fatalf("preparation lost cause: %v", err) |
| + } |
| +} |