Skip to content

Commit c8525c3

Browse files
Michael J Grubergitster
authored andcommitted
t/t7004-tag: test handling of rfc1991 signatures
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 <[email protected]> Signed-off-by: Michael J Gruber <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af77aee commit c8525c3

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

t/t7004-tag.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,72 @@ test_expect_success GPG \
10301030
test_cmp expect actual
10311031
'
10321032

1033+
# usage with rfc1991 signatures
1034+
echo "rfc1991" > gpghome/gpg.conf
1035+
get_tag_header rfc1991-signed-tag $commit commit $time >expect
1036+
echo "RFC1991 signed tag" >>expect
1037+
echo '-----BEGIN PGP MESSAGE-----' >>expect
1038+
test_expect_success GPG \
1039+
'creating a signed tag with rfc1991' '
1040+
git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit &&
1041+
get_tag_msg rfc1991-signed-tag >actual &&
1042+
test_cmp expect actual
1043+
'
1044+
1045+
cat >fakeeditor <<'EOF'
1046+
#!/bin/sh
1047+
cp "$1" actual
1048+
EOF
1049+
chmod +x fakeeditor
1050+
1051+
test_expect_failure GPG \
1052+
'reediting a signed tag body omits signature' '
1053+
echo "RFC1991 signed tag" >expect &&
1054+
GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
1055+
test_cmp expect actual
1056+
'
1057+
1058+
test_expect_failure GPG \
1059+
'verifying rfc1991 signature' '
1060+
git tag -v rfc1991-signed-tag
1061+
'
1062+
1063+
test_expect_failure GPG \
1064+
'list tag with rfc1991 signature' '
1065+
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
1066+
git tag -l -n1 rfc1991-signed-tag >actual &&
1067+
test_cmp expect actual &&
1068+
git tag -l -n2 rfc1991-signed-tag >actual &&
1069+
test_cmp expect actual &&
1070+
git tag -l -n999 rfc1991-signed-tag >actual &&
1071+
test_cmp expect actual
1072+
'
1073+
1074+
rm -f gpghome/gpg.conf
1075+
1076+
test_expect_failure GPG \
1077+
'verifying rfc1991 signature without --rfc1991' '
1078+
git tag -v rfc1991-signed-tag
1079+
'
1080+
1081+
test_expect_failure GPG \
1082+
'list tag with rfc1991 signature without --rfc1991' '
1083+
echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
1084+
git tag -l -n1 rfc1991-signed-tag >actual &&
1085+
test_cmp expect actual &&
1086+
git tag -l -n2 rfc1991-signed-tag >actual &&
1087+
test_cmp expect actual &&
1088+
git tag -l -n999 rfc1991-signed-tag >actual &&
1089+
test_cmp expect actual
1090+
'
1091+
1092+
test_expect_failure GPG \
1093+
'reediting a signed tag body omits signature' '
1094+
echo "RFC1991 signed tag" >expect &&
1095+
GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
1096+
test_cmp expect actual
1097+
'
1098+
10331099
# try to sign with bad user.signingkey
10341100
git config user.signingkey BobTheMouse
10351101
test_expect_success GPG \

0 commit comments

Comments
 (0)