Merge branch 'jk/http-test-fixes'

Various fix-ups on HTTP tests.

* jk/http-test-fixes:
  t5559: make SSL/TLS the default
  t5559: fix test failures with LIB_HTTPD_SSL
  t/lib-httpd: enable HTTP/2 "h2" protocol, not just h2c
  t/lib-httpd: respect $HTTPD_PROTO in expect_askpass()
  t5551: drop curl trace lines without headers
  t5551: handle v2 protocol in cookie test
  t5551: simplify expected cookie file
  t5551: handle v2 protocol in upload-pack service test
  t5551: handle v2 protocol when checking curl trace
  t5551: stop forcing clone to run with v0 protocol
  t5551: handle HTTP/2 when checking curl trace
  t5551: lower-case headers in expected curl trace
  t5551: drop redundant grep for Accept-Language
  t5541: simplify and move "no empty path components" test
  t5541: stop marking "used receive-pack service" test as v0 only
  t5541: run "used receive-pack service" test earlier
This commit is contained in:
Junio C Hamano 2023-02-28 16:38:47 -08:00
Родитель a0f05f6840 8f2146dbf1
Коммит b2893ea403
5 изменённых файлов: 122 добавлений и 114 удалений

Просмотреть файл

@ -290,11 +290,11 @@ expect_askpass() {
none) none)
;; ;;
pass) pass)
echo "askpass: Password for 'http://$2@$dest': " echo "askpass: Password for '$HTTPD_PROTO://$2@$dest': "
;; ;;
both) both)
echo "askpass: Username for 'http://$dest': " echo "askpass: Username for '$HTTPD_PROTO://$dest': "
echo "askpass: Password for 'http://$2@$dest': " echo "askpass: Password for '$HTTPD_PROTO://$2@$dest': "
;; ;;
*) *)
false false

Просмотреть файл

@ -31,7 +31,7 @@ ErrorLog error.log
<IfDefine HTTP2> <IfDefine HTTP2>
LoadModule http2_module modules/mod_http2.so LoadModule http2_module modules/mod_http2.so
Protocols h2c Protocols h2 h2c
</IfDefine> </IfDefine>
<IfModule !mod_auth_basic.c> <IfModule !mod_auth_basic.c>

Просмотреть файл

@ -36,28 +36,6 @@ test_expect_success 'setup remote repository' '
setup_askpass_helper setup_askpass_helper
cat >exp <<EOF
GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
EOF
test_expect_success 'no empty path components' '
# Clear the log, so that it does not affect the "used receive-pack
# service" test which reads the log too.
test_when_finished ">\"\$HTTPD_ROOT_PATH\"/access.log" &&
# In the URL, add a trailing slash, and see if git appends yet another
# slash.
cd "$ROOT_PATH" &&
git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone &&
# NEEDSWORK: If the overspecification of the expected result is reduced, we
# might be able to run this test in all protocol versions.
if test "$GIT_TEST_PROTOCOL_VERSION" = 0
then
check_access_log exp
fi
'
test_expect_success 'clone remote repository' ' test_expect_success 'clone remote repository' '
rm -rf test_repo_clone && rm -rf test_repo_clone &&
git clone $HTTPD_URL/smart/test_repo.git test_repo_clone && git clone $HTTPD_URL/smart/test_repo.git test_repo_clone &&
@ -67,6 +45,10 @@ test_expect_success 'clone remote repository' '
' '
test_expect_success 'push to remote repository (standard)' ' test_expect_success 'push to remote repository (standard)' '
# Clear the log, so that the "used receive-pack service" test below
# sees just what we did here.
>"$HTTPD_ROOT_PATH"/access.log &&
cd "$ROOT_PATH"/test_repo_clone && cd "$ROOT_PATH"/test_repo_clone &&
: >path2 && : >path2 &&
git add path2 && git add path2 &&
@ -80,6 +62,15 @@ test_expect_success 'push to remote repository (standard)' '
test $HEAD = $(git rev-parse --verify HEAD)) test $HEAD = $(git rev-parse --verify HEAD))
' '
test_expect_success 'used receive-pack service' '
cat >exp <<-\EOF &&
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
EOF
check_access_log exp
'
test_expect_success 'push to remote repository (standard) with sending Accept-Language' ' test_expect_success 'push to remote repository (standard) with sending Accept-Language' '
cat >exp <<-\EOF && cat >exp <<-\EOF &&
=> Send header: Accept-Language: ko-KR, *;q=0.9 => Send header: Accept-Language: ko-KR, *;q=0.9
@ -141,28 +132,6 @@ test_expect_success 'rejected update prints status' '
' '
rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
cat >exp <<EOF
GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
EOF
test_expect_success 'used receive-pack service' '
# NEEDSWORK: If the overspecification of the expected result is reduced, we
# might be able to run this test in all protocol versions.
if test "$GIT_TEST_PROTOCOL_VERSION" = 0
then
check_access_log exp
fi
'
test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
"$ROOT_PATH"/test_repo_clone main success "$ROOT_PATH"/test_repo_clone main success

