dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.44k stars 4.76k forks source link

TaskWebClientTest.UploadValues_Success test is failing #79731

Closed wfurt closed 1 year ago

wfurt commented 1 year ago

https://helixre107v0xdeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-heads-viktorhofer-outerlocb9d28b3bc0f4e38be/System.Net.WebClient.Tests/3/console.ad6886a8.log?helixlogtype=result

The UploadValues_Success test fails:

/private/tmp/helix/working/B9E809D7/w/A7880996/e /private/tmp/helix/working/B9E809D7/w/A7880996/e
  Discovering: System.Net.WebClient.Tests (method display = ClassAndMethod, method display options = None)
  Discovered:  System.Net.WebClient.Tests (found 14 of 46 test cases)
  Starting:    System.Net.WebClient.Tests (parallel test collections = on, max threads = 6)
    System.Net.Tests.TaskWebClientTest.UploadValues_Success(echoServer: http://corefx-net-http11.azurewebsites.net/Echo.ashx) [FAIL]
      Assert.Contains() Failure
      Not found: To+be%2c+or+not+to+be%2c+that+is+the+question%3aWhether+'tis+Nobler+in+the+mind+to+sufferThe+Slings+and+Arrows+of+outrageous+Fortune%2cOr+to+take+Arms+against+a+Sea+of+troubles%2cAnd+by+opposing+end+them%3a
      In value:  {"Method":"POST","Url":"/Echo.ashx","Headers": {
                     "Content-Length": "213",
                     "Content-Type": "application/x-www-form-urlencoded",
                     "Host": "corefx-net-http11.azurewebsites.net",
                     "Max-Forwards": "10",
                     "X-ARR-LOG-ID": "54501534-edad-4476-9600-256fcae425b1",
                     "CLIENT-IP": "131.107.1.155:9241",
                     "DISGUISED-HOST": "corefx-net-http11.azurewebsites.net",
                     "X-SITE-DEPLOYMENT-ID": "corefx-net-http11",
                     "WAS-DEFAULT-HOSTNAME": "corefx-net-http11.azurewebsites.net",
                     "X-Forwarded-For": "131.107.1.155:9241",
                     "X-Original-URL": "/Echo.ashx",
                     "X-WAWS-Unencoded-URL": "/Echo.ashx"
                   },
                   "Cookies": {},
                   "BodyContent": "Data=To+be%2C+or+not+to+be%2C+that+is+the+question%3AWhether+%27tis+Nobler+in+the+mind+to+sufferThe+Slings+and+Arrows+of+outrageous+Fortune%2COr+to+take+Arms+against+a+Sea+of+troubles%2CAnd+by+opposing+end+them%3A",
                   "BodyLength": 213,
                   "SecureConnection": false,
                   "ClientCertificatePresent": false,
                   "ClientCertificate": null
                 }
      Stack Trace:

It seems like the expected ' is escaped as %27.

cc: @MihaZupan

ghost commented 1 year ago

Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.

Issue Details
https://helixre107v0xdeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-heads-viktorhofer-outerlocb9d28b3bc0f4e38be/System.Net.WebClient.Tests/3/console.ad6886a8.log?helixlogtype=result ``` /private/tmp/helix/working/B9E809D7/w/A7880996/e /private/tmp/helix/working/B9E809D7/w/A7880996/e Discovering: System.Net.WebClient.Tests (method display = ClassAndMethod, method display options = None) Discovered: System.Net.WebClient.Tests (found 14 of 46 test cases) Starting: System.Net.WebClient.Tests (parallel test collections = on, max threads = 6) System.Net.Tests.TaskWebClientTest.UploadValues_Success(echoServer: http://corefx-net-http11.azurewebsites.net/Echo.ashx) [FAIL] Assert.Contains() Failure Not found: To+be%2c+or+not+to+be%2c+that+is+the+question%3aWhether+'tis+Nobler+in+the+mind+to+sufferThe+Slings+and+Arrows+of+outrageous+Fortune%2cOr+to+take+Arms+against+a+Sea+of+troubles%2cAnd+by+opposing+end+them%3a In value: {"Method":"POST","Url":"/Echo.ashx","Headers": { "Content-Length": "213", "Content-Type": "application/x-www-form-urlencoded", "Host": "corefx-net-http11.azurewebsites.net", "Max-Forwards": "10", "X-ARR-LOG-ID": "54501534-edad-4476-9600-256fcae425b1", "CLIENT-IP": "131.107.1.155:9241", "DISGUISED-HOST": "corefx-net-http11.azurewebsites.net", "X-SITE-DEPLOYMENT-ID": "corefx-net-http11", "WAS-DEFAULT-HOSTNAME": "corefx-net-http11.azurewebsites.net", "X-Forwarded-For": "131.107.1.155:9241", "X-Original-URL": "/Echo.ashx", "X-WAWS-Unencoded-URL": "/Echo.ashx" }, "Cookies": {}, "BodyContent": "Data=To+be%2C+or+not+to+be%2C+that+is+the+question%3AWhether+%27tis+Nobler+in+the+mind+to+sufferThe+Slings+and+Arrows+of+outrageous+Fortune%2COr+to+take+Arms+against+a+Sea+of+troubles%2CAnd+by+opposing+end+them%3A", "BodyLength": 213, "SecureConnection": false, "ClientCertificatePresent": false, "ClientCertificate": null } Stack Trace: ``` It seems like the expected `'` is escaped as `%27`. cc: @MihaZupan
Author: wfurt
Assignees: -
Labels: `area-System.Net`, `test-run-core`
Milestone: 8.0.0
MihaZupan commented 1 year ago

https://github.com/dotnet/corefx/pull/18933 introduced an internal copy of the HttpUtility code for encoding the Uri. For whatever reason, it wasn't an exact copy - it included ' in the "safe" set of characters.

75896 removed this duplication and changed the behavior of ' again.

I'd be inclined to just update the test to use a new expected value. It's not clear to me how this set of "safe" characters came to be - it doesn't make any sense to me when compared to Uri.

Compare the HttpUtility code https://github.com/dotnet/runtime/blob/c0ebf2bdcdcef90f82c67d357750c34bb56c3f4c/src/libraries/System.Web.HttpUtility/src/System/Web/Util/HttpEncoderUtility.cs#L19-L29 to the WebClient code in 7.0 https://github.com/dotnet/runtime/blob/8ac3832812f9bc37fba2a66ac8987ca66d381d85/src/libraries/System.Net.WebClient/src/System/Net/WebClient.cs#L1257-L1268

wfurt commented 1 year ago

I'm fine with that as long as we feel it will not break anybody. I just noticed failing tests as they run agains (tanks to @ViktorHofer)

akoeplinger commented 1 year ago

@MihaZupan do you plan on updating the test soon or should we disable it in the meantime to get a clean run?

akoeplinger commented 1 year ago

@MihaZupan FYI the test needs to be reenabled in https://github.com/dotnet/runtime/blob/cf91dbe06ee4f57bcba01aa66570251e9104e0dc/src/libraries/System.Net.WebClient/tests/WebClientTest.cs#L700