Skip to content

Commit

Permalink
tests: change the behavior of swsbounce
Browse files Browse the repository at this point in the history
- 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 `<data>` as a response and that response contains `swsbounce`
then for the next response the sws server returns `<data1>`. If
`<data1>` also contains `swsbounce` then for the next response the sws
server now returns `<data2>` instead of the requested part.

Fixes curl#16074
Closes curl#16085
  • Loading branch information
jay committed Jan 26, 2025
1 parent 516cb98 commit 1a36923
Show file tree
Hide file tree
Showing 22 changed files with 165 additions and 50 deletions.
12 changes: 8 additions & 4 deletions tests/FILEFORMAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<data>` that contains
keyword `swsbounce` then for the next response it ignores the requested part
number and instead returns `<data1>`. And if `<data1>` contains keyword
`swsbounce` then the next response is `<data2>` 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.
Expand Down
1 change: 1 addition & 0 deletions tests/data/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test1001
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test1002
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test1060
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ daniel

# then this is returned when we get proxy-auth
<connect1000>
HTTP/1.1 200 OK swsbounce
HTTP/1.1 200 OK
Server: no

</connect1000>
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test1061
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ daniel

# then this is returned when we get proxy-auth
<connect1000>
HTTP/1.1 200 OK swsbounce
HTTP/1.1 200 OK
Server: no

</connect1000>
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test1284
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ HTTP Digest auth
# Server-side
<reply>
<data>
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
Expand All @@ -27,7 +27,7 @@ ok
</data1000>

<datacheck>
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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test1285
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ HTTP Digest auth
# Server-side
<reply>
<data>
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
Expand All @@ -27,7 +27,7 @@ ok
</data1000>

<datacheck>
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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test1286
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ followlocation
# Server-side
<reply>
<data>
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
Expand All @@ -35,7 +35,7 @@ Content-Length: 0
</data1001>

<datacheck>
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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test176
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ HTTP NTLM auth
<reply>
# the first request has NTLM type-1 included, and then the 1001 is returned
<data1001>
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
Expand All @@ -29,7 +29,7 @@ content for you
</data>

<datacheck>
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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test2058
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test2059
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test206
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ daniel

# then this is returned when we get proxy-auth
<connect1000>
HTTP/1.1 200 OK swsbounce
HTTP/1.1 200 OK
Server: no

</connect1000>
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test2060
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test2067
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ HTTP Digest auth
# Server-side
<reply>
<data>
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
Expand All @@ -27,7 +27,7 @@ ok
</data1000>

<datacheck>
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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test2068
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ HTTP Digest auth
# Server-side
<reply>
<data>
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
Expand All @@ -27,7 +27,7 @@ ok
</data1000>

<datacheck>
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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test2069
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ HTTP Digest auth
# Server-side
<reply>
<data>
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
Expand All @@ -27,7 +27,7 @@ ok
</data1000>

<datacheck>
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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test245
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ HTTP Digest auth
# Server-side
<reply>
<data>
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
Expand All @@ -27,7 +27,7 @@ ok
</data1000>

<datacheck>
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
Expand Down
4 changes: 2 additions & 2 deletions tests/data/test246
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 1a36923

Please sign in to comment.