aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--remote-curl.c1
-rwxr-xr-xt/t5563-simple-http-auth.sh45
2 files changed, 46 insertions, 0 deletions
diff --git a/remote-curl.c b/remote-curl.c
index 69f919454a..92e40bb682 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -876,6 +876,7 @@ static int probe_rpc(struct rpc_state *rpc, struct slot_results *results)
headers = curl_slist_append(headers, rpc->hdr_content_type);
headers = curl_slist_append(headers, rpc->hdr_accept);
+ headers = http_append_auth_header(&http_auth, headers);
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0L);
curl_easy_setopt(slot->curl, CURLOPT_POST, 1L);
diff --git a/t/t5563-simple-http-auth.sh b/t/t5563-simple-http-auth.sh
index c1febbae9d..0063581615 100755
--- a/t/t5563-simple-http-auth.sh
+++ b/t/t5563-simple-http-auth.sh
@@ -605,6 +605,51 @@ test_expect_success 'access using bearer auth with invalid credentials' '
EOF
'
+test_expect_success 'clone with bearer auth and probe_rpc' '
+ test_when_finished "per_test_cleanup" &&
+ test_when_finished "rm -rf large.git" &&
+
+ # Set up a repository large enough to trigger probe_rpc
+ git init large.git &&
+ (
+ cd large.git &&
+ git config set maintenance.auto false &&
+ git commit --allow-empty --message "initial" &&
+ # Create many refs to trigger probe_rpc, which is called when
+ # the request body is larger than http.postBuffer.
+ #
+ # In the test later, http.postBuffer is set to 70000. Each
+ # "want" line is ~45 bytes, so we need at least 70000/45 = ~1600
+ # refs
+ test_seq -f "create refs/heads/branch-%d @" 2000 |
+ git update-ref --stdin
+ ) &&
+ git clone --bare large.git "$HTTPD_DOCUMENT_ROOT_PATH/large.git" &&
+
+ # Clone it through HTTP with a Bearer token
+ set_credential_reply get <<-EOF &&
+ capability[]=authtype
+ authtype=Bearer
+ credential=YS1naXQtdG9rZW4=
+ EOF
+
+ # Bearer token
+ cat >"$HTTPD_ROOT_PATH/custom-auth.valid" <<-EOF &&
+ id=1 creds=Bearer YS1naXQtdG9rZW4=
+ EOF
+
+ cat >"$HTTPD_ROOT_PATH/custom-auth.challenge" <<-EOF &&
+ id=1 status=200
+ id=default response=WWW-Authenticate: Bearer authorize_uri="id.example.com"
+ EOF
+
+ # Set a small buffer to force probe_rpc to be called
+ # Must be > LARGE_PACKET_MAX (65520)
+ test_config_global http.postBuffer 70000 &&
+ test_config_global credential.helper test-helper &&
+ git clone "$HTTPD_URL/custom_auth/large.git" partial-auth-clone 2>clone-error
+'
+
test_expect_success 'access using three-legged auth' '
test_when_finished "per_test_cleanup" &&