Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Add more HttpListener WebSocket tests - #20398

Merged
stephentoub merged 3 commits into
dotnet:masterfrom
hughbe:managed-enable-more
May 29, 2017
Merged

stephentoub merged 3 commits into
dotnet:masterfrom
hughbe:managed-enable-more

Conversation

@hughbe

@hughbe hughbe commented May 27, 2017

Copy link
Copy Markdown

Contributes to #13618

Contributes to #20389
Contributes to #20391

@hughbe

hughbe commented May 27, 2017 •

Copy link
Copy Markdown
Author

}

[ActiveIssue(20246)] // CI hanging frequently
[ActiveIssue(20246, TestPlatforms.AnyUnix)] // CI hanging frequently

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand when you're choosing to use AnyUnix vs IsWindowsImplementation. I disabled this everywhere because it repros regardless of platform when using the managed implementation.

@stephentoub

Copy link
Copy Markdown
Member

It seems that the Upgrade header is uppercase in 8.1 and lowercase on all other platforms?

It shouldn't matter. The RFC describes it as being case insensitive.

HttpListenerWebSocketContext socketContext = await context.AcceptWebSocketAsync("SubProtocol");

Assert.Equal("SubProtocol", context.Response.Headers["Sec-WebSocket-Protocol"]);
Assert.Equal("Upgrade", context.Response.Headers["Connection"]);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these comparisons should be done case insensitive.


[ConditionalFact(nameof(IsNotWindows7OrUapCore))]
public async Task AcceptWebSocketAsync_SocketSpoofingAsWebSocket_ThrowsWebSocketException()
public async Task AcceptWebSocketAsync_ValidWebSocket_SetsUpHeadersInResponse()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you not seeing random failures in your new tests when running the managed implementation on Windows?


if (ClientConnectTask?.IsCompleted == true)
{
ClientConnectTask?.Dispose();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to dispose of the task. Please remove this and the corresponding changes in GetWebSocketContext.

Assert.Null(result.CloseStatus);
Assert.Null(result.CloseStatusDescription);

Assert.Equal(Text, Encoding.ASCII.GetString(receivedBytes));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's technically no guarantee that you'll receive the same number of bytes in a single receive; it's valid for the implementation to split it up amongst several packets such that you'll get the data across multiple receives. It's of course very likely this will pass, but it could be the source of sporadic failures in the future.

@stephentoub stephentoub left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding all of these, Hugh!

else
{
// AuthenticationSchemes.Digest, AuthenticationSchemes.Negotiate, AuthenticationSchemes.NTLM.
throw new NotImplementedException();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be PlatformNotSupportedException

hughbe and others added 2 commits May 28, 2017 10:21
- Cleanup some test code
- Add HttpListener web socket tests
- Fix some more Windows porting bugs
- Baseline managed test failures
- Change CopyPrincipal to throw PNSE instead of NotImplementedException
- Fix test attribution to allow "msbuild /t:rebuildandtest" to work with both Windows and managed implementations
- Fix IsWindowsImplementation to recognize both netcoreapp and netfx implementations
- Fix Assert.Equal calls that should be case-insensitive
- Move Get_Disposed_ThrowsObjectDisposedException to also apply to managed implementation
- Remove unnecessary Task disposal in HttpListenerWebSocketTests
- Add missing await of ClientConnectTask in several tests, where the lack of it resulted in sporadic failures due to race conditions
- Replace ReceiveAsync calls with custom ReceiveAllAsync calls where necessary
@stephentoub
stephentoub merged commit f81984b into dotnet:master May 29, 2017
@hughbe
hughbe deleted the managed-enable-more branch May 29, 2017 01:50
@hughbe

hughbe commented May 29, 2017

Copy link
Copy Markdown
Author

Sorry for the delay thanks for addressing the PR feedback!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants