chiark / gitweb /
test suite: tagupl: Test lack of signature
[dgit.git] / tests / tests / tagupl
1 #!/bin/bash
2 set -e
3 . tests/lib
4
5 t-dependencies DEBORIG git-debpush
6
7 t-debpolicy
8
9 t-archive-none example
10 t-git-none
11 t-worktree 1.0
12
13 v=1.0-1
14
15 t-tagupl-settings
16
17 cd $p
18 git checkout -b native 
19
20 git checkout --orphan upstream quilt-tip-2
21 git rm -rf debian
22 git commit -m 'pseudo-upstream'
23 git tag upstream/1.0
24
25 git checkout -B master quilt-tip-2
26
27 upstream=$(git rev-parse upstream/1.0~0)
28 tagname=test-dummy/$v
29
30 t-tagupl-test --no-push --quilt=gbp
31
32 # xxx test pushing
33
34 # todo: test each miss/rejection
35
36 ident=ok
37
38 git cat-file tag $tagname >../basetag
39 v=1.0-2
40 tagname=test-dummy/$v
41
42 perl -i -ne '
43         next if $.==1../^$/;
44         next if m/^----/..0;
45         s/\b1\.0-1\b/1.0-2/g;
46         print or die $!;
47 ' ../basetag
48
49 mv-ident () {
50         local f=$tmp/$1
51         if test -e $f; then
52                 mv $f $f--$ident
53         fi
54 }
55
56 next-mangle () {
57         mv-ident tagupl/overall.log
58         mv-ident sendmail.log
59         ident=$1
60 }
61
62 with-mangled () {
63         local perl=$1
64         perl <../basetag >../badtag-$ident -pe "$perl"
65         git tag -u Senatus -f -s -m "$(cat ../badtag-$ident)" "$tagname"
66
67         t-tagupl-run-drs
68 }
69
70 expect-quit () {
71         next-mangle "$1"
72         local perl=$2
73         local mstring=$3
74         with-mangled "$perl"
75         grep ": $mstring" ../tagupl/overall.log
76 }
77
78 expect-email () {
79         next-mangle "$1"
80         local perl=$2
81         local mstring=$3
82         with-mangled "$perl"
83         grep 'Was not successful' ../sendmail.log
84         grep "$mstring" ../sendmail.log
85         grep ": failed, emailed" ../tagupl/overall.log
86 }
87
88 raw-mangled () {
89         git update-ref refs/tags/$tagname \
90                 $(git hash-object -w -t tag ../tagobj-$ident)
91         t-tagupl-run-drs
92 }
93
94 tagname=test-dummy/1.2
95 t-expect-fail E:'failed command: git fetch' \
96 t-tagupl-run-drs
97
98 tagname=splorf/$v     ; expect-quit baddistro '' 'tag name not for us'
99 tagname=test-dummy/1,2; expect-quit badver    '' 'tag name not for us'
100 tagname=test-dummy/$v
101
102 expect-quit noplease s/please-upload/plunk/ 'tag missing please-upload'
103
104 expect-email vermatch 's/^example release /$&3/' 'reject: version mismatch'
105
106 expect-email unkinfo 's/^\[dgit please-upload/$& Rejectme/' \
107         'unknown dgit info in tag'
108
109 expect-quit unkdistro 's/test-dummy/ubuntu/ if m/^\[dgit/' \
110         'not for this distro'
111
112 expect-email notsplit 's/ split / no-split /' 'reject: missing "split"'
113
114 expect-email upsnot1 's/ upstream=/ uxstream=/' \
115         'reject: upstream tag and not commitish'
116
117 expect-email upsnot2 's/ upstream-tag=/ uxstream-tag=/' \
118         'reject: upstream tag and not commitish'
119
120 expect-email bupstag1 's/ upstream-tag=/$&:/' \
121         "failed command: git check-ref-format"
122
123 expect-email bupstag2 's/ upstream-tag=/$&x/' \
124         "Couldn't find remote ref refs/tags/xupstream"
125
126 expect-email upsmism 's/ upstream=/$&3/' \
127         "but tag refers to"
128
129 # we are going to trash $p because it will contain corrupted objects
130 # which makes our end-of-test fsck fail
131 cp -al ../$p ../$p.save
132 cd ../$p
133
134 git cat-file tag $tagname >../raw-base
135
136 next-mangle sigfail
137 perl -pe <../raw-base >../tagobj-$ident 's/ split / split ignoreme /'
138 raw-mangled
139 grep 'gpgv: BAD signature' ../sendmail.log
140
141 next-mangle nosig
142 perl -ne <../raw-base >../tagobj-$ident 'print unless m/^-----/..0'
143 raw-mangled
144 grep 'missing signature' ../sendmail.log
145
146 git cat-file tag test-dummy/1.0-1 >../raw-base
147
148 next-mangle badtagger
149 perl -pe <../raw-base '
150         s/\+\d+$/xyz/ if m/^tagger /;
151         exit 0 if m/^$/;
152 ' >../tagobj-$ident
153 echo >>../tagobj-$ident
154 cat ../basetag >>../tagobj-$ident
155 raw-mangled
156 grep 'failed to fish tagger out of tag' ../tagupl/overall.log
157
158 cd ..
159 rm -rf $p
160 mv $p.save $p
161
162 t-ok