3 8e7bd50a 2019-08-22 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 8e7bd50a 2019-08-22 stsp # Permission to use, copy, modify, and distribute this software for any
6 8e7bd50a 2019-08-22 stsp # purpose with or without fee is hereby granted, provided that the above
7 8e7bd50a 2019-08-22 stsp # copyright notice and this permission notice appear in all copies.
9 8e7bd50a 2019-08-22 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 8e7bd50a 2019-08-22 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 8e7bd50a 2019-08-22 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 8e7bd50a 2019-08-22 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 8e7bd50a 2019-08-22 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 8e7bd50a 2019-08-22 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 8e7bd50a 2019-08-22 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 8e7bd50a 2019-08-22 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_tag_create() {
20 8e7bd50a 2019-08-22 stsp local testroot=`test_init tag_create`
21 8e7bd50a 2019-08-22 stsp local commit_id=`git_show_head $testroot/repo`
22 8e7bd50a 2019-08-22 stsp local tag=1.0.0
23 8e7bd50a 2019-08-22 stsp local tag2=2.0.0
25 8e7bd50a 2019-08-22 stsp # Create a tag based on repository's HEAD reference
26 80106605 2020-02-24 stsp got tag -m 'test' -r $testroot/repo -c HEAD $tag > $testroot/stdout
28 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
29 8e7bd50a 2019-08-22 stsp echo "got ref command failed unexpectedly"
30 8e7bd50a 2019-08-22 stsp test_done "$testroot" "$ret"
34 8e7bd50a 2019-08-22 stsp tag_id=`got ref -r $testroot/repo -l \
35 8e7bd50a 2019-08-22 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
36 8e7bd50a 2019-08-22 stsp echo "Created tag $tag_id" > $testroot/stdout.expected
37 8e7bd50a 2019-08-22 stsp cmp -s $testroot/stdout $testroot/stdout.expected
39 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
40 8e7bd50a 2019-08-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
41 8e7bd50a 2019-08-22 stsp test_done "$testroot" "$ret"
45 8e7bd50a 2019-08-22 stsp # Ensure that Git recognizes the tag Got has created
46 8e7bd50a 2019-08-22 stsp (cd $testroot/repo && git checkout -q $tag)
48 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
49 8e7bd50a 2019-08-22 stsp echo "git checkout command failed unexpectedly"
50 8e7bd50a 2019-08-22 stsp test_done "$testroot" "$ret"
54 8e7bd50a 2019-08-22 stsp # Ensure Got recognizes the new tag
55 8e7bd50a 2019-08-22 stsp got checkout -c $tag $testroot/repo $testroot/wt >/dev/null
57 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
58 8e7bd50a 2019-08-22 stsp echo "got checkout command failed unexpectedly"
59 8e7bd50a 2019-08-22 stsp test_done "$testroot" "$ret"
63 8e7bd50a 2019-08-22 stsp # Create a tag based on implied worktree HEAD ref
64 9f6b5e1c 2022-08-06 thomas (cd $testroot/wt && got branch foo > /dev/null)
65 9f6b5e1c 2022-08-06 thomas echo 'foo' >> $testroot/wt/alpha
66 9f6b5e1c 2022-08-06 thomas (cd $testroot/wt && got commit -m foo > /dev/null)
67 9f6b5e1c 2022-08-06 thomas local commit_id2=`git_show_branch_head $testroot/repo foo`
68 8e7bd50a 2019-08-22 stsp (cd $testroot/wt && got tag -m 'test' $tag2 > $testroot/stdout)
70 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
71 8e7bd50a 2019-08-22 stsp test_done "$testroot" "$ret"
75 8e7bd50a 2019-08-22 stsp tag_id2=`got ref -r $testroot/repo -l \
76 8e7bd50a 2019-08-22 stsp | grep "^refs/tags/$tag2" | tr -d ' ' | cut -d: -f2`
77 8e7bd50a 2019-08-22 stsp echo "Created tag $tag_id2" > $testroot/stdout.expected
78 8e7bd50a 2019-08-22 stsp cmp -s $testroot/stdout $testroot/stdout.expected
80 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
81 8e7bd50a 2019-08-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
82 8e7bd50a 2019-08-22 stsp test_done "$testroot" "$ret"
86 9f6b5e1c 2022-08-06 thomas tagged_commit=`got cat -r $testroot/repo $tag2 | grep ^object \
87 9f6b5e1c 2022-08-06 thomas | cut -d' ' -f2`
88 9f6b5e1c 2022-08-06 thomas if [ "$tagged_commit" != "$commit_id2" ]; then
89 9f6b5e1c 2022-08-06 thomas echo "wrong commit was tagged" >&2
90 9f6b5e1c 2022-08-06 thomas test_done "$testroot" "1"
94 8e7bd50a 2019-08-22 stsp (cd $testroot/repo && git checkout -q $tag2)
96 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
97 8e7bd50a 2019-08-22 stsp echo "git checkout command failed unexpectedly"
98 8e7bd50a 2019-08-22 stsp test_done "$testroot" "$ret"
102 8e7bd50a 2019-08-22 stsp # Attempt to create a tag pointing at a non-commit
103 8e7bd50a 2019-08-22 stsp local tree_id=`git_show_tree $testroot/repo`
104 80106605 2020-02-24 stsp (cd $testroot/wt && got tag -m 'test' -c $tree_id foobar \
105 8e7bd50a 2019-08-22 stsp 2> $testroot/stderr)
107 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
108 9f6b5e1c 2022-08-06 thomas echo "got tag command succeeded unexpectedly"
109 8e7bd50a 2019-08-22 stsp test_done "$testroot" "1"
113 a3599220 2021-10-10 thomas echo "got: commit $tree_id: object not found" \
114 a3599220 2021-10-10 thomas > $testroot/stderr.expected
115 8e7bd50a 2019-08-22 stsp cmp -s $testroot/stderr $testroot/stderr.expected
117 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
118 8e7bd50a 2019-08-22 stsp diff -u $testroot/stderr.expected $testroot/stderr
119 8e7bd50a 2019-08-22 stsp test_done "$testroot" "$ret"
123 8e7bd50a 2019-08-22 stsp got ref -r $testroot/repo -l > $testroot/stdout
124 9f6b5e1c 2022-08-06 thomas echo "HEAD: $commit_id2" > $testroot/stdout.expected
125 8e7bd50a 2019-08-22 stsp echo -n "refs/got/worktree/base-" >> $testroot/stdout.expected
126 8e7bd50a 2019-08-22 stsp cat $testroot/wt/.got/uuid | tr -d '\n' >> $testroot/stdout.expected
127 9f6b5e1c 2022-08-06 thomas echo ": $commit_id2" >> $testroot/stdout.expected
128 9f6b5e1c 2022-08-06 thomas echo "refs/heads/foo: $commit_id2" >> $testroot/stdout.expected
129 8e7bd50a 2019-08-22 stsp echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
130 8e7bd50a 2019-08-22 stsp echo "refs/tags/$tag: $tag_id" >> $testroot/stdout.expected
131 8e7bd50a 2019-08-22 stsp echo "refs/tags/$tag2: $tag_id2" >> $testroot/stdout.expected
132 8e7bd50a 2019-08-22 stsp cmp -s $testroot/stdout $testroot/stdout.expected
134 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
135 8e7bd50a 2019-08-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
137 8e7bd50a 2019-08-22 stsp test_done "$testroot" "$ret"
140 f6cae3ed 2020-09-13 naddy test_tag_list() {
141 8e7bd50a 2019-08-22 stsp local testroot=`test_init tag_list`
142 8e7bd50a 2019-08-22 stsp local commit_id=`git_show_head $testroot/repo`
143 8e7bd50a 2019-08-22 stsp local tag=1.0.0
144 8e7bd50a 2019-08-22 stsp local tag2=2.0.0
146 e8039a4a 2019-08-23 stsp # create tag with Git
147 8e7bd50a 2019-08-22 stsp (cd $testroot/repo && git tag -a -m 'test' $tag)
148 e8039a4a 2019-08-23 stsp # create tag with Got
149 e8039a4a 2019-08-23 stsp (cd $testroot/repo && got tag -m 'test' $tag2 > /dev/null)
151 8e7bd50a 2019-08-22 stsp tag_id=`got ref -r $testroot/repo -l \
152 8e7bd50a 2019-08-22 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
153 8e7bd50a 2019-08-22 stsp local tagger_time=`git_show_tagger_time $testroot/repo $tag`
154 1c72bab5 2023-03-03 thomas d1=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
155 8e7bd50a 2019-08-22 stsp tag_id2=`got ref -r $testroot/repo -l \
156 8e7bd50a 2019-08-22 stsp | grep "^refs/tags/$tag2" | tr -d ' ' | cut -d: -f2`
157 8e7bd50a 2019-08-22 stsp local tagger_time2=`git_show_tagger_time $testroot/repo $tag2`
158 1c72bab5 2023-03-03 thomas d2=`date -u -r $tagger_time2 +"%a %b %e %X %Y UTC"`
160 8e7bd50a 2019-08-22 stsp got tag -r $testroot/repo -l > $testroot/stdout
162 8e7bd50a 2019-08-22 stsp echo "-----------------------------------------------" \
163 8e7bd50a 2019-08-22 stsp > $testroot/stdout.expected
164 b8bad2ba 2019-08-23 stsp echo "tag $tag2 $tag_id2" >> $testroot/stdout.expected
165 8e7bd50a 2019-08-22 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
166 ac03cf6d 2020-01-17 stsp echo "date: $d2" >> $testroot/stdout.expected
167 2417344c 2019-08-23 stsp echo "object: commit $commit_id" >> $testroot/stdout.expected
168 8e7bd50a 2019-08-22 stsp echo " " >> $testroot/stdout.expected
169 8e7bd50a 2019-08-22 stsp echo " test" >> $testroot/stdout.expected
170 8e7bd50a 2019-08-22 stsp echo " " >> $testroot/stdout.expected
171 8e7bd50a 2019-08-22 stsp echo "-----------------------------------------------" \
172 8e7bd50a 2019-08-22 stsp >> $testroot/stdout.expected
173 68e8cedb 2022-07-01 thomas echo "tag $tag $tag_id" >> $testroot/stdout.expected
174 68e8cedb 2022-07-01 thomas echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
175 68e8cedb 2022-07-01 thomas echo "date: $d1" >> $testroot/stdout.expected
176 68e8cedb 2022-07-01 thomas echo "object: commit $commit_id" >> $testroot/stdout.expected
177 68e8cedb 2022-07-01 thomas echo " " >> $testroot/stdout.expected
178 68e8cedb 2022-07-01 thomas echo " test" >> $testroot/stdout.expected
179 68e8cedb 2022-07-01 thomas echo " " >> $testroot/stdout.expected
180 68e8cedb 2022-07-01 thomas cmp -s $testroot/stdout $testroot/stdout.expected
182 68e8cedb 2022-07-01 thomas if [ $ret -ne 0 ]; then
183 68e8cedb 2022-07-01 thomas diff -u $testroot/stdout.expected $testroot/stdout
184 68e8cedb 2022-07-01 thomas test_done "$testroot" "$ret"
188 68e8cedb 2022-07-01 thomas got tag -r $testroot/repo -l $tag > $testroot/stdout
190 68e8cedb 2022-07-01 thomas echo "-----------------------------------------------" \
191 68e8cedb 2022-07-01 thomas > $testroot/stdout.expected
192 b8bad2ba 2019-08-23 stsp echo "tag $tag $tag_id" >> $testroot/stdout.expected
193 8e7bd50a 2019-08-22 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
194 ac03cf6d 2020-01-17 stsp echo "date: $d1" >> $testroot/stdout.expected
195 2417344c 2019-08-23 stsp echo "object: commit $commit_id" >> $testroot/stdout.expected
196 8e7bd50a 2019-08-22 stsp echo " " >> $testroot/stdout.expected
197 8e7bd50a 2019-08-22 stsp echo " test" >> $testroot/stdout.expected
198 8e7bd50a 2019-08-22 stsp echo " " >> $testroot/stdout.expected
199 8e7bd50a 2019-08-22 stsp cmp -s $testroot/stdout $testroot/stdout.expected
201 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
202 8e7bd50a 2019-08-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
203 68e8cedb 2022-07-01 thomas test_done "$testroot" "$ret"
207 68e8cedb 2022-07-01 thomas got tag -r $testroot/repo -l $tag2 > $testroot/stdout
209 68e8cedb 2022-07-01 thomas echo "-----------------------------------------------" \
210 68e8cedb 2022-07-01 thomas > $testroot/stdout.expected
211 68e8cedb 2022-07-01 thomas echo "tag $tag2 $tag_id2" >> $testroot/stdout.expected
212 68e8cedb 2022-07-01 thomas echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
213 68e8cedb 2022-07-01 thomas echo "date: $d2" >> $testroot/stdout.expected
214 68e8cedb 2022-07-01 thomas echo "object: commit $commit_id" >> $testroot/stdout.expected
215 68e8cedb 2022-07-01 thomas echo " " >> $testroot/stdout.expected
216 68e8cedb 2022-07-01 thomas echo " test" >> $testroot/stdout.expected
217 68e8cedb 2022-07-01 thomas echo " " >> $testroot/stdout.expected
218 68e8cedb 2022-07-01 thomas cmp -s $testroot/stdout $testroot/stdout.expected
220 68e8cedb 2022-07-01 thomas if [ $ret -ne 0 ]; then
221 68e8cedb 2022-07-01 thomas diff -u $testroot/stdout.expected $testroot/stdout
223 8e7bd50a 2019-08-22 stsp test_done "$testroot" "$ret"
226 f6cae3ed 2020-09-13 naddy test_tag_list_lightweight() {
227 d4efa91b 2020-01-14 stsp local testroot=`test_init tag_list_lightweight`
228 d4efa91b 2020-01-14 stsp local commit_id=`git_show_head $testroot/repo`
229 d4efa91b 2020-01-14 stsp local tag=1.0.0
230 d4efa91b 2020-01-14 stsp local tag2=2.0.0
232 d4efa91b 2020-01-14 stsp # create "lightweight" tag with Git
233 d4efa91b 2020-01-14 stsp (cd $testroot/repo && git tag $tag)
234 d4efa91b 2020-01-14 stsp (cd $testroot/repo && git tag $tag2)
236 d4efa91b 2020-01-14 stsp tag_id=`got ref -r $testroot/repo -l \
237 d4efa91b 2020-01-14 stsp | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
238 d4efa91b 2020-01-14 stsp local tagger_time=`git_show_author_time $testroot/repo $tag`
239 1c72bab5 2023-03-03 thomas d1=`date -u -r $tagger_time +"%a %b %e %X %Y UTC"`
240 d4efa91b 2020-01-14 stsp tag_id2=`got ref -r $testroot/repo -l \
241 d4efa91b 2020-01-14 stsp | grep "^refs/tags/$tag2" | tr -d ' ' | cut -d: -f2`
242 d4efa91b 2020-01-14 stsp local tagger_time2=`git_show_author_time $testroot/repo $tag2`
243 1c72bab5 2023-03-03 thomas d2=`date -u -r $tagger_time2 +"%a %b %e %X %Y UTC"`
245 d4efa91b 2020-01-14 stsp got tag -r $testroot/repo -l > $testroot/stdout
247 06714b03 2022-09-02 thomas # test signature validation ignoring lightweight tags
248 06714b03 2022-09-02 thomas got tag -r $testroot/repo -V > $testroot/stdout
250 d4efa91b 2020-01-14 stsp echo "-----------------------------------------------" \
251 d4efa91b 2020-01-14 stsp > $testroot/stdout.expected
252 d4efa91b 2020-01-14 stsp echo "tag $tag2 $tag_id2" >> $testroot/stdout.expected
253 d4efa91b 2020-01-14 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
254 ac03cf6d 2020-01-17 stsp echo "date: $d2" >> $testroot/stdout.expected
255 d4efa91b 2020-01-14 stsp echo "object: commit $commit_id" >> $testroot/stdout.expected
256 d4efa91b 2020-01-14 stsp echo " " >> $testroot/stdout.expected
257 d4efa91b 2020-01-14 stsp echo " adding the test tree" >> $testroot/stdout.expected
258 d4efa91b 2020-01-14 stsp echo " " >> $testroot/stdout.expected
259 d4efa91b 2020-01-14 stsp echo "-----------------------------------------------" \
260 d4efa91b 2020-01-14 stsp >> $testroot/stdout.expected
261 d4efa91b 2020-01-14 stsp echo "tag $tag $tag_id" >> $testroot/stdout.expected
262 d4efa91b 2020-01-14 stsp echo "from: $GOT_AUTHOR" >> $testroot/stdout.expected
263 ac03cf6d 2020-01-17 stsp echo "date: $d1" >> $testroot/stdout.expected
264 d4efa91b 2020-01-14 stsp echo "object: commit $commit_id" >> $testroot/stdout.expected
265 d4efa91b 2020-01-14 stsp echo " " >> $testroot/stdout.expected
266 d4efa91b 2020-01-14 stsp echo " adding the test tree" >> $testroot/stdout.expected
267 d4efa91b 2020-01-14 stsp echo " " >> $testroot/stdout.expected
268 d4efa91b 2020-01-14 stsp cmp -s $testroot/stdout $testroot/stdout.expected
270 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
271 d4efa91b 2020-01-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
273 d4efa91b 2020-01-14 stsp test_done "$testroot" "$ret"
276 871bd038 2022-07-03 thomas test_tag_create_ssh_signed() {
277 871bd038 2022-07-03 thomas local testroot=`test_init tag_create`
278 871bd038 2022-07-03 thomas local commit_id=`git_show_head $testroot/repo`
279 871bd038 2022-07-03 thomas local tag=1.0.0
280 871bd038 2022-07-03 thomas local tag2=2.0.0
281 ff5e1f09 2022-07-06 thomas local tag3=3.0.0
283 871bd038 2022-07-03 thomas ssh-keygen -q -N '' -t ed25519 -f $testroot/id_ed25519
285 871bd038 2022-07-03 thomas if [ $ret -ne 0 ]; then
286 871bd038 2022-07-03 thomas echo "ssh-keygen failed unexpectedly"
287 871bd038 2022-07-03 thomas test_done "$testroot" "$ret"
290 871bd038 2022-07-03 thomas touch $testroot/allowed_signers
291 c0805ce5 2022-07-04 thomas touch $testroot/revoked_signers
292 c0805ce5 2022-07-04 thomas echo "allowed_signers \"$testroot/allowed_signers\"" >> \
293 c0805ce5 2022-07-04 thomas $testroot/repo/.git/got.conf
294 c0805ce5 2022-07-04 thomas echo "revoked_signers \"$testroot/revoked_signers\"" >> \
295 871bd038 2022-07-03 thomas $testroot/repo/.git/got.conf
297 871bd038 2022-07-03 thomas # Create a signed tag based on repository's HEAD reference
298 871bd038 2022-07-03 thomas got tag -s $testroot/id_ed25519 -m 'test' -r $testroot/repo -c HEAD \
299 871bd038 2022-07-03 thomas $tag > $testroot/stdout
301 871bd038 2022-07-03 thomas if [ $ret -ne 0 ]; then
302 871bd038 2022-07-03 thomas echo "got tag command failed unexpectedly"
303 871bd038 2022-07-03 thomas test_done "$testroot" "$ret"
307 871bd038 2022-07-03 thomas tag_id=`got ref -r $testroot/repo -l \
308 871bd038 2022-07-03 thomas | grep "^refs/tags/$tag" | tr -d ' ' | cut -d: -f2`
309 871bd038 2022-07-03 thomas echo "Created tag $tag_id" > $testroot/stdout.expected
310 871bd038 2022-07-03 thomas cmp -s $testroot/stdout $testroot/stdout.expected
312 871bd038 2022-07-03 thomas if [ $ret -ne 0 ]; then
313 871bd038 2022-07-03 thomas diff -u $testroot/stdout.expected $testroot/stdout
314 871bd038 2022-07-03 thomas test_done "$testroot" "$ret"
318 871bd038 2022-07-03 thomas # Ensure validation fails when the key is not allowed
319 871bd038 2022-07-03 thomas echo "signature: Could not verify signature." > \
320 871bd038 2022-07-03 thomas $testroot/stdout.expected
321 871bd038 2022-07-03 thomas VERIFY_STDOUT=$(got tag -r $testroot/repo -V $tag 2> $testroot/stderr)
323 871bd038 2022-07-03 thomas echo "$VERIFY_STDOUT" | grep '^signature: ' > $testroot/stdout
324 871bd038 2022-07-03 thomas if [ $ret -eq 0 ]; then
325 871bd038 2022-07-03 thomas diff -u $testroot/stdout.expected $testroot/stdout
326 871bd038 2022-07-03 thomas test_done "$testroot" "1"
330 ebc58f12 2022-07-04 thomas GOOD_SIG='Good "git" signature for flan_hacker@openbsd.org with ED25519 key '
332 871bd038 2022-07-03 thomas # Validate the signature with the key allowed
333 871bd038 2022-07-03 thomas echo -n 'flan_hacker@openbsd.org ' > $testroot/allowed_signers
334 871bd038 2022-07-03 thomas cat $testroot/id_ed25519.pub >> $testroot/allowed_signers
335 871bd038 2022-07-03 thomas GOT_STDOUT=$(got tag -r $testroot/repo -V $tag 2> $testroot/stderr)
337 871bd038 2022-07-03 thomas if [ $ret -ne 0 ]; then
338 871bd038 2022-07-03 thomas echo "got tag command failed unexpectedly"
339 871bd038 2022-07-03 thomas diff -u $testroot/stdout.expected $testroot/stdout
340 871bd038 2022-07-03 thomas test_done "$testroot" "$ret"
344 ebc58f12 2022-07-04 thomas if ! echo "$GOT_STDOUT" | grep -q "^signature: $GOOD_SIG"; then
345 ebc58f12 2022-07-04 thomas echo "got tag command failed to validate signature"
346 ebc58f12 2022-07-04 thomas test_done "$testroot" "1"
350 c0805ce5 2022-07-04 thomas # Ensure validation fails after revoking the key
351 c0805ce5 2022-07-04 thomas ssh-keygen -y -f $testroot/id_ed25519 >> $testroot/revoked_signers
352 c0805ce5 2022-07-04 thomas echo "signature: Could not verify signature." > \
353 c0805ce5 2022-07-04 thomas $testroot/stdout.expected
354 c0805ce5 2022-07-04 thomas VERIFY_STDOUT=$(got tag -r $testroot/repo -V $tag 2> $testroot/stderr)
356 c0805ce5 2022-07-04 thomas echo "$VERIFY_STDOUT" | grep '^signature: ' > $testroot/stdout
357 c0805ce5 2022-07-04 thomas if [ $ret -eq 0 ]; then
358 c0805ce5 2022-07-04 thomas diff -u $testroot/stdout.expected $testroot/stdout
359 c0805ce5 2022-07-04 thomas test_done "$testroot" "1"
363 c0805ce5 2022-07-04 thomas # Later tests expect validation to work
364 c0805ce5 2022-07-04 thomas echo -n > $testroot/revoked_signers
366 ebc58f12 2022-07-04 thomas # Ensure that Git recognizes and verifies the tag Got has created
367 ebc58f12 2022-07-04 thomas (cd $testroot/repo && git checkout -q $tag)
369 ebc58f12 2022-07-04 thomas if [ $ret -ne 0 ]; then
370 ebc58f12 2022-07-04 thomas echo "git checkout command failed unexpectedly"
371 ebc58f12 2022-07-04 thomas test_done "$testroot" "$ret"
374 ebc58f12 2022-07-04 thomas (cd $testroot/repo && git config --local gpg.ssh.allowedSignersFile \
375 ebc58f12 2022-07-04 thomas $testroot/allowed_signers)
376 ebc58f12 2022-07-04 thomas GIT_STDERR=$(cd $testroot/repo && git tag -v $tag 2>&1 1>/dev/null)
377 ebc58f12 2022-07-04 thomas if ! echo "$GIT_STDERR" | grep -q "^$GOOD_SIG"; then
378 ebc58f12 2022-07-04 thomas echo "git tag command failed to validate signature"
379 ebc58f12 2022-07-04 thomas test_done "$testroot" "1"
383 ebc58f12 2022-07-04 thomas # Ensure Got recognizes the new tag
384 ebc58f12 2022-07-04 thomas got checkout -c $tag $testroot/repo $testroot/wt >/dev/null
386 ebc58f12 2022-07-04 thomas if [ $ret -ne 0 ]; then
387 ebc58f12 2022-07-04 thomas echo "got checkout command failed unexpectedly"
388 ff5e1f09 2022-07-06 thomas test_done "$testroot" "$ret"
392 ff5e1f09 2022-07-06 thomas # Create another signed tag with a SHA1 commit ID
393 ff5e1f09 2022-07-06 thomas got tag -s $testroot/id_ed25519 -m 'test' -r $testroot/repo \
394 ff5e1f09 2022-07-06 thomas -c $commit_id $tag2 > $testroot/stdout
396 ff5e1f09 2022-07-06 thomas # Create another signed tag with key defined in got.conf(5)
397 ff5e1f09 2022-07-06 thomas echo "signer_id \"$testroot/id_ed25519\"" >> \
398 ff5e1f09 2022-07-06 thomas $testroot/repo/.git/got.conf
399 ff5e1f09 2022-07-06 thomas got tag -m 'test' -r $testroot/repo -c HEAD $tag3 > $testroot/stdout
401 ff5e1f09 2022-07-06 thomas if [ $ret -ne 0 ]; then
402 ff5e1f09 2022-07-06 thomas echo "got tag command failed unexpectedly"
403 ff5e1f09 2022-07-06 thomas test_done "$testroot" "$ret"
407 ff5e1f09 2022-07-06 thomas # got tag -V behaves like got tag -l, but with verification enabled.
408 ff5e1f09 2022-07-06 thomas got tag -l -r $testroot/repo > $testroot/stdout.list
409 ff5e1f09 2022-07-06 thomas got tag -V -r $testroot/repo > $testroot/stdout.verify
410 ff5e1f09 2022-07-06 thomas diff -U0 $testroot/stdout.list $testroot/stdout.verify |
411 ff5e1f09 2022-07-06 thomas sed -e '/^--- /d' -e '/^+++ /d' > $testroot/stdout
412 ff5e1f09 2022-07-06 thomas echo "@@ -5,0 +6 @@" > $testroot/stdout.expected
413 ff5e1f09 2022-07-06 thomas echo -n "+signature: $GOOD_SIG" >> $testroot/stdout.expected
414 ff5e1f09 2022-07-06 thomas ssh-keygen -l -f $testroot/id_ed25519.pub | cut -d' ' -f 2 \
415 ff5e1f09 2022-07-06 thomas >> $testroot/stdout.expected
416 ff5e1f09 2022-07-06 thomas echo "@@ -19,0 +21 @@" >> $testroot/stdout.expected
417 ff5e1f09 2022-07-06 thomas echo -n "+signature: $GOOD_SIG" >> $testroot/stdout.expected
418 ff5e1f09 2022-07-06 thomas ssh-keygen -l -f $testroot/id_ed25519.pub | cut -d' ' -f 2 \
419 ff5e1f09 2022-07-06 thomas >> $testroot/stdout.expected
420 ff5e1f09 2022-07-06 thomas echo "@@ -33,0 +36 @@" >> $testroot/stdout.expected
421 ff5e1f09 2022-07-06 thomas echo -n "+signature: $GOOD_SIG" >> $testroot/stdout.expected
422 ff5e1f09 2022-07-06 thomas ssh-keygen -l -f $testroot/id_ed25519.pub | cut -d' ' -f 2 \
423 ff5e1f09 2022-07-06 thomas >> $testroot/stdout.expected
424 ff5e1f09 2022-07-06 thomas cmp -s $testroot/stdout $testroot/stdout.expected
426 ff5e1f09 2022-07-06 thomas if [ $ret -ne 0 ]; then
427 ff5e1f09 2022-07-06 thomas diff -u $testroot/stdout.expected $testroot/stdout
429 ebc58f12 2022-07-04 thomas test_done "$testroot" "$ret"
432 64313a9c 2022-07-03 thomas test_tag_create_ssh_signed_missing_key() {
433 64313a9c 2022-07-03 thomas local testroot=`test_init tag_create`
434 64313a9c 2022-07-03 thomas local commit_id=`git_show_head $testroot/repo`
435 64313a9c 2022-07-03 thomas local tag=1.0.0
437 64313a9c 2022-07-03 thomas # Fail to create a signed tag due to a missing SSH key
438 64313a9c 2022-07-03 thomas got tag -s $testroot/bogus -m 'test' -r $testroot/repo \
439 64313a9c 2022-07-03 thomas -c HEAD $tag > $testroot/stdout 2> $testroot/stderr
441 64313a9c 2022-07-03 thomas if [ $ret -eq 0 ]; then
442 64313a9c 2022-07-03 thomas echo "got tag command succeeded unexpectedly"
443 64313a9c 2022-07-03 thomas test_done "$testroot" 1
447 64313a9c 2022-07-03 thomas got ref -r $testroot/repo -l > $testroot/stdout
448 64313a9c 2022-07-03 thomas echo "HEAD: refs/heads/master" > $testroot/stdout.expected
449 64313a9c 2022-07-03 thomas echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected
450 64313a9c 2022-07-03 thomas cmp -s $testroot/stdout $testroot/stdout.expected
452 64313a9c 2022-07-03 thomas if [ $ret -ne 0 ]; then
453 64313a9c 2022-07-03 thomas diff -u $testroot/stdout.expected $testroot/stdout
454 64313a9c 2022-07-03 thomas test_done "$testroot" "$ret"
457 64313a9c 2022-07-03 thomas printf "Couldn't load public key $testroot/bogus: " \
458 492a65d9 2022-07-04 thomas >> $testroot/stderr.expected
459 64313a9c 2022-07-03 thomas printf "No such file or directory\r\n" >> $testroot/stderr.expected
460 492a65d9 2022-07-04 thomas echo "got: unable to sign tag" >> $testroot/stderr.expected
461 64313a9c 2022-07-03 thomas cmp -s $testroot/stderr $testroot/stderr.expected
463 64313a9c 2022-07-03 thomas if [ $ret -ne 0 ]; then
464 64313a9c 2022-07-03 thomas diff -u $testroot/stderr.expected $testroot/stderr
466 64313a9c 2022-07-03 thomas test_done "$testroot" "$ret"
469 7fb414ae 2020-08-08 stsp test_parseargs "$@"
470 8e7bd50a 2019-08-22 stsp run_test test_tag_create
471 8e7bd50a 2019-08-22 stsp run_test test_tag_list
472 d4efa91b 2020-01-14 stsp run_test test_tag_list_lightweight
473 871bd038 2022-07-03 thomas run_test test_tag_create_ssh_signed
474 492a65d9 2022-07-04 thomas run_test test_tag_create_ssh_signed_missing_key