config.c: trivial fix for compile-time warning
[git/dscho.git] / t / t7510-signed-commit.sh
blob30401ced071c24aed5071442da1a9674bc7b7c7e
1 #!/bin/sh
3 test_description='signed commit tests'
4 . ./test-lib.sh
5 . "$TEST_DIRECTORY/lib-gpg.sh"
7 test_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 &&
13 echo 2 >file && test_tick && git commit -a -S -m second &&
14 git tag second &&
16 git checkout side &&
17 echo 3 >elif && git add elif &&
18 test_tick && git commit -m "third on side" &&
20 git checkout master &&
21 test_tick && git merge -S side &&
22 git tag merge &&
24 echo 4 >file && test_tick && git commit -a -m "fourth unsigned" &&
25 git tag fourth-unsigned &&
27 test_tick && git commit --amend -S -m "fourth signed"
30 test_expect_success GPG 'show signatures' '
32 for commit in initial second merge master
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 ) &&
41 for commit in merge^2 fourth-unsigned
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
51 test_expect_success GPG 'detect fudged signature' '
52 git cat-file commit master >raw &&
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
61 test_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
71 test_done