msysGit-based Git for Windows 1.x was superseded by Git for Windows 2.x
[git/mingw/4msysgit.git] / t / t7612-merge-verify-signatures.sh
blob21a0bf8fb8c4946f625b317a9d60aa05bb0acb65
1 #!/bin/sh
3 test_description='merge signature verification 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 -m initial &&
10 git tag initial &&
12 git checkout -b side-signed &&
13 echo 3 >elif && git add elif &&
14 test_tick && git commit -S -m "signed on side" &&
15 git checkout initial &&
17 git checkout -b side-unsigned &&
18 echo 3 >foo && git add foo &&
19 test_tick && git commit -m "unsigned on side" &&
20 git checkout initial &&
22 git checkout -b side-bad &&
23 echo 3 >bar && git add bar &&
24 test_tick && git commit -S -m "bad on side" &&
25 git cat-file commit side-bad >raw &&
26 sed -e "s/bad/forged bad/" raw >forged &&
27 git hash-object -w -t commit forged >forged.commit &&
28 git checkout initial &&
30 git checkout -b side-untrusted &&
31 echo 3 >baz && git add baz &&
32 test_tick && git commit -SB7227189 -m "untrusted on side"
34 git checkout master
37 test_expect_success GPG 'merge unsigned commit with verification' '
38 test_must_fail git merge --ff-only --verify-signatures side-unsigned 2>mergeerror &&
39 test_i18ngrep "does not have a GPG signature" mergeerror
42 test_expect_success GPG 'merge commit with bad signature with verification' '
43 test_must_fail git merge --ff-only --verify-signatures $(cat forged.commit) 2>mergeerror &&
44 test_i18ngrep "has a bad GPG signature" mergeerror
47 test_expect_success GPG 'merge commit with untrusted signature with verification' '
48 test_must_fail git merge --ff-only --verify-signatures side-untrusted 2>mergeerror &&
49 test_i18ngrep "has an untrusted GPG signature" mergeerror
52 test_expect_success GPG 'merge signed commit with verification' '
53 git merge --verbose --ff-only --verify-signatures side-signed >mergeoutput &&
54 test_i18ngrep "has a good GPG signature" mergeoutput
57 test_expect_success GPG 'merge commit with bad signature without verification' '
58 git merge $(cat forged.commit)
61 test_done