Просмотреть файл

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
: ${HTTP_PROTO:=HTTP} : ${HTTP_PROTO:=HTTP/1.1}
test_description="test smart fetching over http via http-backend ($HTTP_PROTO)" test_description="test smart fetching over http via http-backend ($HTTP_PROTO)"
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
@ -33,35 +33,71 @@ test_expect_success 'create http-accessible bare repository' '
setup_askpass_helper setup_askpass_helper
test_expect_success 'clone http repository' ' test_expect_success 'clone http repository' '
cat >exp <<-\EOF && if test_have_prereq HTTP2 && test "$HTTPD_PROTO" = "https"
> GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 then
> Accept: */* # ALPN lets us immediately use HTTP/2; likewise, POSTs with
> Accept-Encoding: ENCODINGS # bodies can use it because they do not need to upgrade
> Accept-Language: ko-KR, *;q=0.9 INITIAL_PROTO=HTTP/2
> Pragma: no-cache else
< HTTP/1.1 200 OK # either we are not using HTTP/2, or the initial
< Pragma: no-cache # request is sent via HTTP/1.1 and asks for upgrade
< Cache-Control: no-cache, max-age=0, must-revalidate INITIAL_PROTO=HTTP/1.1
< Content-Type: application/x-git-upload-pack-advertisement fi &&
> POST /smart/repo.git/git-upload-pack HTTP/1.1
> Accept-Encoding: ENCODINGS cat >exp.raw <<-EOF &&
> Content-Type: application/x-git-upload-pack-request > GET /smart/repo.git/info/refs?service=git-upload-pack $INITIAL_PROTO
> Accept: application/x-git-upload-pack-result > accept: */*
> Accept-Language: ko-KR, *;q=0.9 > accept-encoding: ENCODINGS
> Content-Length: xxx > accept-language: ko-KR, *;q=0.9
< HTTP/1.1 200 OK > pragma: no-cache
< Pragma: no-cache {V2} > git-protocol: version=2
< Cache-Control: no-cache, max-age=0, must-revalidate < $HTTP_PROTO 200 OK
< Content-Type: application/x-git-upload-pack-result < pragma: no-cache
< cache-control: no-cache, max-age=0, must-revalidate
< content-type: application/x-git-upload-pack-advertisement
> POST /smart/repo.git/git-upload-pack $INITIAL_PROTO
> accept-encoding: ENCODINGS
> content-type: application/x-git-upload-pack-request
> accept: application/x-git-upload-pack-result
> accept-language: ko-KR, *;q=0.9
{V2} > git-protocol: version=2
> content-length: xxx
< $INITIAL_PROTO 200 OK
< pragma: no-cache
< cache-control: no-cache, max-age=0, must-revalidate
< content-type: application/x-git-upload-pack-result
{V2} > POST /smart/repo.git/git-upload-pack $INITIAL_PROTO
{V2} > accept-encoding: ENCODINGS
{V2} > content-type: application/x-git-upload-pack-request
{V2} > accept: application/x-git-upload-pack-result
{V2} > accept-language: ko-KR, *;q=0.9
{V2} > git-protocol: version=2
{V2} > content-length: xxx
{V2} < $INITIAL_PROTO 200 OK
{V2} < pragma: no-cache
{V2} < cache-control: no-cache, max-age=0, must-revalidate
{V2} < content-type: application/x-git-upload-pack-result
EOF EOF
GIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION=0 LANGUAGE="ko_KR.UTF-8" \ if test "$GIT_TEST_PROTOCOL_VERSION" = 0
then
sed "/^{V2}/d" <exp.raw >exp
else
sed "s/^{V2} //" <exp.raw >exp
fi &&
GIT_TRACE_CURL=true LANGUAGE="ko_KR.UTF-8" \
git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err && git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
test_cmp file clone/file && test_cmp file clone/file &&
tr '\''\015'\'' Q <err | tr '\''\015'\'' Q <err |
perl -pe '\''
s/(Send|Recv) header: ([A-Za-z0-9-]+):/
"$1 header: " . lc($2) . ":"
/e;
'\'' |
sed -e " sed -e "
s/Q\$// s/Q\$//
/^[*] /d /^[^<=]/d
/^== Info:/d /^== Info:/d
/^=> Send header, /d /^=> Send header, /d
/^=> Send header:$/d /^=> Send header:$/d
@ -71,6 +107,8 @@ test_expect_success 'clone http repository' '
s/= Recv header:// s/= Recv header://
/^<= Recv data/d /^<= Recv data/d
/^=> Send data/d /^=> Send data/d
/^<= Recv SSL data/d
/^=> Send SSL data/d
/^$/d /^$/d
/^< $/d /^< $/d
@ -78,36 +116,35 @@ test_expect_success 'clone http repository' '
s/^/> / s/^/> /
} }
/^> User-Agent: /d /^< HTTP/ {
/^> Host: /d s/200$/200 OK/
}
/^< HTTP\\/1.1 101/d
/^[><] connection: /d
/^[><] upgrade: /d
/^> http2-settings: /d
/^> user-agent: /d
/^> host: /d
/^> POST /,$ { /^> POST /,$ {
/^> Accept: [*]\\/[*]/d /^> Accept: [*]\\/[*]/d
} }
s/^> Content-Length: .*/> Content-Length: xxx/ s/^> content-length: .*/> content-length: xxx/
/^> 00..want /d /^> 00..want /d
/^> 00.*done/d /^> 00.*done/d
/^< Server: /d /^< server: /d
/^< Expires: /d /^< expires: /d
/^< Date: /d /^< date: /d
/^< Content-Length: /d /^< content-length: /d
/^< Transfer-Encoding: /d /^< transfer-encoding: /d
" >actual && " >actual &&
# NEEDSWORK: If the overspecification of the expected result is reduced, we sed -e "s/^> accept-encoding: .*/> accept-encoding: ENCODINGS/" \
# might be able to run this test in all protocol versions.
if test "$GIT_TEST_PROTOCOL_VERSION" = 0
then
sed -e "s/^> Accept-Encoding: .*/> Accept-Encoding: ENCODINGS/" \
actual >actual.smudged && actual >actual.smudged &&
test_cmp exp actual.smudged && test_cmp exp actual.smudged &&
grep "Accept-Encoding:.*gzip" actual >actual.gzip && grep "accept-encoding:.*gzip" actual >actual.gzip
test_line_count = 2 actual.gzip &&
grep "Accept-Language: ko-KR, *" actual >actual.language &&
test_line_count = 2 actual.language
fi
' '
test_expect_success 'fetch changes via http' ' test_expect_success 'fetch changes via http' '
@ -119,19 +156,9 @@ test_expect_success 'fetch changes via http' '
' '
test_expect_success 'used upload-pack service' ' test_expect_success 'used upload-pack service' '
cat >exp <<-\EOF && strip_access_log >log &&
GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200 grep "GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/[0-9.]* 200" log &&
POST /smart/repo.git/git-upload-pack HTTP/1.1 200 grep "POST /smart/repo.git/git-upload-pack HTTP/[0-9.]* 200" log
GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
POST /smart/repo.git/git-upload-pack HTTP/1.1 200
EOF
# NEEDSWORK: If the overspecification of the expected result is reduced, we
# might be able to run this test in all protocol versions.
if test "$GIT_TEST_PROTOCOL_VERSION" = 0
then
check_access_log exp
fi
' '
test_expect_success 'follow redirects (301)' ' test_expect_success 'follow redirects (301)' '
@ -280,21 +307,23 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set
127.0.0.1 FALSE /smart_cookies/ FALSE 0 othername othervalue 127.0.0.1 FALSE /smart_cookies/ FALSE 0 othername othervalue
EOF EOF
sort >expect_cookies.txt <<-\EOF && sort >expect_cookies.txt <<-\EOF &&
127.0.0.1 FALSE /smart_cookies/ FALSE 0 othername othervalue 127.0.0.1 FALSE /smart_cookies/ FALSE 0 othername othervalue
127.0.0.1 FALSE /smart_cookies/repo.git/ FALSE 0 name value
127.0.0.1 FALSE /smart_cookies/repo.git/info/ FALSE 0 name value 127.0.0.1 FALSE /smart_cookies/repo.git/info/ FALSE 0 name value
EOF EOF
git config http.cookiefile cookies.txt && git config http.cookiefile cookies.txt &&
git config http.savecookies true && git config http.savecookies true &&
git ls-remote $HTTPD_URL/smart_cookies/repo.git main &&
# NEEDSWORK: If the overspecification of the expected result is reduced, we test_when_finished "
# might be able to run this test in all protocol versions. git --git-dir=\"\$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" \
if test "$GIT_TEST_PROTOCOL_VERSION" = 0 tag -d cookie-tag
then " &&
tail -3 cookies.txt | sort >cookies_tail.txt && git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
test_cmp expect_cookies.txt cookies_tail.txt tag -m "foo" cookie-tag &&
fi git fetch $HTTPD_URL/smart_cookies/repo.git cookie-tag &&
grep "^[^#]" cookies.txt | sort >cookies_stripped.txt &&
test_cmp expect_cookies.txt cookies_stripped.txt
' '
test_expect_success 'transfer.hiderefs works over smart-http' ' test_expect_success 'transfer.hiderefs works over smart-http' '
@ -666,4 +695,13 @@ test_expect_success 'push warns or fails when using username:password' '
test_line_count -ge 1 warnings test_line_count -ge 1 warnings
' '
test_expect_success 'no empty path components' '
# In the URL, add a trailing slash, and see if git appends yet another
# slash.
git clone $HTTPD_URL/smart/repo.git/ clone-with-slash &&
strip_access_log >log &&
! grep "//" log
'
test_done test_done

Просмотреть файл

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
HTTP_PROTO=HTTP/2 HTTP_PROTO=HTTP/2
LIB_HTTPD_SSL=1
. ./t5551-http-fetch-smart.sh . ./t5551-http-fetch-smart.sh