git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv4 4/4] t7510: test verify-commit

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Jun 27, 2014, 14:13 UTC
Message-ID
<02b475e94770ed809e18e6258d593242abd23569.1403877431.git.git@drmicha.warpmail.net>
In-Reply-To
<xmqqoaxjb9rr.fsf@gitster.dls.corp.google.com>

This mixes the "git verify-commit" tests in with the "git show --show-signature" tests, to keep the tests more readable.

The tests already mix in the "call show" tests with the "verify" tests. So in case of a test beakage, a '-v' run would be needed to reveal the exact point of breakage anyway.

Additionally, test the actual output of "git verify-commit" and "git show --show-signature" and compare to "git cat-file".

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 t/t7510-signed-commit.sh | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index e97477a..474dab3 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -48,10 +48,11 @@ test_expect_success GPG 'create signed commits' '
 	git tag eighth-signed-alt
 '
 
-test_expect_success GPG 'show signatures' '
+test_expect_success GPG 'verify and show signatures' '
 	(
 		for commit in initial second merge fourth-signed fifth-signed sixth-signed seventh-signed
 		do
+			git verify-commit $commit &&
 			git show --pretty=short --show-signature $commit >actual &&
 			grep "Good signature from" actual &&
 			! grep "BAD signature from" actual &&
@@ -61,6 +62,7 @@ test_expect_success GPG 'show signatures' '
 	(
 		for commit in merge^2 fourth-unsigned sixth-unsigned seventh-unsigned
 		do
+			test_must_fail git verify-commit $commit &&
 			git show --pretty=short --show-signature $commit >actual &&
 			! grep "Good signature from" actual &&
 			! grep "BAD signature from" actual &&
@@ -79,11 +81,25 @@ test_expect_success GPG 'show signatures' '
 	)
 '
 
+test_expect_success GPG 'show signed commit with signature' '
+	git show -s initial >commit &&
+	git show -s --show-signature initial >show &&
+	git verify-commit -v initial >verify.1 2>verify.2 &&
+	git cat-file commit initial >cat &&
+	grep -v "gpg: " show >show.commit &&
+	grep "gpg: " show >show.gpg &&
+	grep -v "^ " cat | grep -v "^gpgsig " >cat.commit &&
+	test_cmp show.commit commit &&
+	test_cmp show.gpg verify.2 &&
+	test_cmp cat.commit verify.1
+'
+
 test_expect_success GPG 'detect fudged signature' '
 	git cat-file commit seventh-signed >raw &&
 
 	sed -e "s/seventh/7th forged/" raw >forged1 &&
 	git hash-object -w -t commit forged1 >forged1.commit &&
+	! git verify-commit $(cat forged1.commit) &&
 	git show --pretty=short --show-signature $(cat forged1.commit) >actual1 &&
 	grep "BAD signature from" actual1 &&
 	! grep "Good signature from" actual1
@@ -94,6 +110,7 @@ test_expect_success GPG 'detect fudged signature with NUL' '
 	cat raw >forged2 &&
 	echo Qwik | tr "Q" "\000" >>forged2 &&
 	git hash-object -w -t commit forged2 >forged2.commit &&
+	! git verify-commit $(cat forged2.commit) &&
 	git show --pretty=short --show-signature $(cat forged2.commit) >actual2 &&
 	grep "BAD signature from" actual2 &&
 	! grep "Good signature from" actual2
@@ -102,6 +119,7 @@ test_expect_success GPG 'detect fudged signature with NUL' '
 test_expect_success GPG 'amending already signed commit' '
 	git checkout fourth-signed^0 &&
 	git commit --amend -S --no-edit &&
+	git verify-commit HEAD &&
 	git show -s --show-signature HEAD >actual &&
 	grep "Good signature from" actual &&
 	! grep "BAD signature from" actual
-- 
2.0.1.563.g162087b.dirty
Previous: Michael J GruberNext: Junio C Hamano
Message 41 of 75 in “verify-commit: verify commit signatures”
  1. 0/3 verify-commit: verify commit signaturesMichael J Gruber, Jun 6, 2014
  2. 1/3 pretty: free the gpg status bufMichael J Gruber, Jun 6, 2014
  3. 2/3 gpg-interface: provide access to the payloadMichael J Gruber, Jun 6, 2014
  4. Jeff KingJun 13, 2014
  5. Michael J GruberJun 13, 2014
  6. Jeff KingJun 13, 2014
  7. 3/3 verify-commit: scriptable commit signature verificationMichael J Gruber, Jun 6, 2014
  8. Michael J GruberJun 11, 2014
  9. Jeff KingJun 13, 2014
  10. Michael J GruberJun 13, 2014
  11. Jeff KingJun 13, 2014
  12. Junio C HamanoJun 13, 2014
  13. Michael J GruberJun 16, 2014
  14. Jeff KingJun 16, 2014
  15. Junio C HamanoJun 16, 2014
  16. Jeff KingJun 16, 2014
  17. Michael J GruberJun 27, 2014
  18. Michael J GruberJun 27, 2014
  19. Michael J GruberJun 27, 2014
  20. log: correctly identify mergetag signature verification statusMichael J Gruber, Jun 27, 2014
  21. Jeff KingJun 28, 2014
  22. Junio C HamanoJul 10, 2014
  23. Michael J GruberJun 27, 2014
  24. Junio C HamanoJun 27, 2014
  25. Junio C HamanoJun 27, 2014
  26. Jeff KingJun 28, 2014
  27. Junio C HamanoJun 30, 2014
  28. 0/6 verify-commit: verify commit signaturesMichael J Gruber, Jun 13, 2014
  29. 0/5 verify-commit: verify commit signaturesMichael J Gruber, Jun 23, 2014
  30. Jeff KingJun 23, 2014
  31. Junio C HamanoJun 23, 2014
  32. Jeff KingJun 23, 2014
  33. Junio C HamanoJun 23, 2014
  34. 0/4 verify-commit: verify commit signaturesMichael J Gruber, Jun 27, 2014
  35. Junio C HamanoJun 27, 2014
  36. Jeff KingJun 28, 2014
  37. Jeff KingJun 28, 2014
  38. 1/4 gpg-interface: provide clear helper for struct signature_checkMichael J Gruber, Jun 27, 2014
  39. 2/4 gpg-interface: provide access to the payloadMichael J Gruber, Jun 27, 2014
  40. 3/4 verify-commit: scriptable commit signature verificationMichael J Gruber, Jun 27, 2014
  41. 4/4 t7510: test verify-commitMichael J Gruber, Jun 27, 2014
  42. Junio C HamanoJun 27, 2014
  43. Michael J GruberJun 27, 2014
  44. 1/5 gpg-interface: provide clear helper for struct signature_checkMichael J Gruber, Jun 23, 2014
  45. 2/5 gpg-interface: provide access to the payloadMichael J Gruber, Jun 23, 2014
  46. 3/5 verify-commit: scriptable commit signature verificationMichael J Gruber, Jun 23, 2014
  47. 4/5 t7510: exit for loop with test resultMichael J Gruber, Jun 23, 2014
  48. 5/5 t7510: test verify-commitMichael J Gruber, Jun 23, 2014
  49. Junio C HamanoJun 23, 2014
  50. 1/6 pretty: free the gpg status bufMichael J Gruber, Jun 13, 2014
  51. Jeff KingJun 13, 2014
  52. 2/6 gpg-interface: provide access to the payloadMichael J Gruber, Jun 13, 2014
  53. 3/6 verify-commit: scriptable commit signature verificationMichael J Gruber, Jun 13, 2014
  54. Jeff KingJun 13, 2014
  55. Michael J GruberJun 13, 2014
  56. Jeff KingJun 13, 2014
  57. Michael J GruberJun 13, 2014
  58. 4/6 t7510: exit for loop with test resultMichael J Gruber, Jun 13, 2014
  59. Jeff KingJun 13, 2014
  60. Michael J GruberJun 13, 2014
  61. Michael J GruberJun 13, 2014
  62. Michael J GruberJun 13, 2014
  63. Jeff KingJun 13, 2014
  64. Johannes SixtJun 13, 2014
  65. Michael J GruberJun 13, 2014
  66. Johannes SixtJun 13, 2014
  67. Jeff KingJun 13, 2014
  68. Michael J GruberJun 13, 2014
  69. Johannes SixtJun 13, 2014
  70. Junio C HamanoJun 13, 2014
  71. 5/6 t7510: test verify-commitMichael J Gruber, Jun 13, 2014
  72. Jeff KingJun 13, 2014
  73. Michael J GruberJun 13, 2014
  74. Junio C HamanoJun 13, 2014
  75. 6/6 gpg-interface: provide clear helper for struct signature_checkMichael J Gruber, Jun 13, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.