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 <urschrei@gmail.com> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael J Gruber committed
Nov 10, 2010 at 12:17 UTC
c8525c302bfd8c5bc6a7e2f7aec0be2951eefd90
1 file changed
+66
t/t7004-tag.sh
+66
@@ -1030,6 +1030,72 @@ test_expect_success GPG \
1030
test_cmp expect actual
1031
'
1032
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
+
1099
# try to sign with bad user.signingkey
1100
git config user.signingkey BobTheMouse
1101
test_expect_success GPG \