From 886f5dea80135d6e70af5f68939f7ed194ef3671 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 21 Feb 2025 16:24:01 +0100 Subject: [PATCH] test76: add test with comma-separated list of WWW-Auth methods The support for this is not 100% but at least this works. Closes #16425 --- lib/http.c | 2 + tests/data/Makefile.am | 2 +- tests/data/test76 | 108 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 tests/data/test76 diff --git a/lib/http.c b/lib/http.c index b2426da19a..ca8debe79d 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1014,6 +1014,8 @@ static CURLcode auth_bearer(struct Curl_easy *data, * Curl_http_input_auth() deals with Proxy-Authenticate: and WWW-Authenticate: * headers. They are dealt with both in the transfer.c main loop and in the * proxy CONNECT loop. + * + * The 'auth' line ends with a null byte without CR or LF present. */ CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy, const char *auth) /* the first non-space */ diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 6ce2879e9a..695160b8fd 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -33,7 +33,7 @@ test30 test31 test32 test33 test34 test35 test36 test37 test38 test39 \ test40 test41 test42 test43 test44 test45 test46 test47 test48 test49 \ test50 test51 test52 test53 test54 test55 test56 test57 test58 test59 \ test60 test61 test62 test63 test64 test65 test66 test67 test68 test69 \ -test70 test71 test72 test73 test74 test75 test77 test78 test79 \ +test70 test71 test72 test73 test74 test75 test76 test77 test78 test79 \ test80 test81 test82 test83 test84 test85 test86 test87 test88 test89 \ test90 test91 test92 test93 test94 test95 test96 test97 test98 test99 \ test100 test101 test102 test103 test104 test105 test106 test107 test108 \ diff --git a/tests/data/test76 b/tests/data/test76 new file mode 100644 index 0000000000..2300a38d00 --- /dev/null +++ b/tests/data/test76 @@ -0,0 +1,108 @@ + + + +HTTP +HTTP GET +HTTP NTLM auth +NTLM + + +# Server-side + + +HTTP/1.1 401 Authorization Required swsclose +Server: Apache/1.3.27 (Darwin) PHP/4.1.2 +WWW-Authenticate: Basic, Wild-and-crazy, NTLM +Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 + +This is not the real page + + +# This is supposed to be returned when the server gets a first +# Authorization: NTLM line passed-in from the client + +HTTP/1.1 401 Now gimme that second request of crap +Server: Microsoft-IIS/5.0 +Content-Length: 34 +Content-Type: text/html; charset=iso-8859-1 +WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAACGggEAc51AYVDgyNcAAAAAAAAAAG4AbgAyAAAAQ0MCAAQAQwBDAAEAEgBFAEwASQBTAEEAQgBFAFQASAAEABgAYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAwAsAGUAbABpAHMAYQBiAGUAdABoAC4AYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAAAAAA== + +This is not the real page either! + + +# This is supposed to be returned when the server gets the second +# Authorization: NTLM line passed-in from the client + +HTTP/1.1 200 Things are fine in server land swsclose +Server: Microsoft-IIS/5.0 +Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 + +Finally, this is the real page! + + + +HTTP/1.1 401 Authorization Required swsclose +Server: Apache/1.3.27 (Darwin) PHP/4.1.2 +WWW-Authenticate: Basic, Wild-and-crazy, NTLM +Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 + +HTTP/1.1 401 Now gimme that second request of crap +Server: Microsoft-IIS/5.0 +Content-Length: 34 +Content-Type: text/html; charset=iso-8859-1 +WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAACGggEAc51AYVDgyNcAAAAAAAAAAG4AbgAyAAAAQ0MCAAQAQwBDAAEAEgBFAEwASQBTAEEAQgBFAFQASAAEABgAYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAwAsAGUAbABpAHMAYQBiAGUAdABoAC4AYwBjAC4AaQBjAGUAZABlAHYALgBuAHUAAAAAAA== + +HTTP/1.1 200 Things are fine in server land swsclose +Server: Microsoft-IIS/5.0 +Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 + +Finally, this is the real page! + + + + +# Client-side + + +NTLM +SSL +!SSPI + + +http + + +HTTP with comma-separated WWW-Authenticate header + + +http://%HOSTIP:%HTTPPORT/%TESTNUMBER -u testuser:testpass --anyauth + + + +# Verify data after the test has been "shot" + + +GET /%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +User-Agent: curl/%VERSION +Accept: */* + +GET /%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA= +User-Agent: curl/%VERSION +Accept: */* + +GET /%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAALAAsAeAAAAAAAAAAAAAAAhoIBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyV09SS1NUQVRJT04= +User-Agent: curl/%VERSION +Accept: */* + + + + -- 2.47.2