3 : ${HTTP_PROTO:=HTTP/1.1}
4 test_description
="test smart fetching over http via http-backend ($HTTP_PROTO)"
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9 .
"$TEST_DIRECTORY"/lib-httpd.sh
10 test "$HTTP_PROTO" = "HTTP/2" && enable_http2
13 test_expect_success HTTP2
'enable client-side http/2' '
14 git config --global http.version HTTP/2
17 test_expect_success
'setup repository' '
18 git config push.default matching &&
24 test_expect_success
'create http-accessible bare repository' '
25 mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
26 (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
29 git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
30 git push public main:main
35 test_expect_success
'clone http repository' '
36 if test_have_prereq HTTP2 && test "$HTTPD_PROTO" = "https"
38 # ALPN lets us immediately use HTTP/2; likewise, POSTs with
39 # bodies can use it because they do not need to upgrade
42 # either we are not using HTTP/2, or the initial
43 # request is sent via HTTP/1.1 and asks for upgrade
44 INITIAL_PROTO=HTTP/1.1
47 cat >exp.raw <<-EOF &&
48 > GET /smart/repo.git/info/refs?service=git-upload-pack $INITIAL_PROTO
50 > accept-encoding: ENCODINGS
51 > accept-language: ko-KR, *;q=0.9
53 {V2} > git-protocol: version=2
56 < cache-control: no-cache, max-age=0, must-revalidate
57 < content-type: application/x-git-upload-pack-advertisement
58 > POST /smart/repo.git/git-upload-pack $INITIAL_PROTO
59 > accept-encoding: ENCODINGS
60 > content-type: application/x-git-upload-pack-request
61 > accept: application/x-git-upload-pack-result
62 > accept-language: ko-KR, *;q=0.9
63 {V2} > git-protocol: version=2
65 < $INITIAL_PROTO 200 OK
67 < cache-control: no-cache, max-age=0, must-revalidate
68 < content-type: application/x-git-upload-pack-result
69 {V2} > POST /smart/repo.git/git-upload-pack $INITIAL_PROTO
70 {V2} > accept-encoding: ENCODINGS
71 {V2} > content-type: application/x-git-upload-pack-request
72 {V2} > accept: application/x-git-upload-pack-result
73 {V2} > accept-language: ko-KR, *;q=0.9
74 {V2} > git-protocol: version=2
75 {V2} > content-length: xxx
76 {V2} < $INITIAL_PROTO 200 OK
77 {V2} < pragma: no-cache
78 {V2} < cache-control: no-cache, max-age=0, must-revalidate
79 {V2} < content-type: application/x-git-upload-pack-result
82 if test "$GIT_TEST_PROTOCOL_VERSION" = 0
84 sed "/^{V2}/d" <exp.raw >exp
86 sed "s/^{V2} //" <exp.raw >exp
89 GIT_TRACE_CURL=true LANGUAGE="ko_KR.UTF-8" \
90 git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
91 test_cmp file clone/file &&
92 tr '\''\015'\'' Q <err |
94 s/(Send|Recv) header: ([A-Za-z0-9-]+):/
95 "$1 header: " . lc($2) . ":"
123 /^[><] connection: /d
125 /^> http2-settings: /d
130 /^> Accept: [*]\\/[*]/d
132 s/^> content-length: .*/> content-length: xxx/
139 /^< content-length: /d
140 /^< transfer-encoding: /d
143 sed -e "s/^> accept-encoding: .*/> accept-encoding: ENCODINGS/" \
144 actual >actual.smudged &&
145 test_cmp exp actual.smudged &&
147 grep "accept-encoding:.*gzip" actual >actual.gzip
150 test_expect_success
'fetch changes via http' '
151 echo content >>file &&
152 git commit -a -m two &&
154 (cd clone && git pull) &&
155 test_cmp file clone/file
158 test_expect_success
'used upload-pack service' '
159 strip_access_log >log &&
160 grep "GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/[0-9.]* 200" log &&
161 grep "POST /smart/repo.git/git-upload-pack HTTP/[0-9.]* 200" log
164 test_expect_success
'follow redirects (301)' '
165 git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
168 test_expect_success
'follow redirects (302)' '
169 git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t
172 test_expect_success
'redirects re-root further requests' '
173 git clone $HTTPD_URL/smart-redir-limited/repo.git repo-redir-limited
176 test_expect_success
're-rooting dies on insane schemes' '
177 test_must_fail git clone $HTTPD_URL/insane-redir/repo.git insane
180 test_expect_success
'clone from password-protected repository' '
182 set_askpass user@host pass@host &&
183 git clone --bare "$HTTPD_URL/auth/smart/repo.git" smart-auth &&
184 expect_askpass both user@host &&
185 git --git-dir=smart-auth log -1 --format=%s >actual &&
186 test_cmp expect actual
189 test_expect_success
'clone from auth-only-for-push repository' '
192 git clone --bare "$HTTPD_URL/auth-push/smart/repo.git" smart-noauth &&
193 expect_askpass none &&
194 git --git-dir=smart-noauth log -1 --format=%s >actual &&
195 test_cmp expect actual
198 test_expect_success
'clone from auth-only-for-objects repository' '
200 set_askpass user@host pass@host &&
201 git clone --bare "$HTTPD_URL/auth-fetch/smart/repo.git" half-auth &&
202 expect_askpass both user@host &&
203 git --git-dir=half-auth log -1 --format=%s >actual &&
204 test_cmp expect actual
207 test_expect_success
'no-op half-auth fetch does not require a password' '
210 # NEEDSWORK: When using HTTP(S), protocol v0 supports a "half-auth"
211 # configuration with authentication required only when downloading
212 # objects and not refs, by having the HTTP server only require
213 # authentication for the "git-upload-pack" path and not "info/refs".
214 # This is not possible with protocol v2, since both objects and refs
215 # are obtained from the "git-upload-pack" path. A solution to this is
216 # to teach the server and client to be able to inline ls-refs requests
217 # as an Extra Parameter (see "git help gitformat-pack-protocol"), so that
218 # "info/refs" can serve refs, just like it does in protocol v0.
219 GIT_TEST_PROTOCOL_VERSION=0 git --git-dir=half-auth fetch &&
223 test_expect_success
'redirects send auth to new location' '
224 set_askpass user@host pass@host &&
225 git -c credential.useHttpPath=true \
226 clone $HTTPD_URL/smart-redir-auth/repo.git repo-redir-auth &&
227 expect_askpass both user@host auth/smart/repo.git
230 test_expect_success
'GIT_TRACE_CURL redacts auth details' '
231 rm -rf redact-auth trace &&
232 set_askpass user@host pass@host &&
233 GIT_TRACE_CURL="$(pwd)/trace" git clone --bare "$HTTPD_URL/auth/smart/repo.git" redact-auth &&
234 expect_askpass both user@host &&
236 # Ensure that there is no "Basic" followed by a base64 string, but that
237 # the auth details are redacted
238 ! grep -i "Authorization: Basic [0-9a-zA-Z+/]" trace &&
239 grep -i "Authorization: Basic <redacted>" trace
242 test_expect_success
'GIT_CURL_VERBOSE redacts auth details' '
243 rm -rf redact-auth trace &&
244 set_askpass user@host pass@host &&
245 GIT_CURL_VERBOSE=1 git clone --bare "$HTTPD_URL/auth/smart/repo.git" redact-auth 2>trace &&
246 expect_askpass both user@host &&
248 # Ensure that there is no "Basic" followed by a base64 string, but that
249 # the auth details are redacted
250 ! grep -i "Authorization: Basic [0-9a-zA-Z+/]" trace &&
251 grep -i "Authorization: Basic <redacted>" trace
254 test_expect_success
'GIT_TRACE_CURL does not redact auth details if GIT_TRACE_REDACT=0' '
255 rm -rf redact-auth trace &&
256 set_askpass user@host pass@host &&
257 GIT_TRACE_REDACT=0 GIT_TRACE_CURL="$(pwd)/trace" \
258 git clone --bare "$HTTPD_URL/auth/smart/repo.git" redact-auth &&
259 expect_askpass both user@host &&
261 grep -i "Authorization: Basic [0-9a-zA-Z+/]" trace
264 test_expect_success
'disable dumb http on server' '
265 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
266 config http.getanyfile false
269 test_expect_success
'GIT_SMART_HTTP can disable smart http' '
271 export GIT_SMART_HTTP &&
273 test_must_fail git fetch)
276 test_expect_success
'invalid Content-Type rejected' '
277 test_must_fail git clone $HTTPD_URL/broken_smart/repo.git 2>actual &&
278 test_i18ngrep "not valid:" actual
281 test_expect_success
'create namespaced refs' '
282 test_commit namespaced &&
283 git push public HEAD:refs/namespaces/ns/refs/heads/main &&
284 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
285 symbolic-ref refs/namespaces/ns/HEAD refs/namespaces/ns/refs/heads/main
288 test_expect_success
'smart clone respects namespace' '
289 git clone "$HTTPD_URL/smart_namespace/repo.git" ns-smart &&
290 echo namespaced >expect &&
291 git --git-dir=ns-smart/.git log -1 --format=%s >actual &&
292 test_cmp expect actual
295 test_expect_success
'dumb clone via http-backend respects namespace' '
296 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
297 config http.getanyfile true &&
298 GIT_SMART_HTTP=0 git clone \
299 "$HTTPD_URL/smart_namespace/repo.git" ns-dumb &&
300 echo namespaced >expect &&
301 git --git-dir=ns-dumb/.git log -1 --format=%s >actual &&
302 test_cmp expect actual
305 test_expect_success
'cookies stored in http.cookiefile when http.savecookies set' '
306 cat >cookies.txt <<-\EOF &&
307 127.0.0.1 FALSE /smart_cookies/ FALSE 0 othername othervalue
309 sort >expect_cookies.txt <<-\EOF &&
310 127.0.0.1 FALSE /smart_cookies/ FALSE 0 othername othervalue
311 127.0.0.1 FALSE /smart_cookies/repo.git/ FALSE 0 name value
312 127.0.0.1 FALSE /smart_cookies/repo.git/info/ FALSE 0 name value
314 git config http.cookiefile cookies.txt &&
315 git config http.savecookies true &&
318 git --git-dir=\"\$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" \
321 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
322 tag -m "foo" cookie-tag &&
323 git fetch $HTTPD_URL/smart_cookies/repo.git cookie-tag &&
325 grep "^[^#]" cookies.txt | sort >cookies_stripped.txt &&
326 test_cmp expect_cookies.txt cookies_stripped.txt
329 test_expect_success
'transfer.hiderefs works over smart-http' '
330 test_commit hidden &&
331 test_commit visible &&
332 git push public HEAD^:refs/heads/a HEAD:refs/heads/b &&
333 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
334 config transfer.hiderefs refs/heads/a &&
335 git clone --bare "$HTTPD_URL/smart/repo.git" hidden.git &&
336 test_must_fail git -C hidden.git rev-parse --verify a &&
337 git -C hidden.git rev-parse --verify b
340 # create an arbitrary number of tags, numbered from tag-$1 to tag-$2
343 for i
in $
(test_seq
"$1" "$2")
345 # don't use here-doc, because it requires a process
347 echo "commit refs/heads/too-many-refs-$1" &&
349 echo "committer git <git@example.com> $i +0000" &&
351 echo "M 644 inline bla.txt" &&
354 # make every commit dangling by always
355 # rewinding the branch after each commit
356 echo "reset refs/heads/too-many-refs-$1" &&
358 done | git fast-import
--export-marks=marks
&&
360 # now assign tags to all the dangling commits we created above
361 tag
=$
(perl
-e "print \"bla\" x 30") &&
362 sed -e "s|^:\([^ ]*\) \(.*\)$|\2 refs/tags/$tag-\1|" <marks
>>packed-refs
365 test_expect_success
'create 2,000 tags in the repo' '
367 cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
372 test_expect_success CMDLINE_LIMIT \
373 'clone the 2,000 tag repo to check OS command line overflow' '
374 run_with_limited_cmdline git clone $HTTPD_URL/smart/repo.git too-many-refs &&
377 git for-each-ref refs/tags >actual &&
378 test_line_count = 2000 actual
382 test_expect_success
'large fetch-pack requests can be sent using chunked encoding' '
383 GIT_TRACE_CURL=true git -c http.postbuffer=65536 \
384 clone --bare "$HTTPD_URL/smart/repo.git" split.git 2>err &&
386 test_have_prereq HTTP2 ||
387 grep "^=> Send header: Transfer-Encoding: chunked" err
391 test_expect_success
'test allowreachablesha1inwant' '
392 test_when_finished "rm -rf test_reachable.git" &&
393 server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
394 main_sha=$(git -C "$server" rev-parse refs/heads/main) &&
395 git -C "$server" config uploadpack.allowreachablesha1inwant 1 &&
397 git init --bare test_reachable.git &&
398 git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
399 git -C test_reachable.git fetch origin "$main_sha"
402 test_expect_success
'test allowreachablesha1inwant with unreachable' '
403 test_when_finished "rm -rf test_reachable.git; git reset --hard $(git rev-parse HEAD)" &&
405 #create unreachable sha
406 echo content >file2 &&
409 git push public HEAD:refs/heads/doomed &&
410 git push public :refs/heads/doomed &&
412 server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
413 main_sha=$(git -C "$server" rev-parse refs/heads/main) &&
414 git -C "$server" config uploadpack.allowreachablesha1inwant 1 &&
416 git init --bare test_reachable.git &&
417 git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
418 # Some protocol versions (e.g. 2) support fetching
419 # unadvertised objects, so restrict this test to v0.
420 test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
421 git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
424 test_expect_success
'test allowanysha1inwant with unreachable' '
425 test_when_finished "rm -rf test_reachable.git; git reset --hard $(git rev-parse HEAD)" &&
427 #create unreachable sha
428 echo content >file2 &&
431 git push public HEAD:refs/heads/doomed &&
432 git push public :refs/heads/doomed &&
434 server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
435 main_sha=$(git -C "$server" rev-parse refs/heads/main) &&
436 git -C "$server" config uploadpack.allowreachablesha1inwant 1 &&
438 git init --bare test_reachable.git &&
439 git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" &&
440 # Some protocol versions (e.g. 2) support fetching
441 # unadvertised objects, so restrict this test to v0.
442 test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 \
443 git -C test_reachable.git fetch origin "$(git rev-parse HEAD)" &&
445 git -C "$server" config uploadpack.allowanysha1inwant 1 &&
446 git -C test_reachable.git fetch origin "$(git rev-parse HEAD)"
449 test_expect_success EXPENSIVE
'http can handle enormous ref negotiation' '
451 cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
452 create_tags 2001 50000
454 git -C too-many-refs fetch -q --tags &&
456 cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
457 create_tags 50001 100000
459 git -C too-many-refs fetch -q --tags &&
460 git -C too-many-refs for-each-ref refs/tags >tags &&
461 test_line_count = 100000 tags
464 test_expect_success
'custom http headers' '
465 test_must_fail git -c http.extraheader="x-magic-two: cadabra" \
466 fetch "$HTTPD_URL/smart_headers/repo.git" &&
467 git -c http.extraheader="x-magic-one: abra" \
468 -c http.extraheader="x-magic-two: cadabra" \
469 fetch "$HTTPD_URL/smart_headers/repo.git" &&
470 git update-index --add --cacheinfo 160000,$(git rev-parse HEAD),sub &&
471 git config -f .gitmodules submodule.sub.path sub &&
472 git config -f .gitmodules submodule.sub.url \
473 "$HTTPD_URL/smart_headers/repo.git" &&
474 git submodule init sub &&
475 test_must_fail git submodule update sub &&
476 git -c http.extraheader="x-magic-one: abra" \
477 -c http.extraheader="x-magic-two: cadabra" \
481 test_expect_success
'using fetch command in remote-curl updates refs' '
482 SERVER="$HTTPD_DOCUMENT_ROOT_PATH/twobranch" &&
483 rm -rf "$SERVER" client &&
485 git init "$SERVER" &&
486 test_commit -C "$SERVER" foo &&
487 git -C "$SERVER" update-ref refs/heads/anotherbranch foo &&
489 git clone $HTTPD_URL/smart/twobranch client &&
491 test_commit -C "$SERVER" bar &&
492 git -C client -c protocol.version=0 fetch &&
494 git -C "$SERVER" rev-parse main >expect &&
495 git -C client rev-parse origin/main >actual &&
496 test_cmp expect actual
499 test_expect_success
'fetch by SHA-1 without tag following' '
500 SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
501 rm -rf "$SERVER" client &&
503 git init "$SERVER" &&
504 test_commit -C "$SERVER" foo &&
506 git clone $HTTPD_URL/smart/server client &&
508 test_commit -C "$SERVER" bar &&
509 git -C "$SERVER" rev-parse bar >bar_hash &&
510 git -C client -c protocol.version=0 fetch \
511 --no-tags origin $(cat bar_hash)
514 test_expect_success
'cookies are redacted by default' '
516 echo "Set-Cookie: Foo=1" >cookies &&
517 echo "Set-Cookie: Bar=2" >>cookies &&
518 GIT_TRACE_CURL=true \
519 git -c "http.cookieFile=$(pwd)/cookies" clone \
520 $HTTPD_URL/smart/repo.git clone 2>err &&
521 grep -i "Cookie:.*Foo=<redacted>" err &&
522 grep -i "Cookie:.*Bar=<redacted>" err &&
523 ! grep -i "Cookie:.*Foo=1" err &&
524 ! grep -i "Cookie:.*Bar=2" err
527 test_expect_success
'empty values of cookies are also redacted' '
529 echo "Set-Cookie: Foo=" >cookies &&
530 GIT_TRACE_CURL=true \
531 git -c "http.cookieFile=$(pwd)/cookies" clone \
532 $HTTPD_URL/smart/repo.git clone 2>err &&
533 grep -i "Cookie:.*Foo=<redacted>" err
536 test_expect_success
'GIT_TRACE_REDACT=0 disables cookie redaction' '
538 echo "Set-Cookie: Foo=1" >cookies &&
539 echo "Set-Cookie: Bar=2" >>cookies &&
540 GIT_TRACE_REDACT=0 GIT_TRACE_CURL=true \
541 git -c "http.cookieFile=$(pwd)/cookies" clone \
542 $HTTPD_URL/smart/repo.git clone 2>err &&
543 grep -i "Cookie:.*Foo=1" err &&
544 grep -i "Cookie:.*Bar=2" err
547 test_expect_success
'GIT_TRACE_CURL_NO_DATA prevents data from being traced' '
549 GIT_TRACE_CURL=true \
550 git clone $HTTPD_URL/smart/repo.git clone 2>err &&
551 grep "=> Send data" err &&
554 GIT_TRACE_CURL=true GIT_TRACE_CURL_NO_DATA=1 \
555 git clone $HTTPD_URL/smart/repo.git clone 2>err &&
556 ! grep "=> Send data" err
559 test_expect_success
'server-side error detected' '
560 test_must_fail git clone $HTTPD_URL/error_smart/repo.git 2>actual &&
561 test_i18ngrep "server-side error" actual
564 test_expect_success
'http auth remembers successful credentials' '
565 rm -f .git-credentials &&
566 test_config credential.helper store &&
568 # the first request prompts the user...
569 set_askpass user@host pass@host &&
570 git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null &&
571 expect_askpass both user@host &&
573 # ...and the second one uses the stored value rather than
574 # prompting the user.
575 set_askpass bogus-user bogus-pass &&
576 git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null &&
580 test_expect_success
'http auth forgets bogus credentials' '
581 # seed credential store with bogus values. In real life,
582 # this would probably come from a password which worked
583 # for a previous request.
584 rm -f .git-credentials &&
585 test_config credential.helper store &&
587 echo "url=$HTTPD_URL" &&
588 echo "username=bogus" &&
589 echo "password=bogus"
590 } | git credential approve &&
592 # we expect this to use the bogus values and fail, never even
593 # prompting the user...
594 set_askpass user@host pass@host &&
595 test_must_fail git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null &&
596 expect_askpass none &&
598 # ...but now we should have forgotten the bad value, causing
599 # us to prompt the user again.
600 set_askpass user@host pass@host &&
601 git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null &&
602 expect_askpass both user@host
605 test_expect_success
'client falls back from v2 to v0 to match server' '
606 GIT_TRACE_PACKET=$PWD/trace \
607 GIT_TEST_PROTOCOL_VERSION=2 \
608 git clone $HTTPD_URL/smart_v0/repo.git repo-v0 &&
609 # check for v0; there the HEAD symref is communicated in the capability
610 # line; v2 uses a different syntax on each ref advertisement line
611 grep symref=HEAD:refs/heads/ trace
614 test_expect_success
'passing hostname resolution information works' '
615 BOGUS_HOST=gitbogusexamplehost.invalid &&
616 BOGUS_HTTPD_URL=$HTTPD_PROTO://$BOGUS_HOST:$LIB_HTTPD_PORT &&
617 test_must_fail git ls-remote "$BOGUS_HTTPD_URL/smart/repo.git" >/dev/null &&
618 git -c "http.curloptResolve=$BOGUS_HOST:$LIB_HTTPD_PORT:127.0.0.1" ls-remote "$BOGUS_HTTPD_URL/smart/repo.git" >/dev/null
621 # here user%40host is the URL-encoded version of user@host,
622 # which is our intentionally-odd username to catch parsing errors
623 url_user
=$HTTPD_URL_USER/auth
/smart
/repo.git
624 url_userpass
=$HTTPD_URL_USER_PASS/auth
/smart
/repo.git
625 url_userblank
=$HTTPD_PROTO://user
%40host:@
$HTTPD_DEST/auth
/smart
/repo.git
626 message
="URL .*:<redacted>@.* uses plaintext credentials"
628 test_expect_success
'clone warns or fails when using username:password' '
629 test_when_finished "rm -rf attempt*" &&
631 git -c transfer.credentialsInUrl=allow \
632 clone $url_userpass attempt1 2>err &&
633 ! grep "$message" err &&
635 git -c transfer.credentialsInUrl=warn \
636 clone $url_userpass attempt2 2>err &&
637 grep "warning: $message" err >warnings &&
638 test_line_count -ge 1 warnings &&
640 test_must_fail git -c transfer.credentialsInUrl=die \
641 clone $url_userpass attempt3 2>err &&
642 grep "fatal: $message" err >warnings &&
643 test_line_count -ge 1 warnings &&
645 test_must_fail git -c transfer.credentialsInUrl=die \
646 clone $url_userblank attempt4 2>err &&
647 grep "fatal: $message" err >warnings &&
648 test_line_count -ge 1 warnings
651 test_expect_success
'clone does not detect username:password when it is https://username@domain:port/' '
652 test_when_finished "rm -rf attempt1" &&
654 # we are relying on lib-httpd for url construction, so document our
656 case "$HTTPD_URL_USER" in
658 *) BUG "httpd url does not have port: $HTTPD_URL_USER"
661 git -c transfer.credentialsInUrl=warn clone $url_user attempt1 2>err &&
662 ! grep "uses plaintext credentials" err
665 test_expect_success
'fetch warns or fails when using username:password' '
666 git -c transfer.credentialsInUrl=allow fetch $url_userpass 2>err &&
667 ! grep "$message" err &&
669 git -c transfer.credentialsInUrl=warn fetch $url_userpass 2>err &&
670 grep "warning: $message" err >warnings &&
671 test_line_count -ge 1 warnings &&
673 test_must_fail git -c transfer.credentialsInUrl=die \
674 fetch $url_userpass 2>err &&
675 grep "fatal: $message" err >warnings &&
676 test_line_count -ge 1 warnings &&
678 test_must_fail git -c transfer.credentialsInUrl=die \
679 fetch $url_userblank 2>err &&
680 grep "fatal: $message" err >warnings &&
681 test_line_count -ge 1 warnings
685 test_expect_success
'push warns or fails when using username:password' '
686 git -c transfer.credentialsInUrl=allow push $url_userpass 2>err &&
687 ! grep "$message" err &&
689 git -c transfer.credentialsInUrl=warn push $url_userpass 2>err &&
690 grep "warning: $message" err >warnings &&
692 test_must_fail git -c transfer.credentialsInUrl=die \
693 push $url_userpass 2>err &&
694 grep "fatal: $message" err >warnings &&
695 test_line_count -ge 1 warnings
698 test_expect_success
'no empty path components' '
699 # In the URL, add a trailing slash, and see if git appends yet another
701 git clone $HTTPD_URL/smart/repo.git/ clone-with-slash &&
703 strip_access_log >log &&