y u no log?
This commit is contained in:
parent
0a5dd8f6d3
commit
64f52d1098
|
|
@ -5,14 +5,12 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Channels;
|
using System.Threading.Channels;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Connections;
|
using Microsoft.AspNetCore.Connections;
|
||||||
using Microsoft.AspNetCore.Http.Connections;
|
using Microsoft.AspNetCore.Http.Connections;
|
||||||
using Microsoft.AspNetCore.Http.Connections.Client;
|
using Microsoft.AspNetCore.Http.Connections.Client;
|
||||||
using Microsoft.AspNetCore.SignalR.Internal;
|
|
||||||
using Microsoft.AspNetCore.SignalR.Protocol;
|
using Microsoft.AspNetCore.SignalR.Protocol;
|
||||||
using Microsoft.AspNetCore.SignalR.Tests;
|
using Microsoft.AspNetCore.SignalR.Tests;
|
||||||
using Microsoft.AspNetCore.Testing.xunit;
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
|
|
@ -33,15 +31,8 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
[Collection(HubConnectionTestsCollection.Name)]
|
[Collection(HubConnectionTestsCollection.Name)]
|
||||||
public class HubConnectionTests : VerifiableServerLoggedTest
|
public class HubConnectionTests : VerifiableServerLoggedTest
|
||||||
{
|
{
|
||||||
private readonly ServerFixture<Startup> _serverFixture;
|
|
||||||
public HubConnectionTests(ServerFixture<Startup> serverFixture, ITestOutputHelper output) : base(serverFixture, output)
|
public HubConnectionTests(ServerFixture<Startup> serverFixture, ITestOutputHelper output) : base(serverFixture, output)
|
||||||
{
|
{
|
||||||
if (serverFixture == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(serverFixture));
|
|
||||||
}
|
|
||||||
|
|
||||||
_serverFixture = serverFixture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HubConnection CreateHubConnection(
|
private HubConnection CreateHubConnection(
|
||||||
|
|
@ -66,7 +57,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
return async format =>
|
return async format =>
|
||||||
{
|
{
|
||||||
var connection = new HttpConnection(new Uri(_serverFixture.Url + path), transportType, loggerFactory);
|
var connection = new HttpConnection(new Uri(ServerFixture.Url + path), transportType, loggerFactory);
|
||||||
await connection.StartAsync(format);
|
await connection.StartAsync(format);
|
||||||
return connection;
|
return connection;
|
||||||
};
|
};
|
||||||
|
|
@ -81,7 +72,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
var connectionBuilder = new HubConnectionBuilder()
|
var connectionBuilder = new HubConnectionBuilder()
|
||||||
.WithLoggerFactory(loggerFactory)
|
.WithLoggerFactory(loggerFactory)
|
||||||
.WithUrl(_serverFixture.Url + path, transportType);
|
.WithUrl(ServerFixture.Url + path, transportType);
|
||||||
connectionBuilder.Services.AddSingleton(protocol);
|
connectionBuilder.Services.AddSingleton(protocol);
|
||||||
|
|
||||||
var connection = connectionBuilder.Build();
|
var connection = connectionBuilder.Build();
|
||||||
|
|
@ -438,7 +429,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
bool ExpectedErrors(WriteContext writeContext)
|
bool ExpectedErrors(WriteContext writeContext)
|
||||||
{
|
{
|
||||||
return writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
return //writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
||||||
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -472,7 +463,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
bool ExpectedErrors(WriteContext writeContext)
|
bool ExpectedErrors(WriteContext writeContext)
|
||||||
{
|
{
|
||||||
return writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
return //writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
||||||
writeContext.EventId.Name == "UnknownHubMethod";
|
writeContext.EventId.Name == "UnknownHubMethod";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -505,7 +496,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
bool ExpectedErrors(WriteContext writeContext)
|
bool ExpectedErrors(WriteContext writeContext)
|
||||||
{
|
{
|
||||||
return writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
return //writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
||||||
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -538,7 +529,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
bool ExpectedErrors(WriteContext writeContext)
|
bool ExpectedErrors(WriteContext writeContext)
|
||||||
{
|
{
|
||||||
return writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
return //writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
||||||
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -571,7 +562,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
bool ExpectedErrors(WriteContext writeContext)
|
bool ExpectedErrors(WriteContext writeContext)
|
||||||
{
|
{
|
||||||
return writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
return //writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
||||||
writeContext.EventId.Name == "UnknownHubMethod";
|
writeContext.EventId.Name == "UnknownHubMethod";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -605,7 +596,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
bool ExpectedErrors(WriteContext writeContext)
|
bool ExpectedErrors(WriteContext writeContext)
|
||||||
{
|
{
|
||||||
return writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
return //writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
||||||
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -640,7 +631,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
bool ExpectedErrors(WriteContext writeContext)
|
bool ExpectedErrors(WriteContext writeContext)
|
||||||
{
|
{
|
||||||
return writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
return //writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
||||||
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
writeContext.EventId.Name == "FailedInvokingHubMethod";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -674,7 +665,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
bool ExpectedErrors(WriteContext writeContext)
|
bool ExpectedErrors(WriteContext writeContext)
|
||||||
{
|
{
|
||||||
return writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
return //writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
||||||
writeContext.EventId.Name == "NonStreamingMethodCalledWithStream";
|
writeContext.EventId.Name == "NonStreamingMethodCalledWithStream";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -707,7 +698,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
bool ExpectedErrors(WriteContext writeContext)
|
bool ExpectedErrors(WriteContext writeContext)
|
||||||
{
|
{
|
||||||
return writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
return //writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
||||||
writeContext.EventId.Name == "StreamingMethodCalledWithInvoke";
|
writeContext.EventId.Name == "StreamingMethodCalledWithInvoke";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -740,7 +731,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
bool ExpectedErrors(WriteContext writeContext)
|
bool ExpectedErrors(WriteContext writeContext)
|
||||||
{
|
{
|
||||||
return writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
return //writeContext.LoggerName == "Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher" &&
|
||||||
writeContext.EventId.Name == "InvalidReturnValueFromStreamingMethod";
|
writeContext.EventId.Name == "InvalidReturnValueFromStreamingMethod";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -775,14 +766,14 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
async Task<string> AccessTokenProvider()
|
async Task<string> AccessTokenProvider()
|
||||||
{
|
{
|
||||||
var httpResponse = await new HttpClient().GetAsync(_serverFixture.Url + "/generateJwtToken");
|
var httpResponse = await new HttpClient().GetAsync(ServerFixture.Url + "/generateJwtToken");
|
||||||
httpResponse.EnsureSuccessStatusCode();
|
httpResponse.EnsureSuccessStatusCode();
|
||||||
return await httpResponse.Content.ReadAsStringAsync();
|
return await httpResponse.Content.ReadAsStringAsync();
|
||||||
};
|
};
|
||||||
|
|
||||||
var hubConnection = new HubConnectionBuilder()
|
var hubConnection = new HubConnectionBuilder()
|
||||||
.WithLoggerFactory(loggerFactory)
|
.WithLoggerFactory(loggerFactory)
|
||||||
.WithUrl(_serverFixture.Url + "/authorizedhub", transportType, options =>
|
.WithUrl(ServerFixture.Url + "/authorizedhub", transportType, options =>
|
||||||
{
|
{
|
||||||
options.AccessTokenProvider = AccessTokenProvider;
|
options.AccessTokenProvider = AccessTokenProvider;
|
||||||
})
|
})
|
||||||
|
|
@ -813,7 +804,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
var hubConnection = new HubConnectionBuilder()
|
var hubConnection = new HubConnectionBuilder()
|
||||||
.WithLoggerFactory(loggerFactory)
|
.WithLoggerFactory(loggerFactory)
|
||||||
.WithUrl(_serverFixture.Url + "/default", transportType, options =>
|
.WithUrl(ServerFixture.Url + "/default", transportType, options =>
|
||||||
{
|
{
|
||||||
options.Headers["X-test"] = "42";
|
options.Headers["X-test"] = "42";
|
||||||
options.Headers["X-42"] = "test";
|
options.Headers["X-42"] = "test";
|
||||||
|
|
@ -845,11 +836,11 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
// System.Net has a HttpTransportType type which means we need to fully-qualify this rather than 'use' the namespace
|
// System.Net has a HttpTransportType type which means we need to fully-qualify this rather than 'use' the namespace
|
||||||
var cookieJar = new System.Net.CookieContainer();
|
var cookieJar = new System.Net.CookieContainer();
|
||||||
cookieJar.Add(new System.Net.Cookie("Foo", "Bar", "/", new Uri(_serverFixture.Url).Host));
|
cookieJar.Add(new System.Net.Cookie("Foo", "Bar", "/", new Uri(ServerFixture.Url).Host));
|
||||||
|
|
||||||
var hubConnection = new HubConnectionBuilder()
|
var hubConnection = new HubConnectionBuilder()
|
||||||
.WithLoggerFactory(loggerFactory)
|
.WithLoggerFactory(loggerFactory)
|
||||||
.WithUrl(_serverFixture.Url + "/default", HttpTransportType.WebSockets, options =>
|
.WithUrl(ServerFixture.Url + "/default", HttpTransportType.WebSockets, options =>
|
||||||
{
|
{
|
||||||
options.WebSocketConfiguration = o => o.Cookies = cookieJar;
|
options.WebSocketConfiguration = o => o.Cookies = cookieJar;
|
||||||
})
|
})
|
||||||
|
|
@ -880,7 +871,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
{
|
{
|
||||||
var hubConnection = new HubConnectionBuilder()
|
var hubConnection = new HubConnectionBuilder()
|
||||||
.WithLoggerFactory(loggerFactory)
|
.WithLoggerFactory(loggerFactory)
|
||||||
.WithUrl(_serverFixture.Url + "/default", transportType)
|
.WithUrl(ServerFixture.Url + "/default", transportType)
|
||||||
.Build();
|
.Build();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -917,7 +908,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
var hubConnectionBuilder = new HubConnectionBuilder()
|
var hubConnectionBuilder = new HubConnectionBuilder()
|
||||||
.WithLoggerFactory(loggerFactory)
|
.WithLoggerFactory(loggerFactory)
|
||||||
.AddMessagePackProtocol()
|
.AddMessagePackProtocol()
|
||||||
.WithUrl(_serverFixture.Url + "/default-nowebsockets");
|
.WithUrl(ServerFixture.Url + "/default-nowebsockets");
|
||||||
|
|
||||||
var hubConnection = hubConnectionBuilder.Build();
|
var hubConnection = hubConnectionBuilder.Build();
|
||||||
try
|
try
|
||||||
|
|
@ -947,7 +938,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
PollTrackingMessageHandler pollTracker = null;
|
PollTrackingMessageHandler pollTracker = null;
|
||||||
var hubConnection = new HubConnectionBuilder()
|
var hubConnection = new HubConnectionBuilder()
|
||||||
.WithLoggerFactory(loggerFactory)
|
.WithLoggerFactory(loggerFactory)
|
||||||
.WithUrl(_serverFixture.Url + "/default", options =>
|
.WithUrl(ServerFixture.Url + "/default", options =>
|
||||||
{
|
{
|
||||||
options.Transports = HttpTransportType.LongPolling;
|
options.Transports = HttpTransportType.LongPolling;
|
||||||
options.HttpMessageHandlerFactory = handler =>
|
options.HttpMessageHandlerFactory = handler =>
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,13 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
private readonly ILoggerFactory _loggerFactory;
|
private readonly ILoggerFactory _loggerFactory;
|
||||||
private readonly IDisposable _wrappedDisposable;
|
private readonly IDisposable _wrappedDisposable;
|
||||||
private readonly ConcurrentDictionary<string, ILogger> _loggers;
|
private readonly ConcurrentDictionary<string, ILogger> _loggers;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public ServerLogScope(ServerFixture serverFixture, ILoggerFactory loggerFactory, IDisposable wrappedDisposable)
|
public ServerLogScope(ServerFixture serverFixture, ILoggerFactory loggerFactory, IDisposable wrappedDisposable)
|
||||||
{
|
{
|
||||||
_serverFixture = serverFixture;
|
_serverFixture = serverFixture;
|
||||||
_loggerFactory = loggerFactory;
|
_loggerFactory = loggerFactory;
|
||||||
|
_logger = loggerFactory.CreateLogger(typeof(ServerLogScope));
|
||||||
_wrappedDisposable = wrappedDisposable;
|
_wrappedDisposable = wrappedDisposable;
|
||||||
_loggers = new ConcurrentDictionary<string, ILogger>(StringComparer.Ordinal);
|
_loggers = new ConcurrentDictionary<string, ILogger>(StringComparer.Ordinal);
|
||||||
|
|
||||||
|
|
@ -28,6 +30,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
{
|
{
|
||||||
var logger = _loggers.GetOrAdd(logRecord.Write.LoggerName, loggerName => _loggerFactory.CreateLogger(loggerName));
|
var logger = _loggers.GetOrAdd(logRecord.Write.LoggerName, loggerName => _loggerFactory.CreateLogger(loggerName));
|
||||||
logger.Log(logRecord.Write.LogLevel, logRecord.Write.EventId, logRecord.Write.State, logRecord.Write.Exception, logRecord.Write.Formatter);
|
logger.Log(logRecord.Write.LogLevel, logRecord.Write.EventId, logRecord.Write.State, logRecord.Write.Exception, logRecord.Write.Formatter);
|
||||||
|
_logger.Log(logRecord.Write.LogLevel, logRecord.Write.EventId, logRecord.Write.State, logRecord.Write.Exception, logRecord.Write.Formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
||||||
|
|
@ -36,26 +36,14 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
[Collection(EndToEndTestsCollection.Name)]
|
[Collection(EndToEndTestsCollection.Name)]
|
||||||
public class EndToEndTests : VerifiableServerLoggedTest
|
public class EndToEndTests : VerifiableServerLoggedTest
|
||||||
{
|
{
|
||||||
private readonly ServerFixture<Startup> _serverFixture;
|
|
||||||
|
|
||||||
public EndToEndTests(ServerFixture<Startup> serverFixture, ITestOutputHelper output) : base(serverFixture, output)
|
public EndToEndTests(ServerFixture<Startup> serverFixture, ITestOutputHelper output) : base(serverFixture, output)
|
||||||
{
|
{
|
||||||
if (serverFixture == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(serverFixture));
|
|
||||||
}
|
|
||||||
if (output == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(output));
|
|
||||||
}
|
|
||||||
|
|
||||||
_serverFixture = serverFixture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task CanStartAndStopConnectionUsingDefaultTransport()
|
public async Task CanStartAndStopConnectionUsingDefaultTransport()
|
||||||
{
|
{
|
||||||
var url = _serverFixture.Url + "/echo";
|
var url = ServerFixture.Url + "/echo";
|
||||||
// The test should connect to the server using WebSockets transport on Windows 8 and newer.
|
// The test should connect to the server using WebSockets transport on Windows 8 and newer.
|
||||||
// On Windows 7/2008R2 it should use ServerSentEvents transport to connect to the server.
|
// On Windows 7/2008R2 it should use ServerSentEvents transport to connect to the server.
|
||||||
var connection = new HttpConnection(new Uri(url));
|
var connection = new HttpConnection(new Uri(url));
|
||||||
|
|
@ -66,7 +54,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task TransportThatFallsbackCreatesNewConnection()
|
public async Task TransportThatFallsbackCreatesNewConnection()
|
||||||
{
|
{
|
||||||
var url = _serverFixture.Url + "/echo";
|
var url = ServerFixture.Url + "/echo";
|
||||||
// The test should connect to the server using WebSockets transport on Windows 8 and newer.
|
// The test should connect to the server using WebSockets transport on Windows 8 and newer.
|
||||||
// On Windows 7/2008R2 it should use ServerSentEvents transport to connect to the server.
|
// On Windows 7/2008R2 it should use ServerSentEvents transport to connect to the server.
|
||||||
|
|
||||||
|
|
@ -82,7 +70,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
{
|
{
|
||||||
using (StartVerifableLog(out var loggerFactory, testName: $"CanStartAndStopConnectionUsingGivenTransport_{transportType}", minLogLevel: LogLevel.Trace))
|
using (StartVerifableLog(out var loggerFactory, testName: $"CanStartAndStopConnectionUsingGivenTransport_{transportType}", minLogLevel: LogLevel.Trace))
|
||||||
{
|
{
|
||||||
var url = _serverFixture.Url + "/echo";
|
var url = ServerFixture.Url + "/echo";
|
||||||
var connection = new HttpConnection(new Uri(url), transportType, loggerFactory);
|
var connection = new HttpConnection(new Uri(url), transportType, loggerFactory);
|
||||||
await connection.StartAsync(TransferFormat.Text).OrTimeout();
|
await connection.StartAsync(TransferFormat.Text).OrTimeout();
|
||||||
await connection.DisposeAsync().OrTimeout();
|
await connection.DisposeAsync().OrTimeout();
|
||||||
|
|
@ -100,7 +88,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
const string message = "Hello, World!";
|
const string message = "Hello, World!";
|
||||||
using (var ws = new ClientWebSocket())
|
using (var ws = new ClientWebSocket())
|
||||||
{
|
{
|
||||||
var socketUrl = _serverFixture.WebSocketsUrl + "/echo";
|
var socketUrl = ServerFixture.WebSocketsUrl + "/echo";
|
||||||
|
|
||||||
logger.LogInformation("Connecting WebSocket to {socketUrl}", socketUrl);
|
logger.LogInformation("Connecting WebSocket to {socketUrl}", socketUrl);
|
||||||
await ws.ConnectAsync(new Uri(socketUrl), CancellationToken.None).OrTimeout();
|
await ws.ConnectAsync(new Uri(socketUrl), CancellationToken.None).OrTimeout();
|
||||||
|
|
@ -137,7 +125,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
const string message = "Hello, World!";
|
const string message = "Hello, World!";
|
||||||
using (var ws = new ClientWebSocket())
|
using (var ws = new ClientWebSocket())
|
||||||
{
|
{
|
||||||
var socketUrl = _serverFixture.WebSocketsUrl + "/echo";
|
var socketUrl = ServerFixture.WebSocketsUrl + "/echo";
|
||||||
|
|
||||||
logger.LogInformation("Connecting WebSocket to {socketUrl}", socketUrl);
|
logger.LogInformation("Connecting WebSocket to {socketUrl}", socketUrl);
|
||||||
await ws.ConnectAsync(new Uri(socketUrl), CancellationToken.None).OrTimeout();
|
await ws.ConnectAsync(new Uri(socketUrl), CancellationToken.None).OrTimeout();
|
||||||
|
|
@ -171,7 +159,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
using (StartVerifableLog(out var loggerFactory))
|
using (StartVerifableLog(out var loggerFactory))
|
||||||
{
|
{
|
||||||
var logger = loggerFactory.CreateLogger<EndToEndTests>();
|
var logger = loggerFactory.CreateLogger<EndToEndTests>();
|
||||||
var url = _serverFixture.Url + "/echo";
|
var url = ServerFixture.Url + "/echo";
|
||||||
|
|
||||||
var mockHttpHandler = new Mock<HttpMessageHandler>();
|
var mockHttpHandler = new Mock<HttpMessageHandler>();
|
||||||
mockHttpHandler.Protected()
|
mockHttpHandler.Protected()
|
||||||
|
|
@ -222,7 +210,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
|
|
||||||
const string message = "Major Key";
|
const string message = "Major Key";
|
||||||
|
|
||||||
var url = _serverFixture.Url + "/echo";
|
var url = ServerFixture.Url + "/echo";
|
||||||
var connection = new HttpConnection(new Uri(url), transportType, loggerFactory);
|
var connection = new HttpConnection(new Uri(url), transportType, loggerFactory);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -284,7 +272,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
{
|
{
|
||||||
var logger = loggerFactory.CreateLogger<EndToEndTests>();
|
var logger = loggerFactory.CreateLogger<EndToEndTests>();
|
||||||
|
|
||||||
var url = _serverFixture.Url + "/echo";
|
var url = ServerFixture.Url + "/echo";
|
||||||
var connection = new HttpConnection(new Uri(url), HttpTransportType.WebSockets, loggerFactory);
|
var connection = new HttpConnection(new Uri(url), HttpTransportType.WebSockets, loggerFactory);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -332,7 +320,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
{
|
{
|
||||||
var logger = loggerFactory.CreateLogger<EndToEndTests>();
|
var logger = loggerFactory.CreateLogger<EndToEndTests>();
|
||||||
|
|
||||||
var url = _serverFixture.Url + "/auth";
|
var url = ServerFixture.Url + "/auth";
|
||||||
var connection = new HttpConnection(new Uri(url), HttpTransportType.WebSockets, loggerFactory);
|
var connection = new HttpConnection(new Uri(url), HttpTransportType.WebSockets, loggerFactory);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -371,7 +359,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
{
|
{
|
||||||
var logger = loggerFactory.CreateLogger<EndToEndTests>();
|
var logger = loggerFactory.CreateLogger<EndToEndTests>();
|
||||||
|
|
||||||
var url = _serverFixture.Url + "/auth";
|
var url = ServerFixture.Url + "/auth";
|
||||||
var connection = new HttpConnection(new Uri(url), transportType, loggerFactory);
|
var connection = new HttpConnection(new Uri(url), transportType, loggerFactory);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -428,7 +416,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
{
|
{
|
||||||
var logger = loggerFactory.CreateLogger<EndToEndTests>();
|
var logger = loggerFactory.CreateLogger<EndToEndTests>();
|
||||||
|
|
||||||
var url = _serverFixture.Url + "/uncreatable";
|
var url = ServerFixture.Url + "/uncreatable";
|
||||||
var connection = new HubConnectionBuilder()
|
var connection = new HubConnectionBuilder()
|
||||||
.WithLoggerFactory(loggerFactory)
|
.WithLoggerFactory(loggerFactory)
|
||||||
.WithUrl(url, transportType)
|
.WithUrl(url, transportType)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.IO.Pipelines;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.WebSockets;
|
using System.Net.WebSockets;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
@ -14,7 +13,6 @@ using Microsoft.AspNetCore.Connections;
|
||||||
using Microsoft.AspNetCore.Http.Connections.Client;
|
using Microsoft.AspNetCore.Http.Connections.Client;
|
||||||
using Microsoft.AspNetCore.Http.Connections.Client.Internal;
|
using Microsoft.AspNetCore.Http.Connections.Client.Internal;
|
||||||
using Microsoft.AspNetCore.Testing.xunit;
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
using Microsoft.Extensions.Logging.Testing;
|
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
|
|
@ -24,16 +22,8 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
[Collection(EndToEndTestsCollection.Name)]
|
[Collection(EndToEndTestsCollection.Name)]
|
||||||
public class WebSocketsTransportTests : VerifiableServerLoggedTest
|
public class WebSocketsTransportTests : VerifiableServerLoggedTest
|
||||||
{
|
{
|
||||||
private readonly ServerFixture<Startup> _serverFixture;
|
|
||||||
|
|
||||||
public WebSocketsTransportTests(ServerFixture<Startup> serverFixture, ITestOutputHelper output) : base(serverFixture, output)
|
public WebSocketsTransportTests(ServerFixture<Startup> serverFixture, ITestOutputHelper output) : base(serverFixture, output)
|
||||||
{
|
{
|
||||||
if (serverFixture == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(serverFixture));
|
|
||||||
}
|
|
||||||
|
|
||||||
_serverFixture = serverFixture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConditionalFact]
|
[ConditionalFact]
|
||||||
|
|
@ -70,7 +60,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
using (StartVerifableLog(out var loggerFactory))
|
using (StartVerifableLog(out var loggerFactory))
|
||||||
{
|
{
|
||||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory);
|
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory);
|
||||||
await webSocketsTransport.StartAsync(new Uri(_serverFixture.WebSocketsUrl + "/echo"),
|
await webSocketsTransport.StartAsync(new Uri(ServerFixture.WebSocketsUrl + "/echo"),
|
||||||
TransferFormat.Binary).OrTimeout();
|
TransferFormat.Binary).OrTimeout();
|
||||||
await webSocketsTransport.StopAsync().OrTimeout();
|
await webSocketsTransport.StopAsync().OrTimeout();
|
||||||
await webSocketsTransport.Running.OrTimeout();
|
await webSocketsTransport.Running.OrTimeout();
|
||||||
|
|
@ -84,7 +74,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
using (StartVerifableLog(out var loggerFactory))
|
using (StartVerifableLog(out var loggerFactory))
|
||||||
{
|
{
|
||||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory);
|
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory);
|
||||||
await webSocketsTransport.StartAsync(new Uri(_serverFixture.WebSocketsUrl + "/httpheader"),
|
await webSocketsTransport.StartAsync(new Uri(ServerFixture.WebSocketsUrl + "/httpheader"),
|
||||||
TransferFormat.Binary).OrTimeout();
|
TransferFormat.Binary).OrTimeout();
|
||||||
|
|
||||||
await webSocketsTransport.Output.WriteAsync(Encoding.UTF8.GetBytes("User-Agent"));
|
await webSocketsTransport.Output.WriteAsync(Encoding.UTF8.GetBytes("User-Agent"));
|
||||||
|
|
@ -112,7 +102,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
using (StartVerifableLog(out var loggerFactory))
|
using (StartVerifableLog(out var loggerFactory))
|
||||||
{
|
{
|
||||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory);
|
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory);
|
||||||
await webSocketsTransport.StartAsync(new Uri(_serverFixture.WebSocketsUrl + "/httpheader"),
|
await webSocketsTransport.StartAsync(new Uri(ServerFixture.WebSocketsUrl + "/httpheader"),
|
||||||
TransferFormat.Binary).OrTimeout();
|
TransferFormat.Binary).OrTimeout();
|
||||||
|
|
||||||
await webSocketsTransport.Output.WriteAsync(Encoding.UTF8.GetBytes("X-Requested-With"));
|
await webSocketsTransport.Output.WriteAsync(Encoding.UTF8.GetBytes("X-Requested-With"));
|
||||||
|
|
@ -135,7 +125,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
using (StartVerifableLog(out var loggerFactory))
|
using (StartVerifableLog(out var loggerFactory))
|
||||||
{
|
{
|
||||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory);
|
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory);
|
||||||
await webSocketsTransport.StartAsync(new Uri(_serverFixture.WebSocketsUrl + "/echo"),
|
await webSocketsTransport.StartAsync(new Uri(ServerFixture.WebSocketsUrl + "/echo"),
|
||||||
TransferFormat.Binary);
|
TransferFormat.Binary);
|
||||||
webSocketsTransport.Output.Complete();
|
webSocketsTransport.Output.Complete();
|
||||||
await webSocketsTransport.Running.OrTimeout(TimeSpan.FromSeconds(10));
|
await webSocketsTransport.Running.OrTimeout(TimeSpan.FromSeconds(10));
|
||||||
|
|
@ -151,7 +141,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
using (StartVerifableLog(out var loggerFactory))
|
using (StartVerifableLog(out var loggerFactory))
|
||||||
{
|
{
|
||||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory);
|
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory);
|
||||||
await webSocketsTransport.StartAsync(new Uri(_serverFixture.WebSocketsUrl + "/echoAndClose"), transferFormat);
|
await webSocketsTransport.StartAsync(new Uri(ServerFixture.WebSocketsUrl + "/echoAndClose"), transferFormat);
|
||||||
|
|
||||||
await webSocketsTransport.Output.WriteAsync(new byte[] { 0x42 });
|
await webSocketsTransport.Output.WriteAsync(new byte[] { 0x42 });
|
||||||
|
|
||||||
|
|
@ -174,7 +164,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
||||||
{
|
{
|
||||||
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory);
|
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory);
|
||||||
|
|
||||||
await webSocketsTransport.StartAsync(new Uri(_serverFixture.WebSocketsUrl + "/echo"),
|
await webSocketsTransport.StartAsync(new Uri(ServerFixture.WebSocketsUrl + "/echo"),
|
||||||
transferFormat).OrTimeout();
|
transferFormat).OrTimeout();
|
||||||
|
|
||||||
await webSocketsTransport.StopAsync().OrTimeout();
|
await webSocketsTransport.StopAsync().OrTimeout();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue