From: Junio C Hamano Date: Thu, 2 Aug 2018 22:30:39 +0000 (-0700) Subject: Merge branch 'sg/httpd-test-unflake' X-Git-Tag: v2.19.0-rc0~114 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/bc6d33e87ac930286fe0bfc882b837bba4b18501?hp=-c Merge branch 'sg/httpd-test-unflake' httpd tests saw occasional breakage due to the way its access log gets inspected by the tests, which has been updated to make them less flaky. * sg/httpd-test-unflake: t/lib-httpd: avoid occasional failures when checking access.log t/lib-httpd: add the strip_access_log() helper function t5541: clean up truncating access log --- bc6d33e87ac930286fe0bfc882b837bba4b18501 diff --combined t/lib-httpd.sh index ed41b155af,7f060aebd0..a8729f8232 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@@ -132,7 -132,6 +132,7 @@@ prepare_httpd() cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH" install_script broken-smart-http.sh install_script error.sh + install_script apply-one-time-sed.sh ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules" @@@ -288,3 -287,24 +288,24 @@@ expect_askpass() test_cmp "$TRASH_DIRECTORY/askpass-expect" \ "$TRASH_DIRECTORY/askpass-query" } + + strip_access_log() { + sed -e " + s/^.* \"// + s/\"// + s/ [1-9][0-9]*\$// + s/^GET /GET / + " "$HTTPD_ROOT_PATH"/access.log + } + + # Requires one argument: the name of a file containing the expected stripped + # access log entries. + check_access_log() { + sort "$1" >"$1".sorted && + strip_access_log >access.log.stripped && + sort access.log.stripped >access.log.sorted && + if ! test_cmp "$1".sorted access.log.sorted + then + test_cmp "$1" access.log.stripped + fi + } diff --combined t/t5541-http-push-smart.sh index a2af693068,918822868e..a0fc4005e0 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@@ -38,25 -38,16 +38,16 @@@ GET /smart/test_repo.git/info/refs?ser 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 && - sed -e " - s/^.* \"// - s/\"// - s/ [1-9][0-9]*\$// - s/^GET /GET / - " >act <"$HTTPD_ROOT_PATH"/access.log && - - # Clear the log, so that it does not affect the "used receive-pack - # service" test which reads the log too. - # - # We do this before the actual comparison to ensure the log is cleared. - echo > "$HTTPD_ROOT_PATH"/access.log && - - test_cmp exp act + check_access_log exp ' test_expect_success 'clone remote repository' ' @@@ -124,7 -115,6 +115,6 @@@ test_expect_success 'rejected update pr rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" cat >exp <act <"$HTTPD_ROOT_PATH"/access.log && - test_cmp exp act + check_access_log exp ' test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \ @@@ -234,7 -218,7 +218,7 @@@ test_expect_success TTY 'push --no-prog test_commit no-progress && test_terminal git push --no-progress >output 2>&1 && test_i18ngrep "^To http" output && - test_i18ngrep ! "^Writing objects" + test_i18ngrep ! "^Writing objects" output ' test_expect_success 'push --progress shows progress to non-tty' ' @@@ -377,17 -361,5 +361,17 @@@ test_expect_success 'push status outpu grep "^To $HTTPD_URL/smart/test_repo.git" status ' +test_expect_success 'colorize errors/hints' ' + cd "$ROOT_PATH"/test_repo_clone && + test_must_fail git -c color.transport=always -c color.advice=always \ + -c color.push=always \ + push origin origin/master^:master 2>act && + test_decode_color decoded && + test_i18ngrep ".*rejected.*" decoded && + test_i18ngrep "error: failed to push some refs" decoded && + test_i18ngrep "hint: " decoded && + test_i18ngrep ! "^hint: " decoded +' + stop_httpd test_done diff --combined t/t5551-http-fetch-smart.sh index 913089b144,f0b03e5190..3aab44bdcb --- a/t/t5551-http-fetch-smart.sh +++ b/t/t5551-http-fetch-smart.sh @@@ -26,14 -26,14 +26,14 @@@ setup_askpass_helpe cat >exp < GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 > Accept: */* -> Accept-Encoding: gzip +> Accept-Encoding: ENCODINGS > Pragma: no-cache < HTTP/1.1 200 OK < 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 HTTP/1.1 -> Accept-Encoding: gzip +> Accept-Encoding: ENCODINGS > Content-Type: application/x-git-upload-pack-request > Accept: application/x-git-upload-pack-result > Content-Length: xxx @@@ -79,13 -79,8 +79,13 @@@ test_expect_success 'clone http reposit /^< Date: /d /^< Content-Length: /d /^< Transfer-Encoding: /d - " >act && - test_cmp exp act + " >actual && + sed -e "s/^> Accept-Encoding: .*/> Accept-Encoding: ENCODINGS/" \ + actual >actual.smudged && + test_cmp exp actual.smudged && + + grep "Accept-Encoding:.*gzip" actual >actual.gzip && + test_line_count = 2 actual.gzip ' test_expect_success 'fetch changes via http' ' @@@ -103,13 -98,7 +103,7 @@@ GET /smart/repo.git/info/refs?service= POST /smart/repo.git/git-upload-pack HTTP/1.1 200 EOF test_expect_success 'used upload-pack service' ' - sed -e " - s/^.* \"// - s/\"// - s/ [1-9][0-9]*\$// - s/^GET /GET / - " >act <"$HTTPD_ROOT_PATH"/access.log && - test_cmp exp act + check_access_log exp ' test_expect_success 'follow redirects (301)' ' @@@ -369,38 -358,5 +363,38 @@@ test_expect_success 'custom http header submodule update sub ' +test_expect_success 'GIT_REDACT_COOKIES redacts cookies' ' + rm -rf clone && + echo "Set-Cookie: Foo=1" >cookies && + echo "Set-Cookie: Bar=2" >>cookies && + GIT_TRACE_CURL=true GIT_REDACT_COOKIES=Bar,Baz \ + git -c "http.cookieFile=$(pwd)/cookies" clone \ + $HTTPD_URL/smart/repo.git clone 2>err && + grep "Cookie:.*Foo=1" err && + grep "Cookie:.*Bar=" err && + ! grep "Cookie:.*Bar=2" err +' + +test_expect_success 'GIT_REDACT_COOKIES handles empty values' ' + rm -rf clone && + echo "Set-Cookie: Foo=" >cookies && + GIT_TRACE_CURL=true GIT_REDACT_COOKIES=Foo \ + git -c "http.cookieFile=$(pwd)/cookies" clone \ + $HTTPD_URL/smart/repo.git clone 2>err && + grep "Cookie:.*Foo=" err +' + +test_expect_success 'GIT_TRACE_CURL_NO_DATA prevents data from being traced' ' + rm -rf clone && + GIT_TRACE_CURL=true \ + git clone $HTTPD_URL/smart/repo.git clone 2>err && + grep "=> Send data" err && + + rm -rf clone && + GIT_TRACE_CURL=true GIT_TRACE_CURL_NO_DATA=1 \ + git clone $HTTPD_URL/smart/repo.git clone 2>err && + ! grep "=> Send data" err +' + stop_httpd test_done diff --combined t/t5561-http-backend.sh index 84a955770a,28c74b80a8..1c49054595 --- a/t/t5561-http-backend.sh +++ b/t/t5561-http-backend.sh @@@ -3,16 -3,10 +3,16 @@@ test_description='test git-http-backend' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-httpd.sh + +if ! test_have_prereq CURL; then + skip_all='skipping raw http-backend tests, curl not available' + test_done +fi + start_httpd GET() { - curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out 2>/dev/null && + curl --include "$HTTPD_URL/$SMART/repo.git/$1" >out && tr '\015' Q out 2>/dev/null && + "$HTTPD_URL/smart/repo.git/$1" >out && tr '\015' Q act <"$HTTPD_ROOT_PATH"/access.log && - test_cmp exp act + check_access_log exp ' stop_httpd