* Cleanup Windows 10 version detection
Windows 10 Version 1709 ("Fall Creators Update") has been released. This
PR cleans up the version detection to use the latest RTM build numbers
and removes obsolete InsiderPreview detection for those tests.
Also, removed ActiveIssue for tests that are now fixed due to Windows 10
fixes.
Fixesdotnet/corefx#22187
* Addressed feedback
Commit migrated from https://github.com/dotnet/corefx/commit/ac410223aa763a0f67880815057ee1bfe0f4cb6e
- At least until socket send/receives respect cancellation, we need to poll for cancellation after the handler's SendAsync completes.
- We're unnecessarily allocating another CTS if no external cancellation was provided.
- We're not disposing of the response object in the case of an error after SendAsync completes.
Commit migrated from https://github.com/dotnet/corefx/commit/baf2128a7cdf4a7638be1e86a6fc18651f3945d3
- Have ClientWebSocket change the scheme from http{s} -> ws{s} instead of having HttpClient accept ws{s} urls.
- Use a duplex response stream only when the status code is 101
- Disable a test that relies on connection opening being cancelable
Commit migrated from https://github.com/dotnet/corefx/commit/518ea1c2f8ad882c9829c8c35d27d92063ac67f7
ClientWebSocket's managed implementation currently has its own basic Socket-based code for establishing a websocket connection. This change switches it to use ManagedHandler instead, and in doing so benefits from improvements made to ManagedHandler thus far and in the future. For example, currently ManagedWebSocket doesn't support ClientWebSocketOptions.Proxy or ClientWebSocketOptions.Credentials, but since ManagedHandler does, now ManagedWebSocket does, too.
Commit migrated from https://github.com/dotnet/corefx/commit/db9f342cc43e0096b42d4d6d008c095da2bb8cfa
There's no guarantee that WebSocket.ReceiveAsync will return a complete message; in the extreme, a message can contain long.MaxValue bytes but the API only allows you to retrieve ~int.MaxValue at a time, but even way below that, it's common for ReceiveAsync to return the data it has available rather than gathering up all of the data from the message. However, several of the ConnectTest tests were depending on the full-message behavior. This commit fixes that.
Commit migrated from https://github.com/dotnet/corefx/commit/ffaf5375c00622b285997bc9626c042b9d64195c
* Moving PlatformDetection to Corefx.Private.TestUtilities assembly
The purpose of this change is to clean up all test projects instead of including the PlatformDetection code inside every test project, we’ll have it in the Corefx.Private.TestUtilities.
I have refactored the PlatformDetection to split the different implementation of Windows and Linux. If we need to do more refactoring there we can do it later as needed.
* Fix Linux BB
* Update the xunit package reference
* Fix wrong condition on one of the tests
* Update the ConditionalFact/Theory to use Type as a parameter
Commit migrated from https://github.com/dotnet/corefx/commit/878e2fcf5a9f1068015e5fada9231088663e3490
Re-enabling ClientWebSocket's CloseTest and CancelTest runs for UWP.
All of these tests pass after a minor behavioral fix, where the "cancel pending ReceiveAsync" scenario was resulting in a different exception type compared to .NET Framework and non-UWP .NET Core. The following CancelTest test cases caught the bad behavior that I'm fixing as part of this PR:
ReceiveAsync_CancelThenReceive_ThrowsOperationCanceledException
ReceiveAsync_ReceiveThenCancel_ThrowsOperationCanceledException
ReceiveAsync_AfterCancellationDoReceiveAsync_ThrowsWebSocketException
Contributes to dotnet/corefx#20132
Commit migrated from https://github.com/dotnet/corefx/commit/218348948f536a89f71a61f279d50353f587eb0d
* Implement client certificates for HttpClient on UAP
Added code for HttpClientHandler.ClientCertificates on UAP.
Moved code duplicated in several places into a common helper class, CertificateHelper.
Then I discovered a bug introduced into GetEligibleCertificates (from PR dotnet/corefx#21908) that
doesn't properly filter by EKU or KeyUsage if there is only one cert (this was failing
the WinHttpHandler Unit tests). So, I removed that optimization.
Used the new Azure test endpoint for client certificates. I did not use the loopback
server because there is a problem using it with HttpClient in UAP. There is a crash
in the SslStream.AuthenticateAsServer that I was not able to diagnose yet. It will
require a lot of time debugging and I wanted to get this HttpClientHandler feature
done now. Tracking that investigation with dotnet/corefx#22021.
Fixesdotnet/corefx#21628
Contributes to dotnet/corefx#14542
* Address PR feedback
* Moved method to Windows-only Common file
* Fixed some line spacing
Other potential refactoring/optimizations will be looked into in dotnet/corefx#22045
Commit migrated from https://github.com/dotnet/corefx/commit/472b8d8ec212c2afb107dea305b4624c4989a79f
With these changes, the UWP implementation of ClientWebSocket.ReceiveAsync hands partial WebSocket message data back to the app as soon as it arrives. This eliminates the behavioral difference between .NET Core and UWP tracked by issue dotnet/corefx#21102.
This fix leverages WinRT APIs that are only present since Windows 10 Insider Preview Build 16215, so API presence checks are in place. The pre-fix behavior takes effect when running on older Windows builds.
Fixesdotnet/corefx#21102
Commit migrated from https://github.com/dotnet/corefx/commit/09d029cbe1734ffb4f2ee5f259acfd69ea172158
With these changes, the UWP implementation of ClientWebSocket.ConnectAsync takes the ClientCertificates member of the app-provided ClientWebSocketOptions into account. The first client cert that can be successfully converted into a WinRT client cert (if any) is configured on the underlying WinRT MessageWebSocket instance, leading to the cert being used for mutual TLS authentication when establishing connections with WSS endpoints.
This fix leverages WinRT APIs that are only present since Windows 10 Insider Preview Build 16215, so API presence checks are in place.
Fixesdotnet/corefx#21393
Commit migrated from https://github.com/dotnet/corefx/commit/0c478304177f038af958959f1d106522b77bce26
The UWP implementation of ClientWebSocket uses WinRT MessageWebSocket APIs internally. If a connection-related or message-processing failure occurs, WinRT raises a MessageReceived event that throws an exception containing the failure's details when GetDataReader() is called. Unfortunately, ClientWebSocket isn't handling those exceptions inside its MessageReceived event handler, so they end up bringing down the entire process.
These changes add basic handling of GetDataReader() exceptions. They also contain a new functional test that pins the current behavior of all ClientWebSocket implementations around the "connection is prematurely closed" scenario. Without the proposed product code changes, this new test case reproduces the crash tracked by dotnet/corefx#17317.
Fixesdotnet/corefx#17317
Commit migrated from https://github.com/dotnet/corefx/commit/5573a9e3d4151642e8e2ff477eba2f2eda954fb4