Skip to content

Commit 0517f59

Browse files
FStelzergitster
authored andcommitted
t/gpg: simplify test for unknown key
To test for a key that is completely unknown to the keyring we need one to sign the commit with. This was done by generating a new key and not add it into the keyring. To avoid the key generation overhead and problems where GPG did hang in CI during it, switch GNUPGHOME to the empty $GNUPGHOME_NOT_USED instead, therefore making all used keys unknown for this single `verify-commit` call. Reported-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Fabian Stelzer <[email protected]> Reviewed-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 18c6653 commit 0517f59

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

t/t7510-signed-commit.sh

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,7 @@ test_expect_success GPG 'create signed commits' '
7171
git tag eleventh-signed $(cat oid) &&
7272
echo 12 | git commit-tree --gpg-sign=B7227189 HEAD^{tree} >oid &&
7373
test_line_count = 1 oid &&
74-
git tag twelfth-signed-alt $(cat oid) &&
75-
76-
cat >keydetails <<-\EOF &&
77-
Key-Type: RSA
78-
Key-Length: 2048
79-
Subkey-Type: RSA
80-
Subkey-Length: 2048
81-
Name-Real: Unknown User
82-
Name-Email: [email protected]
83-
Expire-Date: 0
84-
%no-ask-passphrase
85-
%no-protection
86-
EOF
87-
gpg --batch --gen-key keydetails &&
88-
echo 13 >file && git commit -a -S"[email protected]" -m thirteenth &&
89-
git tag thirteenth-signed &&
90-
DELETE_FINGERPRINT=$(gpg -K --with-colons --fingerprint --batch [email protected] | grep "^fpr" | head -n 1 | awk -F ":" "{print \$10;}") &&
91-
gpg --batch --yes --delete-secret-keys $DELETE_FINGERPRINT &&
92-
gpg --batch --yes --delete-keys [email protected]
74+
git tag twelfth-signed-alt $(cat oid)
9375
'
9476

9577
test_expect_success GPG 'verify and show signatures' '
@@ -129,7 +111,7 @@ test_expect_success GPG 'verify and show signatures' '
129111
'
130112

131113
test_expect_success GPG 'verify-commit exits failure on unknown signature' '
132-
test_must_fail git verify-commit thirteenth-signed 2>actual &&
114+
test_must_fail env GNUPGHOME="$GNUPGHOME_NOT_USED" git verify-commit initial 2>actual &&
133115
! grep "Good signature from" actual &&
134116
! grep "BAD signature from" actual &&
135117
grep -q -F -e "No public key" -e "public key not found" actual

0 commit comments

Comments
 (0)