(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestCommitVerifyAlignment(t *testing.T) { |
| 17 | t.Parallel() |
| 18 | |
| 19 | if testing.Short() { |
| 20 | t.Skip("skipping commit verify") |
| 21 | } |
| 22 | |
| 23 | if gpg == nil { |
| 24 | t.Error("gpg not available") |
| 25 | t.FailNow() |
| 26 | } |
| 27 | |
| 28 | cases := []struct { |
| 29 | name string |
| 30 | // build returns the unsigned commit bytes that will be signed |
| 31 | // by gpg. The signature is injected as a single canonical |
| 32 | // "gpgsig" header in the standard location and the result is |
| 33 | // what both verifiers see, unless postSign rewrites it. |
| 34 | build func() []byte |
| 35 | // postSign optionally rewrites the signed object bytes (e.g. |
| 36 | // to inject a duplicated signature header). nil means use the |
| 37 | // standard injection path. |
| 38 | postSign func(signed []byte, sig string) []byte |
| 39 | }{ |
| 40 | { |
| 41 | name: "valid", |
| 42 | build: func() []byte { |
| 43 | h, m := canonicalCommit() |
| 44 | return assembleCommit(h, m) |
| 45 | }, |
| 46 | }, |
| 47 | { |
| 48 | name: "duplicate-tree", |
| 49 | build: func() []byte { |
| 50 | h, m := canonicalCommit() |
| 51 | dup := append([]string{ |
| 52 | h[0], |
| 53 | "tree 5555555555555555555555555555555555555555", |
| 54 | }, h[1:]...) |
| 55 | return assembleCommit(dup, m) |
| 56 | }, |
| 57 | }, |
| 58 | { |
| 59 | name: "duplicate-author", |
| 60 | build: func() []byte { |
| 61 | h, m := canonicalCommit() |
| 62 | dup := []string{ |
| 63 | h[0], |
| 64 | h[1], |
| 65 | h[2], |
| 66 | "author Override Author <override@example.local> 1700000001 +0000", |
| 67 | h[3], |
| 68 | } |
| 69 | return assembleCommit(dup, m) |
| 70 | }, |
| 71 | }, |
| 72 | { |
| 73 | name: "duplicate-committer", |
nothing calls this directly
no test coverage detected
searching dependent graphs…