Skip to content

Commit

Permalink
t/t7004-tag: test handling of rfc1991 signatures
Browse files Browse the repository at this point in the history
Currently, git expects "-----BEGIN PGP SIGNATURE-----" at the beginning of a
signature. But gpg uses "MESSAGE" instead of "SIGNATURE" when used with
the "rfc1991" option. This leads to git's failing to verify it's own
signed tags, among other problems.

Add tests for all code paths (tag -v, tag -l -n largenumber, tag -f
without -m) where signature detection matters.

Reported-by: Stephan Hugel <urschrei@gmail.com>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael J Gruber authored and Junio C Hamano committed Nov 10, 2010
1 parent af77aee commit c8525c3
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions t/t7004-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,72 @@ test_expect_success GPG \
test_cmp expect actual
'

# usage with rfc1991 signatures
echo "rfc1991" > gpghome/gpg.conf
get_tag_header rfc1991-signed-tag $commit commit $time >expect
echo "RFC1991 signed tag" >>expect
echo '-----BEGIN PGP MESSAGE-----' >>expect
test_expect_success GPG \
'creating a signed tag with rfc1991' '
git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit &&
get_tag_msg rfc1991-signed-tag >actual &&
test_cmp expect actual
'

cat >fakeeditor <<'EOF'
#!/bin/sh
cp "$1" actual
EOF
chmod +x fakeeditor

test_expect_failure GPG \
'reediting a signed tag body omits signature' '
echo "RFC1991 signed tag" >expect &&
GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
test_cmp expect actual
'

test_expect_failure GPG \
'verifying rfc1991 signature' '
git tag -v rfc1991-signed-tag
'

test_expect_failure GPG \
'list tag with rfc1991 signature' '
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
git tag -l -n1 rfc1991-signed-tag >actual &&
test_cmp expect actual &&
git tag -l -n2 rfc1991-signed-tag >actual &&
test_cmp expect actual &&
git tag -l -n999 rfc1991-signed-tag >actual &&
test_cmp expect actual
'

rm -f gpghome/gpg.conf

test_expect_failure GPG \
'verifying rfc1991 signature without --rfc1991' '
git tag -v rfc1991-signed-tag
'

test_expect_failure GPG \
'list tag with rfc1991 signature without --rfc1991' '
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
git tag -l -n1 rfc1991-signed-tag >actual &&
test_cmp expect actual &&
git tag -l -n2 rfc1991-signed-tag >actual &&
test_cmp expect actual &&
git tag -l -n999 rfc1991-signed-tag >actual &&
test_cmp expect actual
'

test_expect_failure GPG \
'reediting a signed tag body omits signature' '
echo "RFC1991 signed tag" >expect &&
GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
test_cmp expect actual
'

# try to sign with bad user.signingkey
git config user.signingkey BobTheMouse
test_expect_success GPG \
Expand Down

0 comments on commit c8525c3

Please sign in to comment.