]>
Commit | Line | Data |
---|---|---|
446c6fae RJ |
1 | #!/bin/sh |
2 | # | |
3 | # | |
4 | ||
5 | test_description='git-mktag: tag object verify test' | |
6 | ||
7 | . ./test-lib.sh | |
8 | ||
9 | ########################################################### | |
10 | # check the tag.sig file, expecting verify_tag() to fail, | |
11 | # and checking that the error message matches the pattern | |
12 | # given in the expect.pat file. | |
13 | ||
14 | check_verify_failure () { | |
e9b20943 JH |
15 | expect="$2" |
16 | test_expect_success "$1" ' | |
525d4615 BC |
17 | ( test_must_fail git-mktag <tag.sig 2>message ) && |
18 | grep "$expect" message | |
e9b20943 | 19 | ' |
446c6fae RJ |
20 | } |
21 | ||
22 | ########################################################### | |
23 | # first create a commit, so we have a valid object/type | |
24 | # for the tag. | |
25 | echo Hello >A | |
5be60078 | 26 | git update-index --add A |
446c6fae | 27 | git-commit -m "Initial commit" |
5be60078 | 28 | head=$(git rev-parse --verify HEAD) |
446c6fae RJ |
29 | |
30 | ############################################################ | |
31 | # 1. length check | |
32 | ||
33 | cat >tag.sig <<EOF | |
34 | too short for a tag | |
35 | EOF | |
36 | ||
e9b20943 JH |
37 | check_verify_failure 'Tag object length check' \ |
38 | '^error: .*size wrong.*$' | |
446c6fae RJ |
39 | |
40 | ############################################################ | |
41 | # 2. object line label check | |
42 | ||
43 | cat >tag.sig <<EOF | |
44 | xxxxxx 139e9b33986b1c2670fff52c5067603117b3e895 | |
45 | type tag | |
46 | tag mytag | |
e0aaf781 BC |
47 | tagger . <> 0 +0000 |
48 | ||
446c6fae RJ |
49 | EOF |
50 | ||
e9b20943 | 51 | check_verify_failure '"object" line label check' '^error: char0: .*"object "$' |
446c6fae RJ |
52 | |
53 | ############################################################ | |
54 | # 3. object line SHA1 check | |
55 | ||
56 | cat >tag.sig <<EOF | |
57 | object zz9e9b33986b1c2670fff52c5067603117b3e895 | |
58 | type tag | |
59 | tag mytag | |
e0aaf781 BC |
60 | tagger . <> 0 +0000 |
61 | ||
446c6fae RJ |
62 | EOF |
63 | ||
e9b20943 | 64 | check_verify_failure '"object" line SHA1 check' '^error: char7: .*SHA1 hash$' |
446c6fae RJ |
65 | |
66 | ############################################################ | |
67 | # 4. type line label check | |
68 | ||
69 | cat >tag.sig <<EOF | |
70 | object 779e9b33986b1c2670fff52c5067603117b3e895 | |
71 | xxxx tag | |
72 | tag mytag | |
e0aaf781 BC |
73 | tagger . <> 0 +0000 |
74 | ||
446c6fae RJ |
75 | EOF |
76 | ||
e9b20943 | 77 | check_verify_failure '"type" line label check' '^error: char47: .*"\\ntype "$' |
446c6fae RJ |
78 | |
79 | ############################################################ | |
80 | # 5. type line eol check | |
81 | ||
82 | echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig | |
2aad957a | 83 | printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig |
446c6fae | 84 | |
e9b20943 | 85 | check_verify_failure '"type" line eol check' '^error: char48: .*"\\n"$' |
446c6fae RJ |
86 | |
87 | ############################################################ | |
88 | # 6. tag line label check #1 | |
89 | ||
90 | cat >tag.sig <<EOF | |
91 | object 779e9b33986b1c2670fff52c5067603117b3e895 | |
92 | type tag | |
93 | xxx mytag | |
e0aaf781 BC |
94 | tagger . <> 0 +0000 |
95 | ||
446c6fae RJ |
96 | EOF |
97 | ||
e9b20943 JH |
98 | check_verify_failure '"tag" line label check #1' \ |
99 | '^error: char57: no "tag " found$' | |
446c6fae RJ |
100 | |
101 | ############################################################ | |
102 | # 7. tag line label check #2 | |
103 | ||
104 | cat >tag.sig <<EOF | |
105 | object 779e9b33986b1c2670fff52c5067603117b3e895 | |
106 | type taggggggggggggggggggggggggggggggg | |
107 | tag | |
108 | EOF | |
109 | ||
e9b20943 JH |
110 | check_verify_failure '"tag" line label check #2' \ |
111 | '^error: char87: no "tag " found$' | |
446c6fae RJ |
112 | |
113 | ############################################################ | |
114 | # 8. type line type-name length check | |
115 | ||
116 | cat >tag.sig <<EOF | |
117 | object 779e9b33986b1c2670fff52c5067603117b3e895 | |
118 | type taggggggggggggggggggggggggggggggg | |
119 | tag mytag | |
120 | EOF | |
121 | ||
e9b20943 JH |
122 | check_verify_failure '"type" line type-name length check' \ |
123 | '^error: char53: type too long$' | |
446c6fae RJ |
124 | |
125 | ############################################################ | |
126 | # 9. verify object (SHA1/type) check | |
127 | ||
128 | cat >tag.sig <<EOF | |
129 | object 779e9b33986b1c2670fff52c5067603117b3e895 | |
130 | type tagggg | |
131 | tag mytag | |
e0aaf781 BC |
132 | tagger . <> 0 +0000 |
133 | ||
446c6fae RJ |
134 | EOF |
135 | ||
e9b20943 JH |
136 | check_verify_failure 'verify object (SHA1/type) check' \ |
137 | '^error: char7: could not verify object.*$' | |
446c6fae RJ |
138 | |
139 | ############################################################ | |
140 | # 10. verify tag-name check | |
141 | ||
142 | cat >tag.sig <<EOF | |
143 | object $head | |
144 | type commit | |
145 | tag my tag | |
e0aaf781 BC |
146 | tagger . <> 0 +0000 |
147 | ||
446c6fae RJ |
148 | EOF |
149 | ||
e9b20943 JH |
150 | check_verify_failure 'verify tag-name check' \ |
151 | '^error: char67: could not verify tag name$' | |
446c6fae RJ |
152 | |
153 | ############################################################ | |
3dff5379 | 154 | # 11. tagger line label check #1 |
446c6fae RJ |
155 | |
156 | cat >tag.sig <<EOF | |
157 | object $head | |
158 | type commit | |
159 | tag mytag | |
e0aaf781 BC |
160 | |
161 | This is filler | |
446c6fae RJ |
162 | EOF |
163 | ||
e9b20943 | 164 | check_verify_failure '"tagger" line label check #1' \ |
e0aaf781 | 165 | '^error: char70: could not find "tagger "$' |
446c6fae RJ |
166 | |
167 | ############################################################ | |
3dff5379 | 168 | # 12. tagger line label check #2 |
446c6fae RJ |
169 | |
170 | cat >tag.sig <<EOF | |
171 | object $head | |
172 | type commit | |
173 | tag mytag | |
174 | tagger | |
e0aaf781 BC |
175 | |
176 | This is filler | |
446c6fae RJ |
177 | EOF |
178 | ||
e9b20943 | 179 | check_verify_failure '"tagger" line label check #2' \ |
e0aaf781 | 180 | '^error: char70: could not find "tagger "$' |
446c6fae RJ |
181 | |
182 | ############################################################ | |
ba26ab99 | 183 | # 13. disallow missing tag author name |
446c6fae RJ |
184 | |
185 | cat >tag.sig <<EOF | |
186 | object $head | |
187 | type commit | |
188 | tag mytag | |
e0aaf781 BC |
189 | tagger <> 0 +0000 |
190 | ||
191 | This is filler | |
192 | EOF | |
193 | ||
ba26ab99 | 194 | check_verify_failure 'disallow missing tag author name' \ |
e0aaf781 BC |
195 | '^error: char77: missing tagger name$' |
196 | ||
197 | ############################################################ | |
ba26ab99 | 198 | # 14. disallow missing tag author name |
e0aaf781 BC |
199 | |
200 | cat >tag.sig <<EOF | |
201 | object $head | |
202 | type commit | |
203 | tag mytag | |
204 | tagger T A Gger < | |
205 | > 0 +0000 | |
206 | ||
207 | EOF | |
208 | ||
ba26ab99 BC |
209 | check_verify_failure 'disallow malformed tagger' \ |
210 | '^error: char77: malformed tagger field$' | |
e0aaf781 BC |
211 | |
212 | ############################################################ | |
213 | # 15. allow empty tag email | |
214 | ||
215 | cat >tag.sig <<EOF | |
216 | object $head | |
217 | type commit | |
218 | tag mytag | |
219 | tagger T A Gger <> 0 +0000 | |
220 | ||
221 | EOF | |
222 | ||
223 | test_expect_success \ | |
224 | 'allow empty tag email' \ | |
225 | 'git-mktag <tag.sig >.git/refs/tags/mytag 2>message' | |
226 | ||
227 | ############################################################ | |
ba26ab99 BC |
228 | # 16. disallow spaces in tag email |
229 | ||
230 | cat >tag.sig <<EOF | |
231 | object $head | |
232 | type commit | |
233 | tag mytag | |
234 | tagger T A Gger <tag ger@example.com> 0 +0000 | |
235 | ||
236 | EOF | |
237 | ||
238 | check_verify_failure 'disallow spaces in tag email' \ | |
239 | '^error: char77: malformed tagger field$' | |
240 | ||
241 | ############################################################ | |
242 | # 17. disallow missing tag timestamp | |
e0aaf781 | 243 | |
74f16b0c | 244 | tr '_' ' ' >tag.sig <<EOF |
e0aaf781 BC |
245 | object $head |
246 | type commit | |
247 | tag mytag | |
74f16b0c | 248 | tagger T A Gger <tagger@example.com>__ |
e0aaf781 BC |
249 | |
250 | EOF | |
251 | ||
ba26ab99 BC |
252 | check_verify_failure 'disallow missing tag timestamp' \ |
253 | '^error: char107: missing tag timestamp$' | |
e0aaf781 BC |
254 | |
255 | ############################################################ | |
ba26ab99 | 256 | # 18. detect invalid tag timestamp1 |
e0aaf781 BC |
257 | |
258 | cat >tag.sig <<EOF | |
259 | object $head | |
260 | type commit | |
261 | tag mytag | |
262 | tagger T A Gger <tagger@example.com> Tue Mar 25 15:47:44 2008 | |
263 | ||
264 | EOF | |
265 | ||
ba26ab99 BC |
266 | check_verify_failure 'detect invalid tag timestamp1' \ |
267 | '^error: char107: missing tag timestamp$' | |
e0aaf781 BC |
268 | |
269 | ############################################################ | |
ba26ab99 BC |
270 | # 19. detect invalid tag timestamp2 |
271 | ||
272 | cat >tag.sig <<EOF | |
273 | object $head | |
274 | type commit | |
275 | tag mytag | |
276 | tagger T A Gger <tagger@example.com> 2008-03-31T12:20:15-0500 | |
277 | ||
278 | EOF | |
279 | ||
280 | check_verify_failure 'detect invalid tag timestamp2' \ | |
281 | '^error: char111: malformed tag timestamp$' | |
282 | ||
283 | ############################################################ | |
284 | # 20. detect invalid tag timezone1 | |
e0aaf781 BC |
285 | |
286 | cat >tag.sig <<EOF | |
287 | object $head | |
288 | type commit | |
289 | tag mytag | |
290 | tagger T A Gger <tagger@example.com> 1206478233 GMT | |
291 | ||
292 | EOF | |
293 | ||
ba26ab99 BC |
294 | check_verify_failure 'detect invalid tag timezone1' \ |
295 | '^error: char118: malformed tag timezone$' | |
296 | ||
297 | ############################################################ | |
298 | # 21. detect invalid tag timezone2 | |
299 | ||
300 | cat >tag.sig <<EOF | |
301 | object $head | |
302 | type commit | |
303 | tag mytag | |
304 | tagger T A Gger <tagger@example.com> 1206478233 + 30 | |
305 | ||
306 | EOF | |
307 | ||
308 | check_verify_failure 'detect invalid tag timezone2' \ | |
309 | '^error: char118: malformed tag timezone$' | |
310 | ||
311 | ############################################################ | |
312 | # 22. detect invalid tag timezone3 | |
313 | ||
314 | cat >tag.sig <<EOF | |
315 | object $head | |
316 | type commit | |
317 | tag mytag | |
318 | tagger T A Gger <tagger@example.com> 1206478233 -1430 | |
319 | ||
320 | EOF | |
321 | ||
322 | check_verify_failure 'detect invalid tag timezone3' \ | |
e0aaf781 BC |
323 | '^error: char118: malformed tag timezone$' |
324 | ||
325 | ############################################################ | |
ba26ab99 | 326 | # 23. detect invalid header entry |
e0aaf781 BC |
327 | |
328 | cat >tag.sig <<EOF | |
329 | object $head | |
330 | type commit | |
331 | tag mytag | |
332 | tagger T A Gger <tagger@example.com> 1206478233 -0500 | |
333 | this line should not be here | |
334 | ||
335 | EOF | |
336 | ||
337 | check_verify_failure 'detect invalid header entry' \ | |
338 | '^error: char124: trailing garbage in tag header$' | |
339 | ||
340 | ############################################################ | |
ba26ab99 | 341 | # 24. create valid tag |
e0aaf781 BC |
342 | |
343 | cat >tag.sig <<EOF | |
344 | object $head | |
345 | type commit | |
346 | tag mytag | |
347 | tagger T A Gger <tagger@example.com> 1206478233 -0500 | |
348 | ||
446c6fae RJ |
349 | EOF |
350 | ||
351 | test_expect_success \ | |
352 | 'create valid tag' \ | |
353 | 'git-mktag <tag.sig >.git/refs/tags/mytag 2>message' | |
354 | ||
355 | ############################################################ | |
ba26ab99 | 356 | # 25. check mytag |
446c6fae RJ |
357 | |
358 | test_expect_success \ | |
359 | 'check mytag' \ | |
360 | 'git-tag -l | grep mytag' | |
361 | ||
362 | ||
363 | test_done |