Add partial handshake test (#2630)

This commit is contained in:
BrennanConroy 2018-07-18 14:32:58 -07:00 committed by GitHub
parent e9151906e1
commit 056da5114a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 0 deletions

View File

@ -374,6 +374,32 @@ namespace Microsoft.AspNetCore.SignalR.Tests
}
}
[Fact]
public async Task ConnectionClosesOnServerWithPartialHandshakeMessageAndCompletedPipe()
{
var connectionHandler = HubConnectionHandlerTestUtils.GetHubConnectionHandler(typeof(HubT));
using (var client = new TestClient())
{
// partial handshake
var payload = Encoding.UTF8.GetBytes("{\"protocol\": \"json\",\"ver");
await client.Connection.Application.Output.WriteAsync(payload).OrTimeout();
var connectionHandlerTask = await client.ConnectAsync(connectionHandler, sendHandshakeRequestMessage: false, expectedHandshakeResponseMessage: false);
// Complete the pipe to 'close' the connection
client.Connection.Application.Output.Complete();
// This will never complete as the pipe was completed and nothing can be written to it
var handshakeReadTask = client.ReadAsync(true);
// Check that the connection was closed on the server
await connectionHandlerTask.OrTimeout();
Assert.False(handshakeReadTask.IsCompleted);
client.Dispose();
}
}
[Fact]
public async Task LifetimeManagerOnDisconnectedAsyncCalledIfLifetimeManagerOnConnectedAsyncThrows()
{