Skip to content

Commit 7f8ca20

Browse files
illikainengitster
authored andcommitted
t: add tests for pull --verify-signatures
Add tests for pull --verify-signatures with untrusted, bad and no signatures. Previously the only test for --verify-signatures was to make sure that pull --rebase --verify-signatures result in a warning (t5520-pull.sh). Signed-off-by: Hans Jerry Illikainen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ca779e8 commit 7f8ca20

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

t/t5573-pull-verify-signatures.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/sh
2+
3+
test_description='pull signature verification tests'
4+
. ./test-lib.sh
5+
. "$TEST_DIRECTORY/lib-gpg.sh"
6+
7+
test_expect_success GPG 'create repositories with signed commits' '
8+
echo 1 >a && git add a &&
9+
test_tick && git commit -m initial &&
10+
git tag initial &&
11+
12+
git clone . signed &&
13+
(
14+
cd signed &&
15+
echo 2 >b && git add b &&
16+
test_tick && git commit -S -m "signed"
17+
) &&
18+
19+
git clone . unsigned &&
20+
(
21+
cd unsigned &&
22+
echo 3 >c && git add c &&
23+
test_tick && git commit -m "unsigned"
24+
) &&
25+
26+
git clone . bad &&
27+
(
28+
cd bad &&
29+
echo 4 >d && git add d &&
30+
test_tick && git commit -S -m "bad" &&
31+
git cat-file commit HEAD >raw &&
32+
sed -e "s/bad/forged bad/" raw >forged &&
33+
git hash-object -w -t commit forged >forged.commit &&
34+
git checkout $(cat forged.commit)
35+
) &&
36+
37+
git clone . untrusted &&
38+
(
39+
cd untrusted &&
40+
echo 5 >e && git add e &&
41+
test_tick && git commit -SB7227189 -m "untrusted"
42+
)
43+
'
44+
45+
test_expect_success GPG 'pull unsigned commit with --verify-signatures' '
46+
test_must_fail git pull --ff-only --verify-signatures unsigned 2>pullerror &&
47+
test_i18ngrep "does not have a GPG signature" pullerror
48+
'
49+
50+
test_expect_success GPG 'pull commit with bad signature with --verify-signatures' '
51+
test_must_fail git pull --ff-only --verify-signatures bad 2>pullerror &&
52+
test_i18ngrep "has a bad GPG signature" pullerror
53+
'
54+
55+
test_expect_success GPG 'pull commit with untrusted signature with --verify-signatures' '
56+
test_must_fail git pull --ff-only --verify-signatures untrusted 2>pullerror &&
57+
test_i18ngrep "has an untrusted GPG signature" pullerror
58+
'
59+
60+
test_expect_success GPG 'pull signed commit with --verify-signatures' '
61+
test_when_finished "git checkout initial" &&
62+
git pull --verify-signatures signed >pulloutput &&
63+
test_i18ngrep "has a good GPG signature" pulloutput
64+
'
65+
66+
test_expect_success GPG 'pull commit with bad signature without verification' '
67+
test_when_finished "git checkout initial" &&
68+
git pull --ff-only bad 2>pullerror
69+
'
70+
71+
test_expect_success GPG 'pull commit with bad signature with --no-verify-signatures' '
72+
test_when_finished "git checkout initial" &&
73+
test_config merge.verifySignatures true &&
74+
test_config pull.verifySignatures true &&
75+
git pull --ff-only --no-verify-signatures bad 2>pullerror
76+
'
77+
78+
test_done

0 commit comments

Comments
 (0)