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