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