gunk-dev/the-valley

policy_test.go

sourcec4c1671e1d82main's published tip history
21.2 KiB
1package main
2
3// The policy bridge, where this program is coupled to cue and to the
4// deriver: the policy cue composes, with the window a check writes down
5// and the digest of the whole, and what the deriver makes of a diff under
6// it. Both are pinned here rather than assumed.
7
8import (
9 "the-valley/composed"
10 "the-valley/integrator/verdict"
11
12 "context"
13 "errors"
14 "os"
15 "os/exec"
16 "path/filepath"
17 "reflect"
18 "slices"
19 "strings"
20 "testing"
21 "time"
22)
23
24// derivationFloor is a floor of two classes and an `unclassified` set. A
25// code path requires c-build and sets c-vm due without requiring it; a
26// docs path requires c-docs; a path neither covers requires c-smoke, an
27// effectful check.
28const derivationFloor = `package verification
29floor: {
30 checks: {
31 "c-build": {runner: "nix", attribute: "c-build"}
32 "c-docs": {runner: "nix", attribute: "c-docs"}
33 "c-vm": {runner: "nix", attribute: "c-vm"}
34 "c-smoke": {runner: "command", command: "true", validity: "1h"}
35 }
36 classes: {
37 code: {paths: "src/**": true, requires: "c-build": true, follows: "c-vm": true, carry: exact: true}
38 docs: {paths: "docs/**": true, requires: "c-docs": true, carry: "same-class": true}
39 }
40 unclassified: "c-smoke": true
41}
42`
43
44// policyRig is a target repository whose policy is derivationFloor and,
45// when given, a project layer of its own, composed by real cue under the
46// real schema.
47type policyRig struct {
48 *scratchRepo
49 source policySource
50}
51
52func newPolicyRig(t *testing.T, project string) *policyRig {
53 t.Helper()
54 cue, err := exec.LookPath("cue")
55 if err != nil {
56 t.Skip("no cue to compose a policy with; the nix check provides one")
57 }
58 schema, err := filepath.Abs(filepath.Join("..", "schema", "verification.cue"))
59 if err != nil {
60 t.Fatal(err)
61 }
62 floor := t.TempDir()
63 if err := os.WriteFile(filepath.Join(floor, "floor.cue"), []byte(derivationFloor), 0o644); err != nil {
64 t.Fatal(err)
65 }
66 r := &policyRig{scratchRepo: newScratchRepo(t), source: policySource{
67 schema: schema,
68 cue: cue,
69 layer: composed.Floor{Path: floor},
70 projectDir: "policy/project",
71 }}
72 files := map[string]string{"seed": "seed\n"}
73 if project != "" {
74 files["policy/project/policy.cue"] = "package verification\n" + project
75 }
76 r.commitFiles(files)
77 return r
78}
79
80// commitFiles commits files onto the current branch and returns the commit.
81func (r *policyRig) commitFiles(files map[string]string) string {
82 r.t.Helper()
83 for path, body := range files {
84 full := filepath.Join(r.repo, path)
85 if err := os.MkdirAll(filepath.Dir(full), 0o755); err != nil {
86 r.t.Fatal(err)
87 }
88 if err := os.WriteFile(full, []byte(body), 0o644); err != nil {
89 r.t.Fatal(err)
90 }
91 }
92 r.git("add", "--all")
93 r.git("commit", "--quiet", "-m", "a commit")
94 return r.git("rev-parse", "HEAD")
95}
96
97// open opens the policy at rev as a request's evaluation does, and ends it
98// with the test.
99func (r *policyRig) open(rev string) (policySource, *worktree) {
100 r.t.Helper()
101 tip := &worktree{repo: r.repo, dir: r.repo, rev: rev}
102 p, done, err := r.source.open(tip)
103 r.t.Cleanup(done)
104 if err != nil {
105 r.t.Fatal(err)
106 }
107 return p, tip
108}
109
110// derive derives from..to under the policy at from.
111func (r *policyRig) derive(from, to string) derived {
112 r.t.Helper()
113 p, tip := r.open(from)
114 d, err := p.derive(tip, from, to)
115 if err != nil {
116 r.t.Fatal(err)
117 }
118 return d
119}
120
121func classSet(names ...string) map[string]bool {
122 set := map[string]bool{}
123 for _, n := range names {
124 set[n] = true
125 }
126 return set
127}
128
129// A diff is derived as the policy says: the classes its paths match, the
130// checks those classes require with each class as its reason, the
131// strictest carry mode among them, and no check a class only follows.
132func TestADiffRequiresWhatItsClassesRequire(t *testing.T) {
133 r := newPolicyRig(t, "")
134 base := r.git("rev-parse", "HEAD")
135 head := r.commitFiles(map[string]string{"src/a.go": "package a\n", "src/b.go": "package b\n"})
136 d := r.derive(base, head)
137 want := derived{paths: 2, classes: classSet("code"), requires: map[string][]string{"c-build": {"code"}}, carry: "exact"}
138 if !reflect.DeepEqual(d, want) {
139 t.Fatalf("a code change derives %+v, want %+v", d, want)
140 }
141}
142
143// A path no class covers is unclassified: the name is among the classes
144// matched, and it is the reason for each check the unclassified set
145// requires.
146func TestAPathNoClassCoversIsUnclassified(t *testing.T) {
147 r := newPolicyRig(t, "")
148 base := r.git("rev-parse", "HEAD")
149 head := r.commitFiles(map[string]string{"docs/a.md": "a\n", "README": "r\n"})
150 d := r.derive(base, head)
151 want := derived{
152 paths: 2,
153 classes: classSet("docs", "unclassified"),
154 requires: map[string][]string{"c-docs": {"docs"}, "c-smoke": {"unclassified"}},
155 carry: "same-class",
156 }
157 if !reflect.DeepEqual(d, want) {
158 t.Fatalf("a docs and unclassified change derives %+v, want %+v", d, want)
159 }
160}
161
162// What an intervening landing touched is the classes the deriver matches
163// over base..tip, and an effectful observation of a check one of those
164// classes requires does not transfer. An unclassified path is touched as
165// the class `unclassified`, and a class the policy itself names
166// `unclassified` folds into that one name, so each blocks an observation
167// the other requires. An intervening docs change blocks neither.
168func TestAnInterveningChangeBlocksWhatItsClassesRequire(t *testing.T) {
169 const odd = `project: checks: "c-odd": {runner: "command", command: "true", validity: "1h"}
170project: classes: unclassified: {paths: "odd/**": true, requires: "c-odd": true}
171`
172 for _, c := range []struct {
173 name, check string
174 head, interlude string
175 blocked bool
176 }{
177 {"an unclassified path blocks the class named unclassified", "c-odd", "odd/a", "README", true},
178 {"the class named unclassified blocks the unclassified set", "c-smoke", "README", "odd/b", true},
179 {"a docs path blocks neither", "c-odd", "odd/a", "docs/a.md", false},
180 } {
181 t.Run(c.name, func(t *testing.T) {
182 r := newPolicyRig(t, odd)
183 base := r.git("rev-parse", "HEAD")
184 head := r.commitFiles(map[string]string{c.head: "head\n"})
185 r.git("checkout", "--quiet", "-b", "target", base)
186 tip := r.commitFiles(map[string]string{c.interlude: "interlude\n"})
187
188 p, wt := r.open(tip)
189 candidate, err := p.derive(wt, base, head)
190 if err != nil {
191 t.Fatal(err)
192 }
193 required, err := p.required(candidate)
194 if err != nil {
195 t.Fatal(err)
196 }
197 intervening, err := p.derive(wt, base, tip)
198 if err != nil {
199 t.Fatal(err)
200 }
201 if !intervening.classes["unclassified"] && c.blocked {
202 t.Fatalf("base..tip touched %v, without unclassified", intervening.classes)
203 }
204 observed := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
205 v := verdict.Decide(
206 verdict.Change{ID: "c1", Target: "refs/heads/main", Base: base, Head: head, Attested: "attested", Evidence: map[string]verdict.Evidence{
207 c.check: {Check: c.check, Kind: verdict.Effectful, Runner: "command", Admissible: verdict.Admissible, Result: "passed", ObservedAt: observed},
208 }},
209 verdict.Snapshot{
210 Apply: verdict.Applied{Clean: true, Tree: "moved"},
211 Required: required,
212 Touched: intervening.classes,
213 Now: observed.Add(time.Minute),
214 })
215 if len(v.Checks) != 1 || v.Checks[0].Name != c.check {
216 t.Fatalf("the change requires %+v, want %s alone", v.Checks, c.check)
217 }
218 if v.Checks[0].Transferred == c.blocked {
219 t.Fatalf("with %s intervening, %s transferred %v: %s", c.interlude, c.check, v.Checks[0].Transferred, v.Checks[0].Reason)
220 }
221 })
222 }
223}
224
225// A policy that does not compose refuses the request, and leaves no
226// materialized layer behind.
227func TestAModelThatDoesNotReadIsRefused(t *testing.T) {
228 r := newPolicyRig(t, `project: checks: "c-build": runner: "telepathy"`+"\n")
229 tip := &worktree{repo: r.repo, dir: r.repo, rev: r.git("rev-parse", "HEAD")}
230 p, done, err := r.source.open(tip)
231 defer done()
232 if err == nil {
233 t.Fatal("a policy that does not compose was opened")
234 }
235 if p.model != nil {
236 t.Fatalf("a policy that does not compose was read as %+v", p.model)
237 }
238 if _, err := os.Stat(p.project); !os.IsNotExist(err) {
239 t.Fatalf("the refused request left its project layer behind: %v", err)
240 }
241}
242
243// A diff that does not read refuses the derivation, from git and from the
244// path reader alike.
245func TestADiffThatDoesNotReadIsRefused(t *testing.T) {
246 r := newPolicyRig(t, "")
247 base := r.git("rev-parse", "HEAD")
248 p, tip := r.open(base)
249 if d, err := p.derive(tip, base, strings.Repeat("0", 40)); err == nil {
250 t.Fatalf("a diff to a commit that is not there derived %+v", d)
251 }
252 p.diff = func(context.Context, string, []string, string, string) ([]string, error) {
253 return nil, errors.New("truncated diff output")
254 }
255 if d, err := p.derive(tip, base, base); err == nil || !strings.Contains(err.Error(), "deriving required checks for") {
256 t.Fatalf("a diff that does not read derived %+v, %v", d, err)
257 }
258}
259
260// A diff with nothing in it requires nothing.
261func TestAnEmptyDiffRequiresNothing(t *testing.T) {
262 repo := newScratchRepo(t)
263 one := repo.git("rev-parse", "HEAD")
264 repo.git("commit", "--quiet", "--allow-empty", "-m", "the same tree")
265 same := repo.git("rev-parse", "HEAD")
266 p := policySource{model: &composed.Model{}}
267 d, err := p.derive(&worktree{dir: repo.repo}, one, same)
268 if err != nil {
269 t.Fatal(err)
270 }
271 if d.paths != 0 || len(d.classes) != 0 || len(d.requires) != 0 || d.carry != "same-paths" {
272 t.Fatalf("an empty diff derives %+v", d)
273 }
274}
275
276// No changed paths are believed only when git agrees. The path reader
277// reads none, as one that failed silently would, and the derivation is
278// read over two commits with one tree, and refused over two commits whose
279// trees differ.
280func TestNoChangedPathsAreCheckedAgainstGit(t *testing.T) {
281 repo := newScratchRepo(t)
282 one := repo.git("rev-parse", "HEAD")
283 repo.git("commit", "--quiet", "--allow-empty", "-m", "the same tree")
284 same := repo.git("rev-parse", "HEAD")
285 if err := os.WriteFile(filepath.Join(repo.repo, "changed.txt"), []byte("x\n"), 0o644); err != nil {
286 t.Fatal(err)
287 }
288 repo.git("add", "changed.txt")
289 repo.git("commit", "--quiet", "-m", "a change")
290 changed := repo.git("rev-parse", "HEAD")
291
292 p := policySource{model: &composed.Model{}, diff: func(context.Context, string, []string, string, string) ([]string, error) {
293 return nil, nil
294 }}
295 tip := &worktree{dir: repo.repo}
296 if _, err := p.derive(tip, one, same); err != nil {
297 t.Fatalf("an empty diff read as empty was refused: %v", err)
298 }
299 if d, err := p.derive(tip, one, changed); err == nil {
300 t.Fatalf("a change read as touching nothing derived %+v", d)
301 }
302}
303
304// The landing records the digest of the model the request was derived
305// under. attest is a stand-in here: it digests the head's tree, which this
306// test does not read.
307func TestTheLandingRecordsTheModelsDigest(t *testing.T) {
308 r := newPolicyRig(t, "")
309 tip := r.git("rev-parse", "HEAD")
310 head := r.commitFiles(map[string]string{"src/a.go": "package a\n"})
311 attest := filepath.Join(t.TempDir(), "attest")
312 if err := os.WriteFile(attest, []byte("#!/bin/sh\necho valley-tree-v1:"+strings.Repeat("ab", 32)+"\n"), 0o755); err != nil {
313 t.Fatal(err)
314 }
315 in := &integrator{repo: r.repo, attest: attest, signerName: "integrator", policy: r.source}
316 _, snap, land, err := in.materialize(request{change: "c1", target: "refs/heads/main", head: head}, tip, r.source.layer.Path, newStopwatch())
317 if err != nil {
318 t.Fatal(err)
319 }
320 p, _ := r.open(tip)
321 if land.policy == "" || land.policy != p.model.Digest {
322 t.Fatalf("the landing records policy %q, and the model's digest is %q", land.policy, p.model.Digest)
323 }
324 if !slices.ContainsFunc(snap.Required, func(q verdict.Required) bool { return q.Name == "c-build" }) {
325 t.Fatalf("the landing was judged over %+v", snap.Required)
326 }
327}
328
329// The policy digest is of the whole composed policy, so a class's carry
330// mode, the restacker's cap and the hardware approval requirement are in it
331// as much as a check is. The layers are composed by the real cue under the
332// real schema, with the floor fixed and the project layer varied.
333func TestThePolicyDigestCoversCarryTheCapAndHardware(t *testing.T) {
334 cue, err := exec.LookPath("cue")
335 if err != nil {
336 t.Skip("no cue to compose a policy with; the nix check provides one")
337 }
338 schema, err := filepath.Abs(filepath.Join("..", "schema", "verification.cue"))
339 if err != nil {
340 t.Fatal(err)
341 }
342 const floor = `package verification
343floor: {
344 checks: "c-build": {runner: "nix", attribute: "c-build"}
345 classes: code: {paths: "src/**": true, requires: "c-build": true}
346}
347`
348 digest := func(project string) string {
349 t.Helper()
350 p := policySource{schema: schema, cue: cue, instance: t.TempDir(), project: t.TempDir()}
351 if err := os.WriteFile(filepath.Join(p.instance, "floor.cue"), []byte(floor), 0o644); err != nil {
352 t.Fatal(err)
353 }
354 if err := os.WriteFile(filepath.Join(p.project, "policy.cue"), []byte("package verification\n"+project), 0o644); err != nil {
355 t.Fatal(err)
356 }
357 if err := p.read(); err != nil {
358 t.Fatal(err)
359 }
360 return p.model.Digest
361 }
362
363 base := digest("")
364 if again := digest(""); again != base {
365 t.Fatalf("one policy digested twice gave %s and %s", base, again)
366 }
367 // The digest is of the composition, not of the text: writing the cap's
368 // default composes the same policy.
369 if same := digest("project: restack: maxAutomaticVersions: 64\n"); same != base {
370 t.Errorf("writing the default cap moved the digest from %s to %s", base, same)
371 }
372 seen := map[string]string{base: "the floor alone"}
373 for _, c := range []struct{ name, project string }{
374 {"a class asking for same-class", `project: classes: code: carry: "same-class": true` + "\n"},
375 {"a class asking for exact", "project: classes: code: carry: exact: true\n"},
376 {"a lower cap", "project: restack: maxAutomaticVersions: 16\n"},
377 // The schema puts no upper bound on the cap. The integrator does
378 // not read the cap, so it composes and digests one no Go int holds.
379 {"a cap no int holds", "project: restack: maxAutomaticVersions: 9223372036854775808\n"},
380 {"a hardware approval requirement", "project: approval: hardware: true\n"},
381 } {
382 sum := digest(c.project)
383 if other, ok := seen[sum]; ok {
384 t.Errorf("%s digests the same as %s: %s", c.name, other, sum)
385 }
386 seen[sum] = c.name
387 }
388}
389
390func TestValidityWindowsAreReadAsThePolicyWritesThem(t *testing.T) {
391 for _, c := range []struct {
392 in string
393 want time.Duration
394 }{
395 {"", 0},
396 {"30s", 30 * time.Second},
397 {"15m", 15 * time.Minute},
398 {"6h", 6 * time.Hour},
399 {"2d", 48 * time.Hour},
400 } {
401 got, err := parseWindow(c.in)
402 if err != nil || got != c.want {
403 t.Errorf("parseWindow(%q) = %v, %v; want %v", c.in, got, err, c.want)
404 }
405 }
406}
407
408// Each layer's absence defaults in the safe direction of that layer's job,
409// and the two directions are opposite (dcr-f41f718). Both are pinned here,
410// because the value of the rule is that neither is the other.
411
412// targetTip commits files onto a scratch repository's main and returns
413// the tip as a pass checks it out.
414func targetTip(t *testing.T, files map[string]string) (*scratchRepo, *worktree) {
415 t.Helper()
416 s := newScratchRepo(t)
417 for path, body := range files {
418 full := filepath.Join(s.repo, path)
419 if err := os.MkdirAll(filepath.Dir(full), 0o755); err != nil {
420 t.Fatal(err)
421 }
422 if err := os.WriteFile(full, []byte(body), 0o644); err != nil {
423 t.Fatal(err)
424 }
425 }
426 s.git("add", "--all")
427 s.git("commit", "--quiet", "--allow-empty", "-m", "the target")
428 return s, &worktree{repo: s.repo, dir: s.repo, rev: s.git("rev-parse", "HEAD")}
429}
430
431func TestATargetWithNoProjectLayerIsJudgedUnderTheFloorAlone(t *testing.T) {
432 _, tip := targetTip(t, map[string]string{"policy/project/notes.md": "not a document\n"})
433 p := policySource{projectDir: "policy/project"}
434 done, err := p.openProject(tip)
435 if err != nil {
436 t.Fatal(err)
437 }
438 defer done()
439 if p.note == "" {
440 t.Fatal("the pass said nothing about composing the floor alone")
441 }
442 // What the composer is handed is a layer that adds nothing, not a directory that is not there.
443 docs, err := filepath.Glob(filepath.Join(p.project, "*.cue"))
444 if err != nil || len(docs) != 1 {
445 t.Fatalf("the resolved project layer holds %v (%v)", docs, err)
446 }
447 if body, err := os.ReadFile(docs[0]); err != nil || strings.TrimSpace(string(body)) != "package verification" {
448 t.Fatalf("the layer that adds nothing reads %q (%v)", body, err)
449 }
450 done()
451 if _, err := os.Stat(p.project); !os.IsNotExist(err) {
452 t.Fatalf("the pass left its scratch layer behind: %v", err)
453 }
454}
455
456// The project layer is read from the tip's commit, and its directory is a
457// name, never a pattern: --project-policy policy/proj* reads that
458// directory, and not policy/projX beside it.
459func TestATargetsOwnProjectLayerIsReadAtTheTip(t *testing.T) {
460 for _, dir := range []string{"policy/project", "policy/proj*"} {
461 t.Run(dir, func(t *testing.T) {
462 _, tip := targetTip(t, map[string]string{
463 dir + "/policy.cue": "package verification // own\n",
464 "policy/projX/decoy.cue": "package verification // decoy\n",
465 })
466 p := policySource{projectDir: dir}
467 done, err := p.openProject(tip)
468 if err != nil {
469 t.Fatal(err)
470 }
471 defer done()
472 if p.note != "" {
473 t.Fatalf("an ordinary composition said %q", p.note)
474 }
475 entries, err := os.ReadDir(p.project)
476 if err != nil || len(entries) != 1 || entries[0].Name() != "policy.cue" {
477 t.Fatalf("the project layer resolved to %s, holding %v (%v)", p.project, entries, err)
478 }
479 if body, _ := os.ReadFile(filepath.Join(p.project, "policy.cue")); string(body) != "package verification // own\n" {
480 t.Fatalf("the project layer reads %q", body)
481 }
482 })
483 }
484}
485
486// A project layer that cannot be read refuses the pass. Read as absent, it
487// would judge the change under the floor alone, requiring fewer checks
488// from a read that never happened.
489func TestAProjectLayerThatCannotBeReadIsRefused(t *testing.T) {
490 for _, lost := range []string{"policy/project", "policy/project/policy.cue"} {
491 t.Run(lost, func(t *testing.T) {
492 s, tip := targetTip(t, map[string]string{"policy/project/policy.cue": "package verification\n"})
493 oid := s.git("rev-parse", tip.rev+":"+lost)
494 if err := os.Remove(filepath.Join(s.repo, ".git", "objects", oid[:2], oid[2:])); err != nil {
495 t.Fatal(err)
496 }
497 p := policySource{projectDir: "policy/project"}
498 done, err := p.openProject(tip)
499 defer done()
500 if err == nil {
501 t.Fatalf("an unreadable project layer resolved to %s, noting %q", p.project, p.note)
502 }
503 if !strings.Contains(err.Error(), "policy/project") {
504 t.Fatalf("the refusal reads %q", err)
505 }
506 })
507 }
508}
509
510func TestAFloorThatIsNotThereIsRefused(t *testing.T) {
511 // The materialized source, which is the one a test can drive without a
512 // repository. The repository source refuses the same way, and the e2e
513 // observes it there.
514 _, done, err := composed.Floor{Path: t.TempDir()}.Open(context.Background(), "valley-integrator-floor")
515 defer done()
516 if err == nil {
517 t.Fatal("a floor directory with no documents in it was accepted")
518 }
519 if !strings.Contains(err.Error(), composed.Floorless) {
520 t.Fatalf("the refusal reads %q", err)
521 }
522}
523
524// The floor is every *.cue document directly in its directory, whatever
525// its name. Listed one name a line, git quotes a name with non-ASCII
526// characters in it, and the quoted name does not end in .cue, so a floor
527// read that way skipped naïve.cue. The repository sets core.quotePath to
528// the default that quotes, and the document is composed into the model
529// like any other.
530func TestAFloorDocumentWithANonASCIINameIsRead(t *testing.T) {
531 cue, err := exec.LookPath("cue")
532 if err != nil {
533 t.Skip("no cue to compose a policy with; the nix check provides one")
534 }
535 schema, err := filepath.Abs(filepath.Join("..", "schema", "verification.cue"))
536 if err != nil {
537 t.Fatal(err)
538 }
539 s := newScratchRepo(t)
540 s.git("config", "core.quotePath", "true")
541 dir := filepath.Join(s.repo, "policy", "instance")
542 if err := os.MkdirAll(dir, 0o755); err != nil {
543 t.Fatal(err)
544 }
545 for name, body := range map[string]string{
546 "floor.cue": `package verification
547floor: {
548 checks: "c-build": {runner: "nix", attribute: "c-build"}
549 classes: code: {paths: "src/**": true, requires: "c-build": true}
550}
551`,
552 "naïve.cue": `package verification
553floor: checks: "c-lint": {runner: "nix", attribute: "c-lint"}
554`,
555 } {
556 if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0o644); err != nil {
557 t.Fatal(err)
558 }
559 }
560 s.git("add", "policy")
561 s.git("commit", "--quiet", "-m", "the floor")
562
563 p := policySource{
564 schema: schema,
565 cue: cue,
566 layer: composed.Floor{Repo: s.repo, Ref: "refs/heads/main", Dir: "policy/instance"},
567 projectDir: "policy/project",
568 }
569 p, done, err := p.open(&worktree{repo: s.repo, dir: s.repo, rev: s.git("rev-parse", "HEAD")})
570 defer done()
571 if err != nil {
572 t.Fatal(err)
573 }
574 cat := p.model.Checks
575 if _, ok := cat["c-lint"]; !ok {
576 t.Fatalf("the floor's naïve.cue was not read: the model defines %v", cat)
577 }
578 if _, ok := cat["c-build"]; !ok {
579 t.Fatalf("the floor's floor.cue was not read: the model defines %v", cat)
580 }
581}
582
583func TestARefusalIsReadAsTheSentenceItIs(t *testing.T) {
584 // attest reports what it checked, then refuses, then elaborates. The
585 // sentence is the refusal; the elaboration is not.
586 out := `note /tmp/x.note
587text ok (411 bytes signed)
588attest: tree digest mismatch: the statement is about a different tree
589 recorded aaaa
590 found bbbb
591`
592 if got := refusalLine(out); got != "tree digest mismatch: the statement is about a different tree" {
593 t.Fatalf("refusalLine = %q", got)
594 }
595 if got := refusalLine("something with no prefix at all\n"); got != "something with no prefix at all" {
596 t.Fatalf("refusalLine fallback = %q", got)
597 }
598}