diff options
Diffstat (limited to 't/t5551-http-fetch-smart.sh')
-rwxr-xr-x | t/t5551-http-fetch-smart.sh | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh index e40e9ed52f..4f87d90c5b 100755 --- a/t/t5551-http-fetch-smart.sh +++ b/t/t5551-http-fetch-smart.sh @@ -1,6 +1,9 @@ #!/bin/sh test_description='test smart fetching over http via http-backend' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd @@ -18,7 +21,7 @@ test_expect_success 'create http-accessible bare repository' ' git --bare init ) && git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - git push public master:master + git push public main:main ' setup_askpass_helper @@ -238,9 +241,9 @@ test_expect_success 'invalid Content-Type rejected' ' test_expect_success 'create namespaced refs' ' test_commit namespaced && - git push public HEAD:refs/namespaces/ns/refs/heads/master && + git push public HEAD:refs/namespaces/ns/refs/heads/main && git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \ - symbolic-ref refs/namespaces/ns/HEAD refs/namespaces/ns/refs/heads/master + symbolic-ref refs/namespaces/ns/HEAD refs/namespaces/ns/refs/heads/main ' test_expect_success 'smart clone respects namespace' ' @@ -271,7 +274,7 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set EOF git config http.cookiefile cookies.txt && git config http.savecookies true && - git ls-remote $HTTPD_URL/smart_cookies/repo.git master && + git ls-remote $HTTPD_URL/smart_cookies/repo.git main && # NEEDSWORK: If the overspecification of the expected result is reduced, we # might be able to run this test in all protocol versions. @@ -344,12 +347,12 @@ test_expect_success 'large fetch-pack requests can be sent using chunked encodin test_expect_success 'test allowreachablesha1inwant' ' test_when_finished "rm -rf test_reachable.git" && server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - master_sha=$(git -C "$server" rev-parse refs/heads/master) && + main_sha=$(git -C "$server" rev-parse refs/heads/main) && git -C "$server" config uploadpack.allowreachablesha1inwant 1 && git init --bare test_reachable.git && git -C test_reachable.git remote add origin "$HTTPD_URL/smart/repo.git" && - git -C test_reachable.git fetch origin "$master_sha" + git -C test_reachable.git fetch origin "$main_sha" ' test_expect_success 'test allowreachablesha1inwant with unreachable' ' @@ -363,7 +366,7 @@ test_expect_success 'test allowreachablesha1inwant with unreachable' ' git push public :refs/heads/doomed && server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - master_sha=$(git -C "$server" rev-parse refs/heads/master) && + main_sha=$(git -C "$server" rev-parse refs/heads/main) && git -C "$server" config uploadpack.allowreachablesha1inwant 1 && git init --bare test_reachable.git && @@ -385,7 +388,7 @@ test_expect_success 'test allowanysha1inwant with unreachable' ' git push public :refs/heads/doomed && server="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && - master_sha=$(git -C "$server" rev-parse refs/heads/master) && + main_sha=$(git -C "$server" rev-parse refs/heads/main) && git -C "$server" config uploadpack.allowreachablesha1inwant 1 && git init --bare test_reachable.git && @@ -444,8 +447,8 @@ test_expect_success 'using fetch command in remote-curl updates refs' ' test_commit -C "$SERVER" bar && git -C client -c protocol.version=0 fetch && - git -C "$SERVER" rev-parse master >expect && - git -C client rev-parse origin/master >actual && + git -C "$SERVER" rev-parse main >expect && + git -C client rev-parse origin/main >actual && test_cmp expect actual ' @@ -514,4 +517,45 @@ test_expect_success 'server-side error detected' ' test_i18ngrep "server-side error" actual ' +test_expect_success 'http auth remembers successful credentials' ' + rm -f .git-credentials && + test_config credential.helper store && + + # the first request prompts the user... + set_askpass user@host pass@host && + git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null && + expect_askpass both user@host && + + # ...and the second one uses the stored value rather than + # prompting the user. + set_askpass bogus-user bogus-pass && + git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null && + expect_askpass none +' + +test_expect_success 'http auth forgets bogus credentials' ' + # seed credential store with bogus values. In real life, + # this would probably come from a password which worked + # for a previous request. + rm -f .git-credentials && + test_config credential.helper store && + { + echo "url=$HTTPD_URL" && + echo "username=bogus" && + echo "password=bogus" + } | git credential approve && + + # we expect this to use the bogus values and fail, never even + # prompting the user... + set_askpass user@host pass@host && + test_must_fail git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null && + expect_askpass none && + + # ...but now we should have forgotten the bad value, causing + # us to prompt the user again. + set_askpass user@host pass@host && + git ls-remote "$HTTPD_URL/auth/smart/repo.git" >/dev/null && + expect_askpass both user@host +' + test_done |