From: Jay Satiro Date: Sat, 25 Jan 2025 08:17:10 +0000 (-0500) Subject: tests: change the behavior of swsbounce X-Git-Tag: curl-8_12_0~51 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1a36923d73bf9c7ac234bdf9aaa1c1eca9fdbc5e;p=thirdparty%2Fcurl.git tests: change the behavior of swsbounce - Change the swsbounce keyword to override the part number on a subsequent request to the previous part number + 1. Note the previous part number in this case is the part number that was returned as a response to the previous request and contained the swsbounce keyword. Prior to this change swsbounce incremented the part number of the subsequent request instead of overriding it, and did so in a more limited fashion that prevented chaining swsbounce in multiple responses. For example, if the test makes a request that causes the sws server to return `` as a response and that response contains `swsbounce` then for the next response the sws server returns ``. If `` also contains `swsbounce` then for the next response the sws server now returns `` instead of the requested part. Fixes https://github.com/curl/curl/discussions/16074 Closes https://github.com/curl/curl/pull/16085 --- diff --git a/tests/FILEFORMAT.md b/tests/FILEFORMAT.md index 529bbc0196..5b5f82dea4 100644 --- a/tests/FILEFORMAT.md +++ b/tests/FILEFORMAT.md @@ -237,10 +237,14 @@ If the data contains `swsclose` anywhere within the start and end tag, and this is an HTTP test, then the connection is closed by the server after this response is sent. If not, the connection is kept persistent. -If the data contains `swsbounce` anywhere within the start and end tag, the -HTTP server detects if this is a second request using the same test and part -number and then increases the part number with one. This is useful for auth -tests and similar. +If the data contains `swsbounce` anywhere within the start and end tag, then +the HTTP server overrides the part number response returned for a subsequent +request made by the same test to `previous part number + 1`. For example, if a +test makes a request which causes the server to return `` that contains +keyword `swsbounce` then for the next response it ignores the requested part +number and instead returns ``. And if `` contains keyword +`swsbounce` then the next response is `` and so on. This is useful for +auth tests and similar. `sendzero=yes` means that the (FTP) server "sends" the data even if the size is zero bytes. Used to verify curl's behavior on zero bytes transfers. diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index f39a30f466..43c30d5e3f 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -268,6 +268,7 @@ test3000 test3001 test3002 test3003 test3004 test3005 test3006 test3007 \ test3008 test3009 test3010 test3011 test3012 test3013 test3014 test3015 \ test3016 test3017 test3018 test3019 test3020 test3021 test3022 test3023 \ test3024 test3025 test3026 test3027 test3028 test3029 test3030 test3031 \ +test3032 \ \ test3100 test3101 test3102 test3103 test3104 test3105 \ test3200 \ diff --git a/tests/data/test1001 b/tests/data/test1001 index 4220ab6759..63eb072fdc 100644 --- a/tests/data/test1001 +++ b/tests/data/test1001 @@ -19,7 +19,7 @@ Server: Microsoft-IIS/5.0 Date: Sun, 03 Apr 2005 14:57:45 GMT X-Powered-By: ASP.NET -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 @@ -41,7 +41,7 @@ Server: Microsoft-IIS/5.0 Date: Sun, 03 Apr 2005 14:57:45 GMT X-Powered-By: ASP.NET -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test1002 b/tests/data/test1002 index 92cb5e1585..50f7dcf2a8 100644 --- a/tests/data/test1002 +++ b/tests/data/test1002 @@ -18,7 +18,7 @@ Server: Microsoft-IIS/5.0 Date: Sun, 03 Apr 2005 14:57:45 GMT X-Powered-By: ASP.NET -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 @@ -40,7 +40,7 @@ Server: Microsoft-IIS/5.0 Date: Sun, 03 Apr 2005 14:57:45 GMT X-Powered-By: ASP.NET -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test1060 b/tests/data/test1060 index c1ad6c6676..ce7a37ea09 100644 --- a/tests/data/test1060 +++ b/tests/data/test1060 @@ -836,7 +836,7 @@ daniel # then this is returned when we get proxy-auth -HTTP/1.1 200 OK swsbounce +HTTP/1.1 200 OK Server: no @@ -847,7 +847,7 @@ Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345" Content-Length: 40000 X-tra-long-header: %repeat[16080 x a]% -HTTP/1.1 200 OK swsbounce +HTTP/1.1 200 OK Server: no HTTP/1.1 200 OK diff --git a/tests/data/test1061 b/tests/data/test1061 index 76241142c9..0e383598d0 100644 --- a/tests/data/test1061 +++ b/tests/data/test1061 @@ -841,7 +841,7 @@ daniel # then this is returned when we get proxy-auth -HTTP/1.1 200 OK swsbounce +HTTP/1.1 200 OK Server: no @@ -852,7 +852,7 @@ Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345" Transfer-Encoding: chunked X-tra-long-header: %repeat[16080 x a]% -HTTP/1.1 200 OK swsbounce +HTTP/1.1 200 OK Server: no HTTP/1.1 200 OK diff --git a/tests/data/test1284 b/tests/data/test1284 index dd2d8b8b7c..2900c512ef 100644 --- a/tests/data/test1284 +++ b/tests/data/test1284 @@ -10,7 +10,7 @@ HTTP Digest auth # Server-side -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 @@ -27,7 +27,7 @@ ok -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test1285 b/tests/data/test1285 index 986cb92cc7..ee5f13c5e5 100644 --- a/tests/data/test1285 +++ b/tests/data/test1285 @@ -10,7 +10,7 @@ HTTP Digest auth # Server-side -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 @@ -27,7 +27,7 @@ ok -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test1286 b/tests/data/test1286 index df0f35fc5a..e898a37d30 100644 --- a/tests/data/test1286 +++ b/tests/data/test1286 @@ -11,7 +11,7 @@ followlocation # Server-side -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", qop="auth" Content-Type: text/html; charset=iso-8859-1 @@ -35,7 +35,7 @@ Content-Length: 0 -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", qop="auth" Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test176 b/tests/data/test176 index eba8fef78c..0eab979c90 100644 --- a/tests/data/test176 +++ b/tests/data/test176 @@ -11,7 +11,7 @@ HTTP NTLM auth # the first request has NTLM type-1 included, and then the 1001 is returned -HTTP/1.1 200 beng swsclose swsbounce +HTTP/1.1 200 beng swsclose Server: Microsoft-IIS/6.0 Authentication-Info: Passport1.4 tname=MSPAuth,tname=MSPProf,tname=MSPConsent,tname=MSPSecAuth Content-Type: text/html; charset=iso-8859-1 @@ -29,7 +29,7 @@ content for you -HTTP/1.1 200 beng swsclose swsbounce +HTTP/1.1 200 beng swsclose Server: Microsoft-IIS/6.0 Authentication-Info: Passport1.4 tname=MSPAuth,tname=MSPProf,tname=MSPConsent,tname=MSPSecAuth Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test2058 b/tests/data/test2058 index 4dfac74b7d..c85d534c9a 100644 --- a/tests/data/test2058 +++ b/tests/data/test2058 @@ -19,7 +19,7 @@ Server: Microsoft-IIS/5.0 Date: Sun, 03 Apr 2005 14:57:45 GMT X-Powered-By: ASP.NET -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", algorithm="SHA-256", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 @@ -41,7 +41,7 @@ Server: Microsoft-IIS/5.0 Date: Sun, 03 Apr 2005 14:57:45 GMT X-Powered-By: ASP.NET -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", algorithm="SHA-256", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test2059 b/tests/data/test2059 index e2957bce5d..5b924a5847 100644 --- a/tests/data/test2059 +++ b/tests/data/test2059 @@ -19,7 +19,7 @@ Server: Microsoft-IIS/5.0 Date: Sun, 03 Apr 2005 14:57:45 GMT X-Powered-By: ASP.NET -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", algorithm="SHA-256", nonce="1053604144", userhash=true Content-Type: text/html; charset=iso-8859-1 @@ -41,7 +41,7 @@ Server: Microsoft-IIS/5.0 Date: Sun, 03 Apr 2005 14:57:45 GMT X-Powered-By: ASP.NET -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", algorithm="SHA-256", nonce="1053604144", userhash=true Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test206 b/tests/data/test206 index 19fbbfb4a5..60e103d098 100644 --- a/tests/data/test206 +++ b/tests/data/test206 @@ -41,7 +41,7 @@ daniel # then this is returned when we get proxy-auth -HTTP/1.1 200 OK swsbounce +HTTP/1.1 200 OK Server: no @@ -51,7 +51,7 @@ HTTP/1.1 407 Authorization Required to proxy me my dear Proxy-Authenticate: Digest realm="weirdorealm", nonce="12345" Content-Length: 33 -HTTP/1.1 200 OK swsbounce +HTTP/1.1 200 OK Server: no HTTP/1.1 200 OK diff --git a/tests/data/test2060 b/tests/data/test2060 index e1632a387d..860f40eb8f 100644 --- a/tests/data/test2060 +++ b/tests/data/test2060 @@ -19,7 +19,7 @@ Server: Microsoft-IIS/5.0 Date: Sun, 03 Apr 2005 14:57:45 GMT X-Powered-By: ASP.NET -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", algorithm="SHA-512-256", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 @@ -41,7 +41,7 @@ Server: Microsoft-IIS/5.0 Date: Sun, 03 Apr 2005 14:57:45 GMT X-Powered-By: ASP.NET -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", algorithm="SHA-512-256", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test2067 b/tests/data/test2067 index 4fdd4dcbb0..a65fb52500 100644 --- a/tests/data/test2067 +++ b/tests/data/test2067 @@ -10,7 +10,7 @@ HTTP Digest auth # Server-side -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", algorithm="SHA-256" Content-Type: text/html; charset=iso-8859-1 @@ -27,7 +27,7 @@ ok -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", algorithm="SHA-256" Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test2068 b/tests/data/test2068 index 32afd26290..1a6d271349 100644 --- a/tests/data/test2068 +++ b/tests/data/test2068 @@ -10,7 +10,7 @@ HTTP Digest auth # Server-side -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", algorithm="SHA-512-256" Content-Type: text/html; charset=iso-8859-1 @@ -27,7 +27,7 @@ ok -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", algorithm="SHA-512-256" Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test2069 b/tests/data/test2069 index 74d719fd3e..86aa18301a 100644 --- a/tests/data/test2069 +++ b/tests/data/test2069 @@ -10,7 +10,7 @@ HTTP Digest auth # Server-side -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", algorithm="SHA-256", userhash=true Content-Type: text/html; charset=iso-8859-1 @@ -27,7 +27,7 @@ ok -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144", algorithm="SHA-256", userhash=true Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test245 b/tests/data/test245 index 78893f028e..60319ebc2d 100644 --- a/tests/data/test245 +++ b/tests/data/test245 @@ -10,7 +10,7 @@ HTTP Digest auth # Server-side -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 @@ -27,7 +27,7 @@ ok -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test246 b/tests/data/test246 index a756028b9c..67bf446d74 100644 --- a/tests/data/test246 +++ b/tests/data/test246 @@ -15,7 +15,7 @@ Server: Microsoft-IIS/5.0 Date: Sun, 03 Apr 2005 14:57:45 GMT X-Powered-By: ASP.NET -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 @@ -37,7 +37,7 @@ Server: Microsoft-IIS/5.0 Date: Sun, 03 Apr 2005 14:57:45 GMT X-Powered-By: ASP.NET -HTTP/1.1 401 authentication please swsbounce +HTTP/1.1 401 authentication please Server: Microsoft-IIS/6.0 WWW-Authenticate: Digest realm="testrealm", nonce="1053604144" Content-Type: text/html; charset=iso-8859-1 diff --git a/tests/data/test3032 b/tests/data/test3032 new file mode 100644 index 0000000000..985ff4ff64 --- /dev/null +++ b/tests/data/test3032 @@ -0,0 +1,112 @@ + + + +HTTP +--location + + + +# Server-side + + + +HTTP/1.1 301 redirect swsbounce +Content-Length: 0 +Location: http://%HOSTIP:%HTTPPORT/%TESTNUMBER +Part: data + + + + +HTTP/1.1 301 redirect swsbounce +Content-Length: 0 +Location: http://%HOSTIP:%HTTPPORT/%TESTNUMBER +Part: data1 + + + + +HTTP/1.1 301 redirect swsbounce +Content-Length: 0 +Location: http://%HOSTIP:%HTTPPORT/%TESTNUMBER +Part: data2 + + + + +HTTP/1.1 200 OK +Content-Type: text/html +Content-Length: 30 +Part: data3 + +XXXXXXXXXXXXXXXXXXXXXXXXXXXXX + + + +HTTP/1.1 301 redirect swsbounce +Content-Length: 0 +Location: http://%HOSTIP:%HTTPPORT/%TESTNUMBER +Part: data + +HTTP/1.1 301 redirect swsbounce +Content-Length: 0 +Location: http://%HOSTIP:%HTTPPORT/%TESTNUMBER +Part: data1 + +HTTP/1.1 301 redirect swsbounce +Content-Length: 0 +Location: http://%HOSTIP:%HTTPPORT/%TESTNUMBER +Part: data2 + +HTTP/1.1 200 OK +Content-Type: text/html +Content-Length: 30 +Part: data3 + +XXXXXXXXXXXXXXXXXXXXXXXXXXXXX + + + + +# Client-side + + +http + +# This is a test of the swsbounce keyword which is used during tests to +# override the data response number for the next request to the previous +# data response number + 1. eg data, data1, data2 etc. + +HTTP redirect loop 3x swsbounce test + + +--location http://%HOSTIP:%HTTPPORT/%TESTNUMBER + + + +# 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 +User-Agent: curl/%VERSION +Accept: */* + +GET /%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +User-Agent: curl/%VERSION +Accept: */* + +GET /%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +User-Agent: curl/%VERSION +Accept: */* + + + + diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c index 73cddcf098..707d20706e 100644 --- a/tests/server/rtspd.c +++ b/tests/server/rtspd.c @@ -72,9 +72,9 @@ static int serverlogslocked = 0; static long prevtestno = -1; /* previous test number we served */ static long prevpartno = -1; /* previous part number we served */ -static bool prevbounce = FALSE; /* instructs the server to increase the part - number for a test in case the identical - testno+partno request shows up again */ +static bool prevbounce = FALSE; /* instructs the server to override the + requested part number to prevpartno + 1 when + prevtestno and current test are the same */ #define RCMD_NORMALREQ 0 /* default request, use the tests file normally */ #define RCMD_IDLE 1 /* told to sit idle */ @@ -1319,9 +1319,8 @@ int main(int argc, char *argv[]) if(prevbounce) { /* bounce treatment requested */ - if((req.testno == prevtestno) && - (req.partno == prevpartno)) { - req.partno++; + if(req.testno == prevtestno) { + req.partno = prevpartno + 1; logmsg("BOUNCE part number to %ld", req.partno); } else { diff --git a/tests/server/sws.c b/tests/server/sws.c index 9e364d1d68..e6aefe3e94 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -84,9 +84,9 @@ static bool is_proxy = FALSE; static long prevtestno = -1; /* previous test number we served */ static long prevpartno = -1; /* previous part number we served */ -static bool prevbounce = FALSE; /* instructs the server to increase the part - number for a test in case the identical - testno+partno request shows up again */ +static bool prevbounce = FALSE; /* instructs the server to override the + requested part number to prevpartno + 1 when + prevtestno and current test are the same */ #define RCMD_NORMALREQ 0 /* default request, use the tests file normally */ #define RCMD_IDLE 1 /* told to sit idle */ @@ -1982,9 +1982,8 @@ static int service_connection(curl_socket_t msgsock, struct httprequest *req, if(prevbounce) { /* bounce treatment requested */ - if((req->testno == prevtestno) && - (req->partno == prevpartno)) { - req->partno++; + if(req->testno == prevtestno) { + req->partno = prevpartno + 1; logmsg("BOUNCE part number to %ld", req->partno); } else {