chiark / gitweb /
tests: drs-push-rejects: check that failures do not update any refs
[dgit.git] / tests / tests / drs-push-rejects
1 #!/bin/bash
2 set -e
3 . tests/lib
4
5 t-drs
6 t-git-none
7
8 p=pari-extra
9 t-worktree drs
10
11 cd $p
12
13 reporefs () {
14         (set -e
15         if test -d $tmp/git/$p.git; then
16                 cd $tmp/git/$p.git
17                 git show-ref
18         fi)
19 }
20
21 mustfail () {
22         local wantmsg="$1"; shift
23         reporefs >$tmp/show-refs.pre-push
24         set +e
25         git push origin "$@" 2>&1 |tee $tmp/mustfail.txt
26         ps="${PIPESTATUS[*]}"
27         set -e
28         case $ps in
29         "0 0")  fail "push unexpectedly succeeded: $*" ;;
30         *" 0")  ;;
31         *)      fail "tee failed"  ;;
32         esac
33         if ! fgrep "$wantmsg" $tmp/mustfail.txt >/dev/null; then
34                 fail "error message not found"
35         fi
36         reporefs >$tmp/show-refs.post-push
37         diff $tmp/show-refs.{pre,post}-push
38 }
39
40 prep () {
41         local suite=$1
42         local csuite=$2
43         cp $tmp/masters/* $tmp/.
44         tag_signer='-u Senatus'
45         tag_message="$p release $version for $suite ($csuite) [dgit]"
46         tag_name=debian/$version
47         push_spec1="HEAD:refs/dgit/$csuite"
48         push_spec2="refs/tags/$tag_name"
49         push_spec="$push_spec1 $push_spec2"
50 }
51 mktag () {
52         git tag -f $tag_signer -m "$tag_message" $tag_name "$@"
53 }
54
55 mkdir $tmp/masters
56 cp $tmp/d[dm].* $tmp/masters
57
58 version=3-2_dummy1
59
60 prep unstable sid
61 tag_signer='-a'
62 mktag
63 mustfail 'missing signature' $push_spec
64
65 prep unstable sid
66 tag_message='something'
67 mktag
68 mustfail 'tag message not in expected format' $push_spec
69
70 prep unstable sid
71 mktag
72 mustfail 'sid != sponge' HEAD:refs/dgit/sponge $push_spec2
73
74 # fixme test --sig-policy-url string
75 # fixme cannot test   reject "signature is not of type 00!";
76
77 prep unstable sid
78 mktag
79 mustfail 'push is missing tag ref update' $push_spec1
80 mustfail 'push is missing head ref update' $push_spec2
81 mustfail 'pushing unexpected ref' $push_spec HEAD:refs/wombat
82 mustfail 'pushing multiple heads' $push_spec HEAD:refs/dgit/wombat
83 mustfail 'pushing multiple tags' $push_spec HEAD:refs/tags/debian/wombat
84
85 prep unstable sid
86 mktag
87 cp $tmp/dm.gpg $tmp/dd.gpg
88 mustfail 'key not found in keyrings' $push_spec
89
90 prep unstable sid
91 git push origin $push_spec # succeeds
92 mktag
93 mustfail 'not replacing previously-pushed version' $push_spec
94
95 prep_dm_mangle () {
96         prep unstable sid
97         perl -i.bak -pe '
98                 next unless m/^fingerprint: 3A82860837A0CD32/i../^$/;
99         ' -e "$1" $tmp/dm.txt
100         tag_signer='-u Populus'
101         mktag
102 }
103
104 git checkout v2
105 version=3-2_dummy2
106
107 prep_dm_mangle 's/allow:/asponge:/i'
108 mustfail 'missing Allow section in permission' $push_spec
109
110 prep_dm_mangle 's/\bpari-extra\b/sponge/i'
111 mustfail "package $p not allowed for key" $push_spec
112
113 prep_dm_mangle 'y/0-9/5-90-4/ if m/^fingerprint:/i'
114 mustfail "not in permissions list although in keyring" $push_spec
115
116 prep_dm_mangle ''
117 git push origin $push_spec # succeeds
118
119 echo ok.