@@ -185,6 +185,30 @@ test_expect_success 'redirects send auth to new location' '
185185 expect_askpass both user@host auth/smart/repo.git
186186'
187187
188+ test_expect_success ' GIT_TRACE_CURL redacts auth details' '
189+ rm -rf redact-auth trace &&
190+ set_askpass user@host pass@host &&
191+ GIT_TRACE_CURL="$(pwd)/trace" git clone --bare "$HTTPD_URL/auth/smart/repo.git" redact-auth &&
192+ expect_askpass both user@host &&
193+
194+ # Ensure that there is no "Basic" followed by a base64 string, but that
195+ # the auth details are redacted
196+ ! grep "Authorization: Basic [0-9a-zA-Z+/]" trace &&
197+ grep "Authorization: Basic <redacted>" trace
198+ '
199+
200+ test_expect_success ' GIT_CURL_VERBOSE redacts auth details' '
201+ rm -rf redact-auth trace &&
202+ set_askpass user@host pass@host &&
203+ GIT_CURL_VERBOSE=1 git clone --bare "$HTTPD_URL/auth/smart/repo.git" redact-auth 2>trace &&
204+ expect_askpass both user@host &&
205+
206+ # Ensure that there is no "Basic" followed by a base64 string, but that
207+ # the auth details are redacted
208+ ! grep "Authorization: Basic [0-9a-zA-Z+/]" trace &&
209+ grep "Authorization: Basic <redacted>" trace
210+ '
211+
188212test_expect_success ' disable dumb http on server' '
189213 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
190214 config http.getanyfile false
@@ -442,6 +466,18 @@ test_expect_success 'GIT_REDACT_COOKIES redacts cookies' '
442466 ! grep "Cookie:.*Bar=2" err
443467'
444468
469+ test_expect_success ' GIT_REDACT_COOKIES redacts cookies when GIT_CURL_VERBOSE=1' '
470+ rm -rf clone &&
471+ echo "Set-Cookie: Foo=1" >cookies &&
472+ echo "Set-Cookie: Bar=2" >>cookies &&
473+ GIT_CURL_VERBOSE=1 GIT_REDACT_COOKIES=Bar,Baz \
474+ git -c "http.cookieFile=$(pwd)/cookies" clone \
475+ $HTTPD_URL/smart/repo.git clone 2>err &&
476+ grep "Cookie:.*Foo=1" err &&
477+ grep "Cookie:.*Bar=<redacted>" err &&
478+ ! grep "Cookie:.*Bar=2" err
479+ '
480+
445481test_expect_success ' GIT_REDACT_COOKIES handles empty values' '
446482 rm -rf clone &&
447483 echo "Set-Cookie: Foo=" >cookies &&
0 commit comments