Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Jerry Illikainen <hji@dyntopia.com>2020-03-04 14:48:03 +0300
committerJunio C Hamano <gitster@pobox.com>2020-03-15 19:45:58 +0300
commitf1e3df316992d32b17ee27385e4c644ef7b66cc1 (patch)
tree10db19138ba169fe822db9ab49dd2943bd2e4b2e /t/t6200-fmt-merge-msg.sh
parente63cefb024895fcff4b692cad84cb33ac4c81dcc (diff)
t: increase test coverage of signature verification output
There weren't any tests for unsuccessful signature verification of signed merge tags shown in 'git log'. There also weren't any tests for the GPG output from 'git fmt-merge-msg'. This was noticed while investigating a buggy refactor that slipped through the test suite; see commit 72b006f4bfd30b7c5037c163efaf279ab65bea9c. This commit adds signature verification tests to the 'log' and 'fmt-merge-msg' builtins. Thanks to Linus Torvalds for reporting and finding the (now reverted) commit that introduced the regression. Note that the "log --show-signature for merged tag with GPG failure" test case is really hacky. It relies on an implementation detail of verify_signed_buffer() -- namely, it assumes that the signature is written to a temporary file whose path is under TMPDIR. The rationale for that test case is to check whether the code path that yields the "No signature" message is reachable on failure. The functionality in log-tree.c that may show this message does some pre-parsing of a possible signature that prevents the GPG interface from being invoked if a signature is actually missing. And I haven't been able to construct a signature that both 1. satisfies that pre-processing, and 2. causes GPG to fail without any sort of output on stderr along the lines of "this is a bogus/corrupt/... signature" (the "No signature" message should only be shown if GPG produce no output). Signed-off-by: Hans Jerry Illikainen <hji@dyntopia.com> [jc: fixed missing test title noticed by Dscho] Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t6200-fmt-merge-msg.sh')
-rwxr-xr-xt/t6200-fmt-merge-msg.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 8a72b4c43a..b15582a7a2 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -6,6 +6,7 @@
test_description='fmt-merge-msg test'
. ./test-lib.sh
+. "$TEST_DIRECTORY/lib-gpg.sh"
test_expect_success setup '
echo one >one &&
@@ -73,6 +74,10 @@ test_expect_success setup '
apos="'\''"
'
+test_expect_success GPG 'set up a signed tag' '
+ git tag -s -m signed-tag-msg signed-good-tag left
+'
+
test_expect_success 'message for merging local branch' '
echo "Merge branch ${apos}left${apos}" >expected &&
@@ -83,6 +88,24 @@ test_expect_success 'message for merging local branch' '
test_cmp expected actual
'
+test_expect_success GPG 'message for merging local tag signed by good key' '
+ git checkout master &&
+ git fetch . signed-good-tag &&
+ git fmt-merge-msg <.git/FETCH_HEAD >actual 2>&1 &&
+ grep "^Merge tag ${apos}signed-good-tag${apos}" actual &&
+ grep "^# gpg: Signature made" actual &&
+ grep "^# gpg: Good signature from" actual
+'
+
+test_expect_success GPG 'message for merging local tag signed by unknown key' '
+ git checkout master &&
+ git fetch . signed-good-tag &&
+ GNUPGHOME=. git fmt-merge-msg <.git/FETCH_HEAD >actual 2>&1 &&
+ grep "^Merge tag ${apos}signed-good-tag${apos}" actual &&
+ grep "^# gpg: Signature made" actual &&
+ grep "^# gpg: Can${apos}t check signature: \(public key not found\|No public key\)" actual
+'
+
test_expect_success 'message for merging external branch' '
echo "Merge branch ${apos}left${apos} of $(pwd)" >expected &&