Skip to content

Commit c4304d4

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 4ca96ab commit c4304d4

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
@@ -793,4 +793,78 @@ test_expect_success NTLM 'access using NTLM auth' '
793793
git ls-remote "$HTTPD_URL/ntlm_auth/repo.git"
794794
'
795795

796+
test_lazy_prereq SPNEGO 'curl --version | grep -qi "SPNEGO\|GSS-API\|Kerberos\|negotiate"'
797+
798+
test_expect_success SPNEGO 'http.emptyAuth=auto attempts Negotiate before credential_fill' '
799+
test_when_finished "per_test_cleanup" &&
800+
801+
set_credential_reply get <<-EOF &&
802+
username=alice
803+
password=secret-passwd
804+
EOF
805+
806+
# Basic base64(alice:secret-passwd)
807+
cat >"$HTTPD_ROOT_PATH/custom-auth.valid" <<-EOF &&
808+
id=1 creds=Basic YWxpY2U6c2VjcmV0LXBhc3N3ZA==
809+
EOF
810+
811+
cat >"$HTTPD_ROOT_PATH/custom-auth.challenge" <<-EOF &&
812+
id=1 status=200
813+
id=default response=WWW-Authenticate: Negotiate
814+
id=default response=WWW-Authenticate: Basic realm="example.com"
815+
EOF
816+
817+
test_config_global credential.helper test-helper &&
818+
GIT_TRACE_CURL="$TRASH_DIRECTORY/trace-auto" \
819+
git -c http.emptyAuth=auto \
820+
ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
821+
822+
# In auto mode with a Negotiate+Basic server, there should be
823+
# three 401 responses: (1) initial no-auth request, (2) empty-auth
824+
# retry where Negotiate fails (no Kerberos ticket), (3) libcurl
825+
# internal Negotiate retry. The fourth attempt uses Basic
826+
# credentials from credential_fill and succeeds.
827+
grep "HTTP/[0-9.]* 401" "$TRASH_DIRECTORY/trace-auto" >actual_401s &&
828+
test_line_count = 3 actual_401s &&
829+
830+
expect_credential_query get <<-EOF
831+
capability[]=authtype
832+
capability[]=state
833+
protocol=http
834+
host=$HTTPD_DEST
835+
wwwauth[]=Negotiate
836+
wwwauth[]=Basic realm="example.com"
837+
EOF
838+
'
839+
840+
test_expect_success SPNEGO 'http.emptyAuth=false skips Negotiate' '
841+
test_when_finished "per_test_cleanup" &&
842+
843+
set_credential_reply get <<-EOF &&
844+
username=alice
845+
password=secret-passwd
846+
EOF
847+
848+
# Basic base64(alice:secret-passwd)
849+
cat >"$HTTPD_ROOT_PATH/custom-auth.valid" <<-EOF &&
850+
id=1 creds=Basic YWxpY2U6c2VjcmV0LXBhc3N3ZA==
851+
EOF
852+
853+
cat >"$HTTPD_ROOT_PATH/custom-auth.challenge" <<-EOF &&
854+
id=1 status=200
855+
id=default response=WWW-Authenticate: Negotiate
856+
id=default response=WWW-Authenticate: Basic realm="example.com"
857+
EOF
858+
859+
test_config_global credential.helper test-helper &&
860+
GIT_TRACE_CURL="$TRASH_DIRECTORY/trace-false" \
861+
git -c http.emptyAuth=false \
862+
ls-remote "$HTTPD_URL/custom_auth/repo.git" &&
863+
864+
# With emptyAuth=false, Negotiate is stripped immediately and
865+
# credential_fill is called right away. Only one 401 response.
866+
grep "HTTP/[0-9.]* 401" "$TRASH_DIRECTORY/trace-false" >actual_401s &&
867+
test_line_count = 1 actual_401s
868+
'
869+
796870
test_done

0 commit comments

Comments
 (0)