@@ -124,4 +124,48 @@ test_expect_success GPG 'signed push sends push certificate' '
124124 test_cmp expect dst/push-cert-status
125125'
126126
127+ test_expect_success GPG ' fail without key and heed user.signingkey' '
128+ prepare_dst &&
129+ mkdir -p dst/.git/hooks &&
130+ git -C dst config receive.certnonceseed sekrit &&
131+ write_script dst/.git/hooks/post-receive <<-\EOF &&
132+ # discard the update list
133+ cat >/dev/null
134+ # record the push certificate
135+ if test -n "${GIT_PUSH_CERT-}"
136+ then
137+ git cat-file blob $GIT_PUSH_CERT >../push-cert
138+ fi &&
139+
140+ cat >../push-cert-status <<E_O_F
141+ SIGNER=${GIT_PUSH_CERT_SIGNER-nobody}
142+ KEY=${GIT_PUSH_CERT_KEY-nokey}
143+ STATUS=${GIT_PUSH_CERT_STATUS-nostatus}
144+ NONCE_STATUS=${GIT_PUSH_CERT_NONCE_STATUS-nononcestatus}
145+ NONCE=${GIT_PUSH_CERT_NONCE-nononce}
146+ E_O_F
147+
148+ EOF
149+
150+ unset GIT_COMMITTER_EMAIL &&
151+ git config user.email hasnokey@nowhere.com &&
152+ test_must_fail git push --signed dst noop ff +noff &&
153+ git config user.signingkey committer@example.com &&
154+ git push --signed dst noop ff +noff &&
155+
156+ (
157+ cat <<-\EOF &&
158+ SIGNER=C O Mitter <committer@example.com>
159+ KEY=13B6F51ECDDE430D
160+ STATUS=G
161+ NONCE_STATUS=OK
162+ EOF
163+ sed -n -e "s/^nonce /NONCE=/p" -e "/^$/q" dst/push-cert
164+ ) >expect &&
165+
166+ grep "$(git rev-parse noop ff) refs/heads/ff" dst/push-cert &&
167+ grep "$(git rev-parse noop noff) refs/heads/noff" dst/push-cert &&
168+ test_cmp expect dst/push-cert-status
169+ '
170+
127171test_done
0 commit comments