verify_signed_buffer: fix stale comment
[git/git.git] / t / t7510-signed-commit.sh
CommitLineData
247503f2
JH
1#!/bin/sh
2
3test_description='signed commit tests'
4. ./test-lib.sh
5. "$TEST_DIRECTORY/lib-gpg.sh"
6
7test_expect_success GPG 'create signed commits' '
8 echo 1 >file && git add file &&
9 test_tick && git commit -S -m initial &&
10 git tag initial &&
11 git branch side &&
12
13 echo 2 >file && test_tick && git commit -a -S -m second &&
14 git tag second &&
15
16 git checkout side &&
17 echo 3 >elif && git add elif &&
18 test_tick && git commit -m "third on side" &&
19
20 git checkout master &&
21 test_tick && git merge -S side &&
22 git tag merge &&
23
24 echo 4 >file && test_tick && git commit -a -m "fourth unsigned" &&
25 git tag fourth-unsigned &&
26
27 test_tick && git commit --amend -S -m "fourth signed"
28'
29
30test_expect_success GPG 'show signatures' '
31 (
32 for commit in initial second merge master
33 do
34 git show --pretty=short --show-signature $commit >actual &&
35 grep "Good signature from" actual || exit 1
36 ! grep "BAD signature from" actual || exit 1
37 echo $commit OK
38 done
39 ) &&
40 (
41 for commit in merge^2 fourth-unsigned
42 do
43 git show --pretty=short --show-signature $commit >actual &&
44 grep "Good signature from" actual && exit 1
45 ! grep "BAD signature from" actual || exit 1
46 echo $commit OK
47 done
48 )
49'
50
51test_expect_success GPG 'detect fudged signature' '
52 git cat-file commit master >raw &&
53
54 sed -e "s/fourth signed/4th forged/" raw >forged1 &&
55 git hash-object -w -t commit forged1 >forged1.commit &&
56 git show --pretty=short --show-signature $(cat forged1.commit) >actual1 &&
57 grep "BAD signature from" actual1 &&
58 ! grep "Good signature from" actual1
59'
60
61test_expect_success GPG 'detect fudged signature with NUL' '
62 git cat-file commit master >raw &&
63 cat raw >forged2 &&
64 echo Qwik | tr "Q" "\000" >>forged2 &&
65 git hash-object -w -t commit forged2 >forged2.commit &&
66 git show --pretty=short --show-signature $(cat forged2.commit) >actual2 &&
67 grep "BAD signature from" actual2 &&
68 ! grep "Good signature from" actual2
69'
70
71test_done