]>
Commit | Line | Data |
---|---|---|
7da4e228 SP |
1 | #!/bin/sh |
2 | ||
3 | test_description='test smart fetching over http via http-backend' | |
4 | . ./test-lib.sh | |
7da4e228 SP |
5 | . "$TEST_DIRECTORY"/lib-httpd.sh |
6 | start_httpd | |
7 | ||
8 | test_expect_success 'setup repository' ' | |
bd7ac599 | 9 | git config push.default matching && |
7da4e228 SP |
10 | echo content >file && |
11 | git add file && | |
12 | git commit -m one | |
13 | ' | |
14 | ||
15 | test_expect_success 'create http-accessible bare repository' ' | |
16 | mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && | |
17 | (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && | |
18 | git --bare init | |
19 | ) && | |
20 | git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && | |
21 | git push public master:master | |
22 | ' | |
23 | ||
6ac2b3ae JK |
24 | setup_askpass_helper |
25 | ||
7da4e228 | 26 | test_expect_success 'clone http repository' ' |
92b7fd87 TG |
27 | cat >exp <<-\EOF && |
28 | > GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 | |
29 | > Accept: */* | |
30 | > Accept-Encoding: ENCODINGS | |
31 | > Pragma: no-cache | |
32 | < HTTP/1.1 200 OK | |
33 | < Pragma: no-cache | |
34 | < Cache-Control: no-cache, max-age=0, must-revalidate | |
35 | < Content-Type: application/x-git-upload-pack-advertisement | |
36 | > POST /smart/repo.git/git-upload-pack HTTP/1.1 | |
37 | > Accept-Encoding: ENCODINGS | |
38 | > Content-Type: application/x-git-upload-pack-request | |
39 | > Accept: application/x-git-upload-pack-result | |
40 | > Content-Length: xxx | |
41 | < HTTP/1.1 200 OK | |
42 | < Pragma: no-cache | |
43 | < Cache-Control: no-cache, max-age=0, must-revalidate | |
44 | < Content-Type: application/x-git-upload-pack-result | |
45 | EOF | |
8a1b0978 | 46 | GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION=0 \ |
8cbeba06 | 47 | git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err && |
7da4e228 SP |
48 | test_cmp file clone/file && |
49 | tr '\''\015'\'' Q <err | | |
50 | sed -e " | |
51 | s/Q\$// | |
52 | /^[*] /d | |
14e24114 EP |
53 | /^== Info:/d |
54 | /^=> Send header, /d | |
55 | /^=> Send header:$/d | |
56 | /^<= Recv header, /d | |
57 | /^<= Recv header:$/d | |
58 | s/=> Send header: // | |
59 | s/= Recv header:// | |
60 | /^<= Recv data/d | |
61 | /^=> Send data/d | |
0a8fcbdc SP |
62 | /^$/d |
63 | /^< $/d | |
7da4e228 SP |
64 | |
65 | /^[^><]/{ | |
66 | s/^/> / | |
67 | } | |
68 | ||
69 | /^> User-Agent: /d | |
70 | /^> Host: /d | |
20366635 SP |
71 | /^> POST /,$ { |
72 | /^> Accept: [*]\\/[*]/d | |
73 | } | |
7da4e228 | 74 | s/^> Content-Length: .*/> Content-Length: xxx/ |
0a8fcbdc SP |
75 | /^> 00..want /d |
76 | /^> 00.*done/d | |
7da4e228 SP |
77 | |
78 | /^< Server: /d | |
79 | /^< Expires: /d | |
80 | /^< Date: /d | |
81 | /^< Content-Length: /d | |
82 | /^< Transfer-Encoding: /d | |
1a53e692 | 83 | " >actual && |
1a53e692 | 84 | |
d790ee17 JT |
85 | # NEEDSWORK: If the overspecification of the expected result is reduced, we |
86 | # might be able to run this test in all protocol versions. | |
8a1b0978 | 87 | if test "$GIT_TEST_PROTOCOL_VERSION" = 0 |
d790ee17 JT |
88 | then |
89 | sed -e "s/^> Accept-Encoding: .*/> Accept-Encoding: ENCODINGS/" \ | |
90 | actual >actual.smudged && | |
91 | test_cmp exp actual.smudged && | |
92 | ||
93 | grep "Accept-Encoding:.*gzip" actual >actual.gzip && | |
94 | test_line_count = 2 actual.gzip | |
95 | fi | |
7da4e228 SP |
96 | ' |
97 | ||
98 | test_expect_success 'fetch changes via http' ' | |
99 | echo content >>file && | |
100 | git commit -a -m two && | |
99094a7a | 101 | git push public && |
7da4e228 SP |
102 | (cd clone && git pull) && |
103 | test_cmp file clone/file | |
104 | ' | |
105 | ||
7da4e228 | 106 | test_expect_success 'used upload-pack service' ' |
92b7fd87 TG |
107 | cat >exp <<-\EOF && |
108 | GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200 | |
109 | POST /smart/repo.git/git-upload-pack HTTP/1.1 200 | |
110 | GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200 | |
111 | POST /smart/repo.git/git-upload-pack HTTP/1.1 200 | |
112 | EOF | |
d790ee17 JT |
113 | |
114 | # NEEDSWORK: If the overspecification of the expected result is reduced, we | |
115 | # might be able to run this test in all protocol versions. | |
8a1b0978 | 116 | if test "$GIT_TEST_PROTOCOL_VERSION" = 0 |
d790ee17 JT |
117 | then |
118 | check_access_log exp | |
119 | fi | |
7da4e228 SP |
120 | ' |
121 | ||
311e2ea0 TRC |
122 | test_expect_success 'follow redirects (301)' ' |
123 | git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p | |
124 | ' | |
125 | ||
126 | test_expect_success 'follow redirects (302)' ' | |
127 | git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t | |
128 | ' | |
129 | ||
050ef365 JK |
130 | test_expect_success 'redirects re-root further requests' ' |
131 | git clone $HTTPD_URL/smart-redir-limited/repo.git repo-redir-limited | |
132 | ' | |
133 | ||
6628eb41 JK |
134 | test_expect_success 're-rooting dies on insane schemes' ' |
135 | test_must_fail git clone $HTTPD_URL/insane-redir/repo.git insane | |
136 | ' | |
137 | ||
6ac2b3ae JK |
138 | test_expect_success 'clone from password-protected repository' ' |
139 | echo two >expect && | |
afbf5ca5 | 140 | set_askpass user@host pass@host && |
6ac2b3ae JK |
141 | git clone --bare "$HTTPD_URL/auth/smart/repo.git" smart-auth && |
142 | expect_askpass both user@host && | |
143 | git --git-dir=smart-auth log -1 --format=%s >actual && | |
144 | test_cmp expect actual | |
145 | ' | |
146 | ||
4c71009d JK |
147 | test_expect_success 'clone from auth-only-for-push repository' ' |
148 | echo two >expect && | |
149 | set_askpass wrong && | |
150 | git clone --bare "$HTTPD_URL/auth-push/smart/repo.git" smart-noauth && | |
151 | expect_askpass none && | |
152 | git --git-dir=smart-noauth log -1 --format=%s >actual && | |
153 | test_cmp expect actual | |
154 | ' | |
155 | ||
2e736fd5 JK |
156 | test_expect_success 'clone from auth-only-for-objects repository' ' |
157 | echo two >expect && | |
afbf5ca5 | 158 | set_askpass user@host pass@host && |
2e736fd5 JK |
159 | git clone --bare "$HTTPD_URL/auth-fetch/smart/repo.git" half-auth && |
160 | expect_askpass both user@host && | |
161 | git --git-dir=half-auth log -1 --format=%s >actual && | |
162 | test_cmp expect actual | |
163 | ' | |
164 | ||
165 | test_expect_success 'no-op half-auth fetch does not require a password' ' | |
166 | set_askpass wrong && | |
3a9e1ad7 JT |
167 | |
168 | # NEEDSWORK: When using HTTP(S), protocol v0 supports a "half-auth" | |
169 | # configuration with authentication required only when downloading | |
170 | # objects and not refs, by having the HTTP server only require | |
171 | # authentication for the "git-upload-pack" path and not "info/refs". | |
172 | # This is not possible with protocol v2, since both objects and refs | |
173 | # are obtained from the "git-upload-pack" path. A solution to this is | |
174 | # to teach the server and client to be able to inline ls-refs requests | |
175 | # as an Extra Parameter (see pack-protocol.txt), so that "info/refs" | |
176 | # can serve refs, just like it does in protocol v0. | |
177 | GIT_TEST_PROTOCOL_VERSION=0 git --git-dir=half-auth fetch && | |
2e736fd5 JK |
178 | expect_askpass none |
179 | ' | |
180 | ||
050ef365 | 181 | test_expect_success 'redirects send auth to new location' ' |
afbf5ca5 | 182 | set_askpass user@host pass@host && |
050ef365 JK |
183 | git -c credential.useHttpPath=true \ |
184 | clone $HTTPD_URL/smart-redir-auth/repo.git repo-redir-auth && | |
185 | expect_askpass both user@host auth/smart/repo.git | |
186 | ' | |
187 | ||
373e9bd6 JT |
188 | test_expect_success 'GIT_TRACE_CURL redacts auth details' ' |
189 | rm -rf redact-auth trace && | |
190 | set_askpass user@host pass@host && | |
191 | GIT_TRACE_CURL="$(pwd)/trace" git clone --bare "$HTTPD_URL/auth/smart/repo.git" redact-auth && | |
192 | expect_askpass both user@host && | |
193 | ||
194 | # Ensure that there is no "Basic" followed by a base64 string, but that | |
195 | # the auth details are redacted | |
196 | ! grep "Authorization: Basic [0-9a-zA-Z+/]" trace && | |
197 | grep "Authorization: Basic <redacted>" trace | |
198 | ' | |
199 | ||
7167a62b JT |
200 | test_expect_success 'GIT_CURL_VERBOSE redacts auth details' ' |
201 | rm -rf redact-auth trace && | |
202 | set_askpass user@host pass@host && | |
203 | GIT_CURL_VERBOSE=1 git clone --bare "$HTTPD_URL/auth/smart/repo.git" redact-auth 2>trace && | |
204 | expect_askpass both user@host && | |
205 | ||
206 | # Ensure that there is no "Basic" followed by a base64 string, but that | |
207 | # the auth details are redacted | |
208 | ! grep "Authorization: Basic [0-9a-zA-Z+/]" trace && | |
209 | grep "Authorization: Basic <redacted>" trace | |
210 | ' | |
211 | ||
827e7d4d JT |
212 | test_expect_success 'GIT_TRACE_CURL does not redact auth details if GIT_TRACE_REDACT=0' ' |
213 | rm -rf redact-auth trace && | |
214 | set_askpass user@host pass@host && | |
215 | GIT_TRACE_REDACT=0 GIT_TRACE_CURL="$(pwd)/trace" \ | |
216 | git clone --bare "$HTTPD_URL/auth/smart/repo.git" redact-auth && | |
217 | expect_askpass both user@host && | |
218 | ||
219 | grep "Authorization: Basic [0-9a-zA-Z+/]" trace | |
220 | ' | |
221 | ||
02572c2e JK |
222 | test_expect_success 'disable dumb http on server' ' |
223 | git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \ | |
224 | config http.getanyfile false | |
225 | ' | |
226 | ||
227 | test_expect_success 'GIT_SMART_HTTP can disable smart http' ' | |
228 | (GIT_SMART_HTTP=0 && | |
229 | export GIT_SMART_HTTP && | |
230 | cd clone && | |
231 | test_must_fail git fetch) | |
232 | ' | |
233 | ||
4656bf47 | 234 | test_expect_success 'invalid Content-Type rejected' ' |
8fb26872 | 235 | test_must_fail git clone $HTTPD_URL/broken_smart/repo.git 2>actual && |
e532a90a | 236 | test_i18ngrep "not valid:" actual |
4656bf47 SP |
237 | ' |
238 | ||
6130f86d JK |
239 | test_expect_success 'create namespaced refs' ' |
240 | test_commit namespaced && | |
241 | git push public HEAD:refs/namespaces/ns/refs/heads/master && | |
242 | git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \ | |
243 | symbolic-ref refs/namespaces/ns/HEAD refs/namespaces/ns/refs/heads/master | |
244 | ' | |
245 | ||
246 | test_expect_success 'smart clone respects namespace' ' | |
247 | git clone "$HTTPD_URL/smart_namespace/repo.git" ns-smart && | |
248 | echo namespaced >expect && | |
249 | git --git-dir=ns-smart/.git log -1 --format=%s >actual && | |
250 | test_cmp expect actual | |
251 | ' | |
252 | ||
253 | test_expect_success 'dumb clone via http-backend respects namespace' ' | |
254 | git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \ | |
255 | config http.getanyfile true && | |
256 | GIT_SMART_HTTP=0 git clone \ | |
257 | "$HTTPD_URL/smart_namespace/repo.git" ns-dumb && | |
258 | echo namespaced >expect && | |
259 | git --git-dir=ns-dumb/.git log -1 --format=%s >actual && | |
260 | test_cmp expect actual | |
261 | ' | |
262 | ||
912b2acf | 263 | test_expect_success 'cookies stored in http.cookiefile when http.savecookies set' ' |
92b7fd87 TG |
264 | cat >cookies.txt <<-\EOF && |
265 | 127.0.0.1 FALSE /smart_cookies/ FALSE 0 othername othervalue | |
266 | EOF | |
29e8dc50 | 267 | sort >expect_cookies.txt <<-\EOF && |
92b7fd87 TG |
268 | |
269 | 127.0.0.1 FALSE /smart_cookies/ FALSE 0 othername othervalue | |
270 | 127.0.0.1 FALSE /smart_cookies/repo.git/info/ FALSE 0 name value | |
271 | EOF | |
912b2acf DB |
272 | git config http.cookiefile cookies.txt && |
273 | git config http.savecookies true && | |
274 | git ls-remote $HTTPD_URL/smart_cookies/repo.git master && | |
d790ee17 JT |
275 | |
276 | # NEEDSWORK: If the overspecification of the expected result is reduced, we | |
277 | # might be able to run this test in all protocol versions. | |
8a1b0978 | 278 | if test "$GIT_TEST_PROTOCOL_VERSION" = 0 |
d790ee17 JT |
279 | then |
280 | tail -3 cookies.txt | sort >cookies_tail.txt && | |
281 | test_cmp expect_cookies.txt cookies_tail.txt | |
282 | fi | |
912b2acf DB |
283 | ' |
284 | ||
e172755b JK |
285 | test_expect_success 'transfer.hiderefs works over smart-http' ' |
286 | test_commit hidden && | |
287 | test_commit visible && | |
288 | git push public HEAD^:refs/heads/a HEAD:refs/heads/b && | |
289 | git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \ | |
290 | config transfer.hiderefs refs/heads/a && | |
291 | git clone --bare "$HTTPD_URL/smart/repo.git" hidden.git && | |
292 | test_must_fail git -C hidden.git rev-parse --verify a && | |
293 | git -C hidden.git rev-parse --verify b | |
294 | ' | |
295 | ||
cc969c8d JK |
296 | # create an arbitrary number of tags, numbered from tag-$1 to tag-$2 |
297 | create_tags () { | |
298 | rm -f marks && | |
299 | for i in $(test_seq "$1" "$2") | |
7103d254 | 300 | do |
cc969c8d JK |
301 | # don't use here-doc, because it requires a process |
302 | # per loop iteration | |
303 | echo "commit refs/heads/too-many-refs-$1" && | |
304 | echo "mark :$i" && | |
305 | echo "committer git <git@example.com> $i +0000" && | |
306 | echo "data 0" && | |
307 | echo "M 644 inline bla.txt" && | |
308 | echo "data 4" && | |
309 | echo "bla" && | |
7103d254 IT |
310 | # make every commit dangling by always |
311 | # rewinding the branch after each commit | |
cc969c8d JK |
312 | echo "reset refs/heads/too-many-refs-$1" && |
313 | echo "from :$1" | |
7103d254 IT |
314 | done | git fast-import --export-marks=marks && |
315 | ||
316 | # now assign tags to all the dangling commits we created above | |
94221d22 | 317 | tag=$(perl -e "print \"bla\" x 30") && |
5e2c7cd2 | 318 | sed -e "s|^:\([^ ]*\) \(.*\)$|\2 refs/tags/$tag-\1|" <marks >>packed-refs |
cc969c8d JK |
319 | } |
320 | ||
7419a03f | 321 | test_expect_success 'create 2,000 tags in the repo' ' |
cc969c8d JK |
322 | ( |
323 | cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && | |
7419a03f | 324 | create_tags 1 2000 |
7103d254 IT |
325 | ) |
326 | ' | |
327 | ||
376e4b39 JK |
328 | test_expect_success CMDLINE_LIMIT \ |
329 | 'clone the 2,000 tag repo to check OS command line overflow' ' | |
330 | run_with_limited_cmdline git clone $HTTPD_URL/smart/repo.git too-many-refs && | |
5e2c7cd2 JH |
331 | ( |
332 | cd too-many-refs && | |
376e4b39 JK |
333 | git for-each-ref refs/tags >actual && |
334 | test_line_count = 2000 actual | |
5e2c7cd2 | 335 | ) |
7103d254 IT |
336 | ' |
337 | ||
8d45ad8c | 338 | test_expect_success 'large fetch-pack requests can be sent using chunked encoding' ' |
14e24114 | 339 | GIT_TRACE_CURL=true git -c http.postbuffer=65536 \ |
376e4b39 | 340 | clone --bare "$HTTPD_URL/smart/repo.git" split.git 2>err && |
8d45ad8c | 341 | grep "^=> Send header: Transfer-Encoding: chunked" err |
376e4b39 JK |
342 | ' |
343 | ||
296b847c DT |
344 | test_expect_success 'test allowreachablesha1inwant' ' |
345 | test_when_finished "rm -rf test_reachable.git" && | |
346 | server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && | |
347 | master_sha=$(git -C "$server" rev-parse refs/heads/master) && | |
348 | git -C "$server" config uploadpack.allowreachablesha1inwant 1 && | |
349 | ||
350 | git init --bare test_reachable.git && | |
351 | git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" && | |
352 | git -C test_reachable.git fetch origin "$master_sha" | |
353 | ' | |
354 | ||
355 | test_expect_success 'test allowreachablesha1inwant with unreachable' ' | |
356 | test_when_finished "rm -rf test_reachable.git; git reset --hard $(git rev-parse HEAD)" && | |
357 | ||
358 | #create unreachable sha | |
359 | echo content >file2 && | |
360 | git add file2 && | |
361 | git commit -m two && | |
362 | git push public HEAD:refs/heads/doomed && | |
363 | git push public :refs/heads/doomed && | |
364 | ||
365 | server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && | |
366 | master_sha=$(git -C "$server" rev-parse refs/heads/master) && | |
367 | git -C "$server" config uploadpack.allowreachablesha1inwant 1 && | |
368 | ||
369 | git init --bare test_reachable.git && | |
370 | git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" && | |
ab0c5f50 JT |
371 | # Some protocol versions (e.g. 2) support fetching |
372 | # unadvertised objects, so restrict this test to v0. | |
8a1b0978 | 373 | test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \ |
ab0c5f50 | 374 | git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" |
296b847c DT |
375 | ' |
376 | ||
f8edeaa0 DT |
377 | test_expect_success 'test allowanysha1inwant with unreachable' ' |
378 | test_when_finished "rm -rf test_reachable.git; git reset --hard $(git rev-parse HEAD)" && | |
379 | ||
380 | #create unreachable sha | |
381 | echo content >file2 && | |
382 | git add file2 && | |
383 | git commit -m two && | |
384 | git push public HEAD:refs/heads/doomed && | |
385 | git push public :refs/heads/doomed && | |
386 | ||
387 | server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && | |
388 | master_sha=$(git -C "$server" rev-parse refs/heads/master) && | |
389 | git -C "$server" config uploadpack.allowreachablesha1inwant 1 && | |
390 | ||
391 | git init --bare test_reachable.git && | |
392 | git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" && | |
ab0c5f50 JT |
393 | # Some protocol versions (e.g. 2) support fetching |
394 | # unadvertised objects, so restrict this test to v0. | |
8a1b0978 | 395 | test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \ |
ab0c5f50 | 396 | git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" && |
f8edeaa0 DT |
397 | |
398 | git -C "$server" config uploadpack.allowanysha1inwant 1 && | |
399 | git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" | |
400 | ' | |
401 | ||
6bc0cb51 | 402 | test_expect_success EXPENSIVE 'http can handle enormous ref negotiation' ' |
7419a03f JH |
403 | ( |
404 | cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && | |
405 | create_tags 2001 50000 | |
406 | ) && | |
6bc0cb51 JK |
407 | git -C too-many-refs fetch -q --tags && |
408 | ( | |
409 | cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && | |
410 | create_tags 50001 100000 | |
411 | ) && | |
412 | git -C too-many-refs fetch -q --tags && | |
413 | git -C too-many-refs for-each-ref refs/tags >tags && | |
414 | test_line_count = 100000 tags | |
415 | ' | |
416 | ||
8cb01e2f | 417 | test_expect_success 'custom http headers' ' |
e31165ce JS |
418 | test_must_fail git -c http.extraheader="x-magic-two: cadabra" \ |
419 | fetch "$HTTPD_URL/smart_headers/repo.git" && | |
8cb01e2f JS |
420 | git -c http.extraheader="x-magic-one: abra" \ |
421 | -c http.extraheader="x-magic-two: cadabra" \ | |
0bbe7317 JS |
422 | fetch "$HTTPD_URL/smart_headers/repo.git" && |
423 | git update-index --add --cacheinfo 160000,$(git rev-parse HEAD),sub && | |
424 | git config -f .gitmodules submodule.sub.path sub && | |
425 | git config -f .gitmodules submodule.sub.url \ | |
426 | "$HTTPD_URL/smart_headers/repo.git" && | |
427 | git submodule init sub && | |
428 | test_must_fail git submodule update sub && | |
429 | git -c http.extraheader="x-magic-one: abra" \ | |
430 | -c http.extraheader="x-magic-two: cadabra" \ | |
431 | submodule update sub | |
8cb01e2f JS |
432 | ' |
433 | ||
e2842b39 JT |
434 | test_expect_success 'using fetch command in remote-curl updates refs' ' |
435 | SERVER="$HTTPD_DOCUMENT_ROOT_PATH/twobranch" && | |
436 | rm -rf "$SERVER" client && | |
437 | ||
438 | git init "$SERVER" && | |
439 | test_commit -C "$SERVER" foo && | |
440 | git -C "$SERVER" update-ref refs/heads/anotherbranch foo && | |
441 | ||
442 | git clone $HTTPD_URL/smart/twobranch client && | |
443 | ||
444 | test_commit -C "$SERVER" bar && | |
445 | git -C client -c protocol.version=0 fetch && | |
446 | ||
447 | git -C "$SERVER" rev-parse master >expect && | |
448 | git -C client rev-parse origin/master >actual && | |
449 | test_cmp expect actual | |
450 | ' | |
451 | ||
e70a3030 JT |
452 | test_expect_success 'fetch by SHA-1 without tag following' ' |
453 | SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" && | |
454 | rm -rf "$SERVER" client && | |
455 | ||
456 | git init "$SERVER" && | |
457 | test_commit -C "$SERVER" foo && | |
458 | ||
459 | git clone $HTTPD_URL/smart/server client && | |
460 | ||
461 | test_commit -C "$SERVER" bar && | |
462 | git -C "$SERVER" rev-parse bar >bar_hash && | |
463 | git -C client -c protocol.version=0 fetch \ | |
464 | --no-tags origin $(cat bar_hash) | |
465 | ' | |
466 | ||
827e7d4d | 467 | test_expect_success 'cookies are redacted by default' ' |
83411783 JT |
468 | rm -rf clone && |
469 | echo "Set-Cookie: Foo=1" >cookies && | |
470 | echo "Set-Cookie: Bar=2" >>cookies && | |
827e7d4d | 471 | GIT_TRACE_CURL=true \ |
7167a62b JT |
472 | git -c "http.cookieFile=$(pwd)/cookies" clone \ |
473 | $HTTPD_URL/smart/repo.git clone 2>err && | |
827e7d4d | 474 | grep "Cookie:.*Foo=<redacted>" err && |
7167a62b | 475 | grep "Cookie:.*Bar=<redacted>" err && |
827e7d4d | 476 | ! grep "Cookie:.*Foo=1" err && |
7167a62b JT |
477 | ! grep "Cookie:.*Bar=2" err |
478 | ' | |
479 | ||
827e7d4d | 480 | test_expect_success 'empty values of cookies are also redacted' ' |
7167a62b | 481 | rm -rf clone && |
827e7d4d JT |
482 | echo "Set-Cookie: Foo=" >cookies && |
483 | GIT_TRACE_CURL=true \ | |
83411783 JT |
484 | git -c "http.cookieFile=$(pwd)/cookies" clone \ |
485 | $HTTPD_URL/smart/repo.git clone 2>err && | |
827e7d4d | 486 | grep "Cookie:.*Foo=<redacted>" err |
83411783 JT |
487 | ' |
488 | ||
827e7d4d | 489 | test_expect_success 'GIT_TRACE_REDACT=0 disables cookie redaction' ' |
83411783 | 490 | rm -rf clone && |
827e7d4d JT |
491 | echo "Set-Cookie: Foo=1" >cookies && |
492 | echo "Set-Cookie: Bar=2" >>cookies && | |
493 | GIT_TRACE_REDACT=0 GIT_TRACE_CURL=true \ | |
83411783 JT |
494 | git -c "http.cookieFile=$(pwd)/cookies" clone \ |
495 | $HTTPD_URL/smart/repo.git clone 2>err && | |
827e7d4d JT |
496 | grep "Cookie:.*Foo=1" err && |
497 | grep "Cookie:.*Bar=2" err | |
83411783 JT |
498 | ' |
499 | ||
8ba18e6f JT |
500 | test_expect_success 'GIT_TRACE_CURL_NO_DATA prevents data from being traced' ' |
501 | rm -rf clone && | |
502 | GIT_TRACE_CURL=true \ | |
503 | git clone $HTTPD_URL/smart/repo.git clone 2>err && | |
504 | grep "=> Send data" err && | |
505 | ||
506 | rm -rf clone && | |
507 | GIT_TRACE_CURL=true GIT_TRACE_CURL_NO_DATA=1 \ | |
508 | git clone $HTTPD_URL/smart/repo.git clone 2>err && | |
509 | ! grep "=> Send data" err | |
510 | ' | |
511 | ||
30dea565 JS |
512 | test_expect_success 'server-side error detected' ' |
513 | test_must_fail git clone $HTTPD_URL/error_smart/repo.git 2>actual && | |
e532a90a | 514 | test_i18ngrep "server-side error" actual |
30dea565 JS |
515 | ' |
516 | ||
7da4e228 | 517 | test_done |