test the commit.gpgsign config option

The tests are checking that : - when commit.gpgsign is true, "git commit" creates signed commits - when commit.gpgsign is false, "git commit" creates unsigned commits - when commit.gpgsign is true, "git commit --no-gpg-sign" creates unsigned commits - when commit.gpgsign is true, "git rebase -f" creates signed commits Signed-off-by: Nicolas Vigier <boklm@mars-attacks.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nicolas Vigier committed Dec 16, 2013 at 14:55 UTC 4b8d14b4c5d73dd4adb354d9689022d1b87828d5
1 file changed +21 -4
t/t7510-signed-commit.sh
+21 -4
@@ -5,6 +5,8 @@ test_description='signed commit tests'
5 . "$TEST_DIRECTORY/lib-gpg.sh"
6
7 test_expect_success GPG 'create signed commits' '
8 + test_when_finished "test_unconfig commit.gpgsign" &&
9 +
10 echo 1 >file && git add file &&
11 test_tick && git commit -S -m initial &&
12 git tag initial &&
@@ -25,12 +27,27 @@ test_expect_success GPG 'create signed commits' '
27 git tag fourth-unsigned &&
28
29 test_tick && git commit --amend -S -m "fourth signed" &&
28 - git tag fourth-signed
30 + git tag fourth-signed &&
31 +
32 + git config commit.gpgsign true &&
33 + echo 5 >file && test_tick && git commit -a -m "fifth signed" &&
34 + git tag fifth-signed &&
35 +
36 + git config commit.gpgsign false &&
37 + echo 6 >file && test_tick && git commit -a -m "sixth" &&
38 + git tag sixth-unsigned &&
39 +
40 + git config commit.gpgsign true &&
41 + echo 7 >file && test_tick && git commit -a -m "seventh" --no-gpg-sign &&
42 + git tag seventh-unsigned &&
43 +
44 + test_tick && git rebase -f HEAD^^ && git tag sixth-signed HEAD^ &&
45 + git tag seventh-signed
46 '
47
48 test_expect_success GPG 'show signatures' '
49 (
33 - for commit in initial second merge master
50 + for commit in initial second merge fourth-signed fifth-signed sixth-signed master
51 do
52 git show --pretty=short --show-signature $commit >actual &&
53 grep "Good signature from" actual || exit 1
@@ -39,7 +56,7 @@ test_expect_success GPG 'show signatures' '
56 done
57 ) &&
58 (
42 - for commit in merge^2 fourth-unsigned
59 + for commit in merge^2 fourth-unsigned sixth-unsigned seventh-unsigned
60 do
61 git show --pretty=short --show-signature $commit >actual &&
62 grep "Good signature from" actual && exit 1
@@ -52,7 +69,7 @@ test_expect_success GPG 'show signatures' '
69 test_expect_success GPG 'detect fudged signature' '
70 git cat-file commit master >raw &&
71
55 - sed -e "s/fourth signed/4th forged/" raw >forged1 &&
72 + sed -e "s/seventh/7th forged/" raw >forged1 &&
73 git hash-object -w -t commit forged1 >forged1.commit &&
74 git show --pretty=short --show-signature $(cat forged1.commit) >actual1 &&
75 grep "BAD signature from" actual1 &&