From: "Matthew John Cheetham via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, johannes.schindelin@gmx.de,
Matthew John Cheetham <mjcheetham@outlook.com>,
Matthew John Cheetham <mjcheetham@outlook.com>,
Matthew John Cheetham <mjcheetham@outlook.com>
Subject: [PATCH v2 3/4] t5563: add tests for http.emptyAuth with Negotiate
Date: Thu, 30 Apr 2026 10:54:31 +0000 [thread overview]
Message-ID: <650acab79ef5e45b6835b523a37cde184ad60e04.1777546472.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2087.v2.git.1777546472.gitgitgadget@gmail.com>
From: Matthew John Cheetham <mjcheetham@outlook.com>
Add tests exercising the interaction between http.emptyAuth and
servers that advertise Negotiate (SPNEGO) authentication.
Verify that auto mode gives Negotiate a chance via empty auth
(resulting in two 401 responses before falling through to
credential_fill with Basic credentials), and that false mode
strips Negotiate immediately (only one 401 response).
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
---
t/t5563-simple-http-auth.sh | 74 +++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/t/t5563-simple-http-auth.sh b/t/t5563-simple-http-auth.sh
index 0063581615..a7d475dd68 100755
--- a/t/t5563-simple-http-auth.sh
+++ b/t/t5563-simple-http-auth.sh
@@ -719,4 +719,78 @@ test_expect_success 'access using three-legged auth' '
EOF
'
+test_lazy_prereq SPNEGO 'curl --version | grep -qi "SPNEGO\|GSS-API\|Kerberos\|negotiate"'
+
+test_expect_success SPNEGO 'http.emptyAuth=auto attempts Negotiate before credential_fill' '
+ test_when_finished "per_test_cleanup" &&
+
+ set_credential_reply get <<-EOF &&
+ username=alice
+ password=secret-passwd
+ EOF
+
+ # Basic base64(alice:secret-passwd)
+ cat >"$HTTPD_ROOT_PATH/custom-auth.valid" <<-EOF &&
+ id=1 creds=Basic YWxpY2U6c2VjcmV0LXBhc3N3ZA==
+ EOF
+
+ cat >"$HTTPD_ROOT_PATH/custom-auth.challenge" <<-EOF &&
+ id=1 status=200
+ id=default response=WWW-Authenticate: Negotiate
+ id=default response=WWW-Authenticate: Basic realm="example.com"
+ EOF
+
+ test_config_global credential.helper test-helper &&
+ GIT_TRACE_CURL="$TRASH_DIRECTORY/trace-auto" \
+ git -c http.emptyAuth=auto \
+ ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
+
+ # In auto mode with a Negotiate+Basic server, there should be
+ # three 401 responses: (1) initial no-auth request, (2) empty-auth
+ # retry where Negotiate fails (no Kerberos ticket), (3) libcurl
+ # internal Negotiate retry. The fourth attempt uses Basic
+ # credentials from credential_fill and succeeds.
+ grep "HTTP/[0-9.]* 401" "$TRASH_DIRECTORY/trace-auto" >actual_401s &&
+ test_line_count = 3 actual_401s &&
+
+ expect_credential_query get <<-EOF
+ capability[]=authtype
+ capability[]=state
+ protocol=http
+ host=$HTTPD_DEST
+ wwwauth[]=Negotiate
+ wwwauth[]=Basic realm="example.com"
+ EOF
+'
+
+test_expect_success SPNEGO 'http.emptyAuth=false skips Negotiate' '
+ test_when_finished "per_test_cleanup" &&
+
+ set_credential_reply get <<-EOF &&
+ username=alice
+ password=secret-passwd
+ EOF
+
+ # Basic base64(alice:secret-passwd)
+ cat >"$HTTPD_ROOT_PATH/custom-auth.valid" <<-EOF &&
+ id=1 creds=Basic YWxpY2U6c2VjcmV0LXBhc3N3ZA==
+ EOF
+
+ cat >"$HTTPD_ROOT_PATH/custom-auth.challenge" <<-EOF &&
+ id=1 status=200
+ id=default response=WWW-Authenticate: Negotiate
+ id=default response=WWW-Authenticate: Basic realm="example.com"
+ EOF
+
+ test_config_global credential.helper test-helper &&
+ GIT_TRACE_CURL="$TRASH_DIRECTORY/trace-false" \
+ git -c http.emptyAuth=false \
+ ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
+
+ # With emptyAuth=false, Negotiate is stripped immediately and
+ # credential_fill is called right away. Only one 401 response.
+ grep "HTTP/[0-9.]* 401" "$TRASH_DIRECTORY/trace-false" >actual_401s &&
+ test_line_count = 1 actual_401s
+'
+
test_done
--
gitgitgadget
next prev parent reply other threads:[~2026-04-30 10:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-16 9:20 [PATCH 0/3] http: fix emptyAuth=auto for Negotiate/SPNEGO Matthew John Cheetham via GitGitGadget
2026-04-16 9:20 ` [PATCH 1/3] http: extract http_reauth_prepare() from retry paths Matthew John Cheetham via GitGitGadget
2026-04-16 16:21 ` Junio C Hamano
2026-04-16 9:20 ` [PATCH 2/3] http: attempt Negotiate auth in http.emptyAuth=auto mode Matthew John Cheetham via GitGitGadget
2026-04-16 16:40 ` Junio C Hamano
2026-04-28 14:38 ` Matthew John Cheetham
[not found] ` <xmqqse8dz4pi.fsf@gitster.g>
2026-04-30 10:53 ` Matthew John Cheetham
2026-04-16 9:20 ` [PATCH 3/3] t5563: add tests for http.emptyAuth with Negotiate Matthew John Cheetham via GitGitGadget
2026-04-30 10:54 ` [PATCH v2 0/4] http: fix emptyAuth=auto for Negotiate/SPNEGO Matthew John Cheetham via GitGitGadget
2026-04-30 10:54 ` [PATCH v2 1/4] http: extract http_reauth_prepare() from retry paths Matthew John Cheetham via GitGitGadget
2026-04-30 10:54 ` [PATCH v2 2/4] http: attempt Negotiate auth in http.emptyAuth=auto mode Matthew John Cheetham via GitGitGadget
2026-04-30 10:54 ` Matthew John Cheetham via GitGitGadget [this message]
2026-04-30 10:54 ` [PATCH v2 4/4] doc: clarify http.emptyAuth values Matthew John Cheetham via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=650acab79ef5e45b6835b523a37cde184ad60e04.1777546472.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=mjcheetham@outlook.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox