3 test_description
='test smart fetching over http via http-backend'
6 if test -n "$NO_CURL"; then
7 skip_all
='skipping test, git built without http support'
11 LIB_HTTPD_PORT
=${LIB_HTTPD_PORT-'5551'}
12 .
"$TEST_DIRECTORY"/lib-httpd.sh
15 test_expect_success
'setup repository' '
21 test_expect_success
'create http-accessible bare repository' '
22 mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
23 (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
26 git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
27 git push public master:master
33 > GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1
35 > Accept-Encoding: gzip
39 < Cache-Control: no-cache, max-age=0, must-revalidate
40 < Content-Type: application/x-git-upload-pack-advertisement
41 > POST /smart/repo.git/git-upload-pack HTTP/1.1
42 > Accept-Encoding: gzip
43 > Content-Type: application/x-git-upload-pack-request
44 > Accept: application/x-git-upload-pack-result
48 < Cache-Control: no-cache, max-age=0, must-revalidate
49 < Content-Type: application/x-git-upload-pack-result
51 test_expect_success
'clone http repository' '
52 GIT_CURL_VERBOSE=1 git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
53 test_cmp file clone/file &&
54 tr '\''\015'\'' Q <err |
68 /^> Accept: [*]\\/[*]/d
70 s/^> Content-Length: .*/> Content-Length: xxx/
77 /^< Content-Length: /d
78 /^< Transfer-Encoding: /d
83 test_expect_success
'fetch changes via http' '
84 echo content >>file &&
85 git commit -a -m two &&
87 (cd clone && git pull) &&
88 test_cmp file clone/file
92 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
93 POST /smart/repo.git/git-upload-pack HTTP/1.1 200
94 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
95 POST /smart/repo.git/git-upload-pack HTTP/1.1 200
97 test_expect_success
'used upload-pack service' '
103 " >act <"$HTTPD_ROOT_PATH"/access.log &&
107 test_expect_success
'follow redirects (301)' '
108 git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
111 test_expect_success
'follow redirects (302)' '
112 git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t
115 test_expect_success
'clone from password-protected repository' '
117 set_askpass user@host &&
118 git clone --bare "$HTTPD_URL/auth/smart/repo.git" smart-auth &&
119 expect_askpass both user@host &&
120 git --git-dir=smart-auth log -1 --format=%s >actual &&
121 test_cmp expect actual
124 test_expect_success
'clone from auth-only-for-push repository' '
127 git clone --bare "$HTTPD_URL/auth-push/smart/repo.git" smart-noauth &&
128 expect_askpass none &&
129 git --git-dir=smart-noauth log -1 --format=%s >actual &&
130 test_cmp expect actual
133 test_expect_success
'clone from auth-only-for-objects repository' '
135 set_askpass user@host &&
136 git clone --bare "$HTTPD_URL/auth-fetch/smart/repo.git" half-auth &&
137 expect_askpass both user@host &&
138 git --git-dir=half-auth log -1 --format=%s >actual &&
139 test_cmp expect actual
142 test_expect_success
'no-op half-auth fetch does not require a password' '
144 git --git-dir=half-auth fetch &&
148 test_expect_success
'disable dumb http on server' '
149 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
150 config http.getanyfile false
153 test_expect_success
'GIT_SMART_HTTP can disable smart http' '
155 export GIT_SMART_HTTP &&
157 test_must_fail git fetch)
160 test_expect_success
'invalid Content-Type rejected' '
161 echo "fatal: invalid content-type text/html" >expect
162 test_must_fail git clone $HTTPD_URL/broken_smart/repo.git 2>actual
163 test_cmp expect actual
166 test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
168 test_expect_success EXPENSIVE
'create 50,000 tags in the repo' '
170 cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
171 for i in `test_seq 50000`
173 echo "commit refs/heads/too-many-refs"
175 echo "committer git <git@example.com> $i +0000"
177 echo "M 644 inline bla.txt"
180 # make every commit dangling by always
181 # rewinding the branch after each commit
182 echo "reset refs/heads/too-many-refs"
184 done | git fast-import --export-marks=marks &&
186 # now assign tags to all the dangling commits we created above
187 tag=$("$PERL_PATH" -e "print \"bla\" x 30") &&
188 sed -e "s/^:\(.\+\) \(.\+\)$/\2 refs\/tags\/$tag-\1/" <marks >>packed-refs
192 test_expect_success EXPENSIVE
'clone the 50,000 tag repo to check OS command line overflow' '
193 git clone $HTTPD_URL/smart/repo.git too-many-refs 2>err &&
194 test_line_count = 0 err