Skip to content

Commit a82b913

Browse files
mjcheethamGit for Windows Build Agent
authored andcommitted
t5563: add tests for http.emptyAuth with Negotiate
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>
1 parent 86a0ea9 commit a82b913

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

t/t5563-simple-http-auth.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,4 +748,78 @@ test_expect_success NTLM 'access using NTLM auth' '
748748
git ls-remote "$HTTPD_URL/ntlm_auth/repo.git"
749749
'
750750

751+
test_lazy_prereq SPNEGO 'curl --version | grep -qi "SPNEGO\|GSS-API\|Kerberos\|negotiate"'
752+
753+
test_expect_success SPNEGO 'http.emptyAuth=auto attempts Negotiate before credential_fill' '
754+
test_when_finished "per_test_cleanup" &&
755+
756+
set_credential_reply get <<-EOF &&
757+
username=alice
758+
password=secret-passwd
759+
EOF
760+
761+
# Basic base64(alice:secret-passwd)
762+
cat >"$HTTPD_ROOT_PATH/custom-auth.valid" <<-EOF &&
763+
id=1 creds=Basic YWxpY2U6c2VjcmV0LXBhc3N3ZA==
764+
EOF
765+
766+
cat >"$HTTPD_ROOT_PATH/custom-auth.challenge" <<-EOF &&
767+
id=1 status=200
768+
id=default response=WWW-Authenticate: Negotiate
769+
id=default response=WWW-Authenticate: Basic realm="example.com"
770+
EOF
771+
772+
test_config_global credential.helper test-helper &&
773+
GIT_TRACE_CURL="$TRASH_DIRECTORY/trace-auto" \
774+
git -c http.emptyAuth=auto \
775+
ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
776+
777+
# In auto mode with a Negotiate+Basic server, there should be
778+
# three 401 responses: (1) initial no-auth request, (2) empty-auth
779+
# retry where Negotiate fails (no Kerberos ticket), (3) libcurl
780+
# internal Negotiate retry. The fourth attempt uses Basic
781+
# credentials from credential_fill and succeeds.
782+
grep "HTTP/[0-9.]* 401" "$TRASH_DIRECTORY/trace-auto" >actual_401s &&
783+
test_line_count = 3 actual_401s &&
784+
785+
expect_credential_query get <<-EOF
786+
capability[]=authtype
787+
capability[]=state
788+
protocol=http
789+
host=$HTTPD_DEST
790+
wwwauth[]=Negotiate
791+
wwwauth[]=Basic realm="example.com"
792+
EOF
793+
'
794+
795+
test_expect_success SPNEGO 'http.emptyAuth=false skips Negotiate' '
796+
test_when_finished "per_test_cleanup" &&
797+
798+
set_credential_reply get <<-EOF &&
799+
username=alice
800+
password=secret-passwd
801+
EOF
802+
803+
# Basic base64(alice:secret-passwd)
804+
cat >"$HTTPD_ROOT_PATH/custom-auth.valid" <<-EOF &&
805+
id=1 creds=Basic YWxpY2U6c2VjcmV0LXBhc3N3ZA==
806+
EOF
807+
808+
cat >"$HTTPD_ROOT_PATH/custom-auth.challenge" <<-EOF &&
809+
id=1 status=200
810+
id=default response=WWW-Authenticate: Negotiate
811+
id=default response=WWW-Authenticate: Basic realm="example.com"
812+
EOF
813+
814+
test_config_global credential.helper test-helper &&
815+
GIT_TRACE_CURL="$TRASH_DIRECTORY/trace-false" \
816+
git -c http.emptyAuth=false \
817+
ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
818+
819+
# With emptyAuth=false, Negotiate is stripped immediately and
820+
# credential_fill is called right away. Only one 401 response.
821+
grep "HTTP/[0-9.]* 401" "$TRASH_DIRECTORY/trace-false" >actual_401s &&
822+
test_line_count = 1 actual_401s
823+
'
824+
751825
test_done

0 commit comments

Comments
 (0)