send-pack: send feature request on push-cert packet
[git/jrn.git] / t / t5534-push-signed.sh
blob659bca0d93edd89979eaf4e4ee931da4fa507b37
1 #!/bin/sh
3 test_description='signed push'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-gpg.sh
8 prepare_dst () {
9 rm -fr dst &&
10 test_create_repo dst &&
12 git push dst master:noop master:ff master:noff
15 test_expect_success setup '
16 # master, ff and noff branches pointing at the same commit
17 test_tick &&
18 git commit --allow-empty -m initial &&
20 git checkout -b noop &&
21 git checkout -b ff &&
22 git checkout -b noff &&
24 # noop stays the same, ff advances, noff rewrites
25 test_tick &&
26 git commit --allow-empty --amend -m rewritten &&
27 git checkout ff &&
29 test_tick &&
30 git commit --allow-empty -m second
33 test_expect_success 'unsigned push does not send push certificate' '
34 prepare_dst &&
35 mkdir -p dst/.git/hooks &&
36 write_script dst/.git/hooks/post-receive <<-\EOF &&
37 if test -n "${GIT_PUSH_CERT-}"
38 then
39 git cat-file blob $GIT_PUSH_CERT >../push-cert
41 EOF
43 git push dst noop ff +noff &&
44 test -f dst/push-cert &&
45 ! test -s dst/push-cert
48 test_expect_success GPG 'signed push sends push certificate' '
49 prepare_dst &&
50 mkdir -p dst/.git/hooks &&
51 write_script dst/.git/hooks/post-receive <<-\EOF &&
52 if test -n "${GIT_PUSH_CERT-}"
53 then
54 git cat-file blob $GIT_PUSH_CERT >../push-cert
55 fi &&
57 cat >../push-cert-status <<E_O_F
58 SIGNER=${GIT_PUSH_CERT_SIGNER-nobody}
59 KEY=${GIT_PUSH_CERT_KEY-nokey}
60 STATUS=${GIT_PUSH_CERT_STATUS-nostatus}
61 E_O_F
63 EOF
65 cat >expect <<-\EOF &&
66 SIGNER=C O Mitter <committer@example.com>
67 KEY=13B6F51ECDDE430D
68 STATUS=G
69 EOF
71 git push --signed dst noop ff +noff &&
72 grep "$(git rev-parse noop ff) refs/heads/ff" dst/push-cert &&
73 grep "$(git rev-parse noop noff) refs/heads/noff" dst/push-cert &&
74 test_cmp expect dst/push-cert-status
77 test_done