diff --git a/docs/workflow/testing/libraries/testing-wasm.md b/docs/workflow/testing/libraries/testing-wasm.md index a8d7eb1a7934d..da752eb2d5974 100644 --- a/docs/workflow/testing/libraries/testing-wasm.md +++ b/docs/workflow/testing/libraries/testing-wasm.md @@ -100,11 +100,11 @@ The following shows how to run tests for a specific library - `$(WasmXHarnessArgs)` - xharness command arguments - Example: `WasmXHarnessArgs="--xyz"` -> becomes `dotnet xharness wasm test --xyz` + Example: `WasmXHarnessArgs="--set-web-server-http-env=DOTNET_TEST_WEBSOCKETHOST"` -> becomes `dotnet xharness wasm test --set-web-server-http-env=DOTNET_TEST_WEBSOCKETHOST` -- `$(WasmXHarnessMonoArgs)` - arguments to mono +- `$(WasmXHarnessMonoArgs)` - arguments and variables for mono - Example: `WasmXHarnessMonoArgs="--runtime-arg=--trace=E"` + Example: `WasmXHarnessMonoArgs="--runtime-arg=--trace=E --setenv=MONO_LOG_LEVEL=debug"` - `$(WasmTestAppArgs)` - arguments for the test app itself diff --git a/src/libraries/Common/tests/System/Net/Configuration.Http.cs b/src/libraries/Common/tests/System/Net/Configuration.Http.cs index 69e1094128771..3e4684b9add18 100644 --- a/src/libraries/Common/tests/System/Net/Configuration.Http.cs +++ b/src/libraries/Common/tests/System/Net/Configuration.Http.cs @@ -17,6 +17,7 @@ public static partial class Http public static string SecureHost => GetValue("DOTNET_TEST_SECUREHTTPHOST", DefaultAzureServer); public static string Http2Host => GetValue("DOTNET_TEST_HTTP2HOST", DefaultHttp2AzureServer); + public static string Http2SecureHost => GetValue("DOTNET_TEST_HTTP2SECUREHOST", DefaultHttp2AzureServer); // This server doesn't use HTTP/2 server push (push promise) feature. Some HttpClient implementations // don't support servers that use push right now. @@ -53,32 +54,34 @@ public static partial class Http public static readonly Uri RemoteEchoServer = new Uri("http://" + Host + "/" + EchoHandler); public static readonly Uri SecureRemoteEchoServer = new Uri("https://" + SecureHost + "/" + EchoHandler); - public static readonly Uri Http2RemoteEchoServer = new Uri("https://" + Http2Host + "/" + EchoHandler); - public static readonly Uri[] EchoServerList = new Uri[] { RemoteEchoServer, SecureRemoteEchoServer, Http2RemoteEchoServer }; + public static readonly Uri Http2RemoteEchoServer = new Uri("http://" + Http2Host + "/" + EchoHandler); + public static readonly Uri Http2SecureRemoteEchoServer = new Uri("https://" + Http2SecureHost + "/" + EchoHandler); + public static readonly Uri[] EchoServerList = new Uri[] { RemoteEchoServer, SecureRemoteEchoServer, Http2RemoteEchoServer, Http2SecureRemoteEchoServer }; public static readonly Uri RemoteVerifyUploadServer = new Uri("http://" + Host + "/" + VerifyUploadHandler); public static readonly Uri SecureRemoteVerifyUploadServer = new Uri("https://" + SecureHost + "/" + VerifyUploadHandler); - public static readonly Uri Http2RemoteVerifyUploadServer = new Uri("https://" + Http2Host + "/" + VerifyUploadHandler); + public static readonly Uri Http2RemoteVerifyUploadServer = new Uri("https://" + Http2SecureHost + "/" + VerifyUploadHandler); public static readonly Uri[] VerifyUploadServerList = new Uri[] { RemoteVerifyUploadServer, SecureRemoteVerifyUploadServer, Http2RemoteVerifyUploadServer }; public static readonly Uri RemoteEmptyContentServer = new Uri("http://" + Host + "/" + EmptyContentHandler); public static readonly Uri RemoteDeflateServer = new Uri("http://" + Host + "/" + DeflateHandler); public static readonly Uri RemoteGZipServer = new Uri("http://" + Host + "/" + GZipHandler); - public static readonly Uri Http2RemoteDeflateServer = new Uri("https://" + Http2Host + "/" + DeflateHandler); - public static readonly Uri Http2RemoteGZipServer = new Uri("https://" + Http2Host + "/" + GZipHandler); + public static readonly Uri Http2RemoteDeflateServer = new Uri("https://" + Http2SecureHost + "/" + DeflateHandler); + public static readonly Uri Http2RemoteGZipServer = new Uri("https://" + Http2SecureHost + "/" + GZipHandler); public static readonly object[][] EchoServers = EchoServerList.Select(x => new object[] { x }).ToArray(); public static readonly object[][] VerifyUploadServers = { new object[] { RemoteVerifyUploadServer }, new object[] { SecureRemoteVerifyUploadServer }, new object[] { Http2RemoteVerifyUploadServer } }; public static readonly object[][] CompressedServers = { new object[] { RemoteDeflateServer }, new object[] { RemoteGZipServer }, new object[] { Http2RemoteDeflateServer }, new object[] { Http2RemoteGZipServer } }; - public static readonly object[][] Http2Servers = { new object[] { new Uri("https://" + Http2Host) } }; + public static readonly object[][] Http2Servers = { new object[] { new Uri("https://" + Http2SecureHost) } }; public static readonly object[][] Http2NoPushServers = { new object[] { new Uri("https://" + Http2NoPushHost) } }; public static readonly RemoteServer RemoteHttp11Server = new RemoteServer(new Uri("http://" + Host + "/"), HttpVersion.Version11); public static readonly RemoteServer RemoteSecureHttp11Server = new RemoteServer(new Uri("https://" + SecureHost + "/"), HttpVersion.Version11); - public static readonly RemoteServer RemoteHttp2Server = new RemoteServer(new Uri("https://" + Http2Host + "/"), new Version(2, 0)); + public static readonly RemoteServer RemoteSecureHttp2Server = new RemoteServer(new Uri("https://" + Http2SecureHost + "/"), new Version(2, 0)); + public static readonly RemoteServer RemoteHttp2Server = new RemoteServer(new Uri("http://" + Http2Host + "/"), new Version(2, 0)); - public static readonly IEnumerable RemoteServers = new RemoteServer[] { RemoteHttp11Server, RemoteSecureHttp11Server, RemoteHttp2Server }; + public static readonly IEnumerable RemoteServers = new RemoteServer[] { RemoteHttp11Server, RemoteSecureHttp11Server, RemoteSecureHttp2Server }; public static readonly IEnumerable RemoteServersMemberData = RemoteServers.Select(s => new object[] { s }); diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs index fcf578b63cd63..e7f8091607345 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs @@ -77,9 +77,9 @@ public async Task UseDefaultCredentials_SetToFalseAndServerNeedsAuth_StatusCodeU } } - [OuterLoop("Uses external servers")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task SendAsync_SimpleGet_Success(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -95,9 +95,8 @@ public async Task SendAsync_SimpleGet_Success(Configuration.Http.RemoteServer re } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task SendAsync_MultipleRequestsReusingSameClient_Success(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -112,9 +111,9 @@ public async Task SendAsync_MultipleRequestsReusingSameClient_Success(Configurat } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task GetAsync_ResponseContentAfterClientAndHandlerDispose_Success(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -162,9 +161,8 @@ public async Task GetAsync_ServerNeedsAuthAndSetCredential_StatusCodeOK(Configur } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task GetAsync_ServerNeedsAuthAndNoCredential_StatusCodeUnauthorized(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -177,10 +175,10 @@ public async Task GetAsync_ServerNeedsAuthAndNoCredential_StatusCodeUnauthorized } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory] [MemberData(nameof(RemoteServersAndHeaderEchoUrisMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/53872", TestPlatforms.Browser)] public async Task GetAsync_RequestHeadersAddCustomHeaders_HeaderAndEmptyValueSent(Configuration.Http.RemoteServer remoteServer, Uri uri) { if (IsWinHttpHandler && !PlatformDetection.IsWindows10Version1709OrGreater) @@ -204,9 +202,8 @@ public async Task GetAsync_RequestHeadersAddCustomHeaders_HeaderAndEmptyValueSen } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersHeaderValuesAndUris))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task GetAsync_RequestHeadersAddCustomHeaders_HeaderAndValueSent(Configuration.Http.RemoteServer remoteServer, string name, string value, Uri uri) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -223,9 +220,8 @@ public async Task GetAsync_RequestHeadersAddCustomHeaders_HeaderAndValueSent(Con } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersAndHeaderEchoUrisMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task GetAsync_LargeRequestHeader_HeadersAndValuesSent(Configuration.Http.RemoteServer remoteServer, Uri uri) { // Unfortunately, our remote servers seem to have pretty strict limits (around 16K?) @@ -291,9 +287,9 @@ public static IEnumerable RemoteServersHeaderValuesAndUris() public static IEnumerable RemoteServersAndHeaderEchoUrisMemberData() => RemoteServersAndHeaderEchoUris().Select(x => new object[] { x.remoteServer, x.uri }); - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task GetAsync_ResponseHeadersRead_ReadFromEachIterativelyDoesntDeadlock(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -317,9 +313,9 @@ public async Task GetAsync_ResponseHeadersRead_ReadFromEachIterativelyDoesntDead } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task SendAsync_HttpRequestMsgResponseHeadersRead_StatusCodeOK(Configuration.Http.RemoteServer remoteServer) { // Sync API supported only up to HTTP/1.1 @@ -344,7 +340,7 @@ public async Task SendAsync_HttpRequestMsgResponseHeadersRead_StatusCodeOK(Confi } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_CallMethodTwice_StringContent(Configuration.Http.RemoteServer remoteServer) @@ -370,7 +366,7 @@ public async Task PostAsync_CallMethodTwice_StringContent(Configuration.Http.Rem } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_CallMethod_UnicodeStringContent(Configuration.Http.RemoteServer remoteServer) @@ -388,7 +384,7 @@ public async Task PostAsync_CallMethod_UnicodeStringContent(Configuration.Http.R } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(VerifyUploadServersStreamsAndExpectedData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_CallMethod_StreamContent(Configuration.Http.RemoteServer remoteServer, HttpContent content, byte[] expectedData) @@ -528,9 +524,9 @@ public static IEnumerable VerifyUploadServersStreamsAndExpectedData } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_CallMethod_NullContent(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -550,9 +546,9 @@ public async Task PostAsync_CallMethod_NullContent(Configuration.Http.RemoteServ } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_CallMethod_EmptyContent(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -581,7 +577,7 @@ public static IEnumerable ExpectContinueVersion() select new object[] {expect, version}; } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory] [MemberData(nameof(ExpectContinueVersion))] [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] @@ -622,9 +618,8 @@ public async Task PostAsync_ExpectContinue_Success(bool? expectContinue, Version } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task PostAsync_Redirect_ResultingGetFormattedCorrectly(Configuration.Http.RemoteServer remoteServer) { const string ContentString = "This is the content string."; @@ -644,7 +639,7 @@ public async Task PostAsync_Redirect_ResultingGetFormattedCorrectly(Configuratio } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_RedirectWith307_LargePayload(Configuration.Http.RemoteServer remoteServer) @@ -660,7 +655,7 @@ public async Task PostAsync_RedirectWith307_LargePayload(Configuration.Http.Remo await PostAsync_Redirect_LargePayload_Helper(remoteServer, 307, true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_RedirectWith302_LargePayload(Configuration.Http.RemoteServer remoteServer) @@ -716,9 +711,9 @@ private async Task PostAsync_Redirect_LargePayload_Helper(Configuration.Http.Rem } #if !NETFRAMEWORK - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_ReuseRequestContent_Success(Configuration.Http.RemoteServer remoteServer) { const string ContentString = "This is the content string."; @@ -737,14 +732,17 @@ public async Task PostAsync_ReuseRequestContent_Success(Configuration.Http.Remot } #endif - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(HttpMethods))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53592", TestPlatforms.Browser)] public async Task SendAsync_SendRequestUsingMethodToEchoServerWithNoContent_MethodCorrectlySent( string method, Uri serverUri) { + if (method == "TRACE" && PlatformDetection.IsBrowser) + { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/53592", TestPlatforms.Browser)] + return; + } using (HttpClient client = CreateHttpClient()) { var request = new HttpRequestMessage( @@ -759,9 +757,10 @@ public async Task SendAsync_SendRequestUsingMethodToEchoServerWithNoContent_Meth } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(HttpMethodsThatAllowContent))] [ActiveIssue("https://github.com/dotnet/runtime/issues/53591", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task SendAsync_SendRequestUsingMethodToEchoServerWithContent_Success( string method, Uri serverUri) @@ -789,14 +788,23 @@ public async Task SendAsync_SendRequestUsingMethodToEchoServerWithContent_Succes } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(HttpMethodsThatDontAllowContent))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53591", TestPlatforms.Browser)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53592", TestPlatforms.Browser)] public async Task SendAsync_SendRequestUsingNoBodyMethodToEchoServerWithContent_NoBodySent( string method, Uri serverUri) { + if (method == "TRACE" && PlatformDetection.IsBrowser) + { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/53592", TestPlatforms.Browser)] + return; + } + if (method == "HEAD" && PlatformDetection.IsBrowser) + { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/53591", TestPlatforms.Browser)] + return; + } + using (HttpClient client = CreateHttpClient()) { var request = new HttpRequestMessage( @@ -836,9 +844,8 @@ public static IEnumerable SendAsync_SendSameRequestMultipleTimesDirect } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(SendAsync_SendSameRequestMultipleTimesDirectlyOnHandler_Success_MemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task SendAsync_SendSameRequestMultipleTimesDirectlyOnHandler_Success(Configuration.Http.RemoteServer remoteServer, string stringContent, int startingPosition) { using (var handler = new HttpMessageInvoker(CreateHttpClientHandler())) @@ -869,10 +876,9 @@ public async Task SendAsync_SendSameRequestMultipleTimesDirectlyOnHandler_Succes } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory] [MemberData(nameof(Http2Servers))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task SendAsync_RequestVersion20_ResponseVersion20IfHttp2Supported(Uri server) { // Sync API supported only up to HTTP/1.1 diff --git a/src/libraries/Common/tests/System/Net/Http/PostScenarioTest.cs b/src/libraries/Common/tests/System/Net/Http/PostScenarioTest.cs index 0d75e65aea91a..faf410134250a 100644 --- a/src/libraries/Common/tests/System/Net/Http/PostScenarioTest.cs +++ b/src/libraries/Common/tests/System/Net/Http/PostScenarioTest.cs @@ -28,9 +28,9 @@ public abstract class PostScenarioTest : HttpClientHandlerTestBase public PostScenarioTest(ITestOutputHelper output) : base(output) { } #if !NETFRAMEWORK - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostRewindableStreamContentMultipleTimes_StreamContentFullySent(Configuration.Http.RemoteServer remoteServer) { const string requestBody = "ABC"; @@ -53,17 +53,17 @@ public async Task PostRewindableStreamContentMultipleTimes_StreamContentFullySen } #endif - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [MemberData(nameof(RemoteServersMemberData))] [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNotBrowser))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostNoContentUsingContentLengthSemantics_Success(Configuration.Http.RemoteServer remoteServer) { await PostHelper(remoteServer, string.Empty, null, useContentLengthUpload: true, useChunkedEncodingUpload: false); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostEmptyContentUsingContentLengthSemantics_Success(Configuration.Http.RemoteServer remoteServer) @@ -72,7 +72,7 @@ public async Task PostEmptyContentUsingContentLengthSemantics_Success(Configurat useContentLengthUpload: true, useChunkedEncodingUpload: false); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostEmptyContentUsingChunkedEncoding_Success(Configuration.Http.RemoteServer remoteServer) @@ -81,7 +81,7 @@ public async Task PostEmptyContentUsingChunkedEncoding_Success(Configuration.Htt useContentLengthUpload: false, useChunkedEncodingUpload: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostEmptyContentUsingConflictingSemantics_Success(Configuration.Http.RemoteServer remoteServer) @@ -90,7 +90,7 @@ public async Task PostEmptyContentUsingConflictingSemantics_Success(Configuratio useContentLengthUpload: true, useChunkedEncodingUpload: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostUsingContentLengthSemantics_Success(Configuration.Http.RemoteServer remoteServer) @@ -99,7 +99,7 @@ public async Task PostUsingContentLengthSemantics_Success(Configuration.Http.Rem useContentLengthUpload: true, useChunkedEncodingUpload: false); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostUsingChunkedEncoding_Success(Configuration.Http.RemoteServer remoteServer) @@ -108,7 +108,7 @@ public async Task PostUsingChunkedEncoding_Success(Configuration.Http.RemoteServ useContentLengthUpload: false, useChunkedEncodingUpload: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostSyncBlockingContentUsingChunkedEncoding_Success(Configuration.Http.RemoteServer remoteServer) @@ -117,7 +117,7 @@ public async Task PostSyncBlockingContentUsingChunkedEncoding_Success(Configurat useContentLengthUpload: false, useChunkedEncodingUpload: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostRepeatedFlushContentUsingChunkedEncoding_Success(Configuration.Http.RemoteServer remoteServer) @@ -126,7 +126,7 @@ public async Task PostRepeatedFlushContentUsingChunkedEncoding_Success(Configura useContentLengthUpload: false, useChunkedEncodingUpload: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostUsingUsingConflictingSemantics_UsesChunkedSemantics(Configuration.Http.RemoteServer remoteServer) @@ -135,7 +135,7 @@ public async Task PostUsingUsingConflictingSemantics_UsesChunkedSemantics(Config useContentLengthUpload: true, useChunkedEncodingUpload: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostUsingNoSpecifiedSemantics_UsesChunkedSemantics(Configuration.Http.RemoteServer remoteServer) @@ -154,7 +154,7 @@ public static IEnumerable RemoteServersAndLargeContentSizes() } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory] [MemberData(nameof(RemoteServersAndLargeContentSizes))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] @@ -223,10 +223,10 @@ public async Task PostNonRewindableContentUsingAuth_PreAuthenticate_Success(Conf await PostUsingAuthHelper(remoteServer, ExpectedContent, content, credential, preAuthenticate: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [MemberData(nameof(RemoteServersMemberData))] [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNotBrowser))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_EmptyContent_ContentTypeHeaderNotSent(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) diff --git a/src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs b/src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs index 3b01e68198c64..3d9d39a08f803 100644 --- a/src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs +++ b/src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs @@ -30,9 +30,9 @@ public static IEnumerable RemoteServersAndReadModes() } } - [OuterLoop("Uses external servers")] + + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersAndReadModes))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task GetStreamAsync_ReadToEnd_Success(Configuration.Http.RemoteServer remoteServer, int readMode) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -126,9 +126,9 @@ public async Task GetStreamAsync_ReadToEnd_Success(Configuration.Http.RemoteServ } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task GetAsync_UseResponseHeadersReadAndCallLoadIntoBuffer_Success(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -146,9 +146,9 @@ public async Task GetAsync_UseResponseHeadersReadAndCallLoadIntoBuffer_Success(C } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task GetAsync_UseResponseHeadersReadAndCopyToMemoryStream_Success(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -171,9 +171,8 @@ public async Task GetAsync_UseResponseHeadersReadAndCopyToMemoryStream_Success(C } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task GetStreamAsync_ReadZeroBytes_Success(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -187,9 +186,8 @@ public async Task GetStreamAsync_ReadZeroBytes_Success(Configuration.Http.Remote } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task ReadAsStreamAsync_Cancel_TaskIsCanceled(Configuration.Http.RemoteServer remoteServer) { var cts = new CancellationTokenSource(); diff --git a/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/GenericHandler.cs b/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/GenericHandler.cs index 6efc71033a308..f129157b1d916 100644 --- a/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/GenericHandler.cs +++ b/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/GenericHandler.cs @@ -13,7 +13,7 @@ public class GenericHandler // Must have constructor with this signature, otherwise exception at run time. public GenericHandler(RequestDelegate next) { - // This is an HTTP Handler, so no need to store next. + // This catch all HTTP Handler, so no need to store next. } public async Task Invoke(HttpContext context) diff --git a/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/NetCoreServer.csproj b/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/NetCoreServer.csproj index d9b272d4d3241..875277b02d31a 100644 --- a/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/NetCoreServer.csproj +++ b/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/NetCoreServer.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + $(AspNetCoreAppCurrent) InProcess Exe false diff --git a/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/Startup.cs b/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/Startup.cs index 3ebe39a7d2c51..5819ff9f25ef3 100644 --- a/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/Startup.cs +++ b/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/Startup.cs @@ -11,11 +11,20 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { + services.AddCors(o => o.AddPolicy("AnyCors", builder => + { + builder.AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader() + .WithExposedHeaders("*") + ; + })); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { + app.UseCors("AnyCors"); app.UseWebSockets(); app.UseGenericHandler(); } diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index e63e0d0d5e946..e1dbe0aa512e3 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -9,6 +9,7 @@ using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32; +using Xunit; namespace System { @@ -59,6 +60,7 @@ public static partial class PlatformDetection public static bool IsBrowserDomSupported => GetIsBrowserDomSupported(); public static bool IsBrowserDomSupportedOrNotBrowser => IsNotBrowser || GetIsBrowserDomSupported(); public static bool IsNotBrowserDomSupported => !IsBrowserDomSupported; + public const TestPlatforms LocalEchoServerIsNotAvailable = TestPlatforms.Any & ~TestPlatforms.Browser; public static bool IsUsingLimitedCultures => !IsNotMobile; public static bool IsNotUsingLimitedCultures => IsNotMobile; @@ -78,7 +80,7 @@ public static bool IsDrawingSupported } else { - return NativeLibrary.TryLoad("libgdiplus.so", out _) || NativeLibrary.TryLoad("libgdiplus.so.0", out _); + return NativeLibrary.TryLoad("libgdiplus.so", out _) || NativeLibrary.TryLoad("libgdiplus.so.0", out _); } } #endif diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/ClientCertificateTest.cs b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/ClientCertificateTest.cs index 9a7d6616f5f56..92b8e042364ef 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/ClientCertificateTest.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/ClientCertificateTest.cs @@ -96,7 +96,7 @@ public async Task UseClientCertOnHttp2_OSSupportsItButCertNotSet_SuccessWithOneW WinHttpHandler handler = new WinHttpHandler(); handler.ServerCertificateValidationCallback = CustomServerCertificateValidationCallback; string payload = "Mutual Authentication Test"; - HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, Test.Common.Configuration.Http.Http2RemoteEchoServer) { Version = HttpVersion20.Value }; + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, Test.Common.Configuration.Http.Http2SecureRemoteEchoServer) { Version = HttpVersion20.Value }; request.Content = new StringContent(payload); using (var client = new HttpClient(handler)) using (HttpResponseMessage response = await client.SendAsync(request)) diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/WinHttpHandlerTest.cs b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/WinHttpHandlerTest.cs index 5178f3a9d5298..c975a161efea3 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/WinHttpHandlerTest.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/WinHttpHandlerTest.cs @@ -148,14 +148,14 @@ public async Task GetAsync_SetCookieContainerMultipleCookies_CookiesSent() foreach (Cookie c in cookies) { - cookieContainer.Add(Configuration.Http.Http2RemoteEchoServer, c); + cookieContainer.Add(Configuration.Http.Http2SecureRemoteEchoServer, c); } handler.CookieContainer = cookieContainer; handler.CookieUsePolicy = CookieUsePolicy.UseSpecifiedCookieContainer; handler.ServerCertificateValidationCallback = (m, cert, chain, err) => true; string payload = "Cookie Test"; - HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, Configuration.Http.Http2RemoteEchoServer) { Version = HttpVersion20.Value }; + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, Configuration.Http.Http2SecureRemoteEchoServer) { Version = HttpVersion20.Value }; request.Content = new StringContent(payload); using (var client = new HttpClient(handler)) using (HttpResponseMessage response = await client.SendAsync(request)) @@ -188,14 +188,14 @@ public async Task SendAsync_MultipleHttp2ConnectionsEnabled_CreateAdditionalConn List<(Task task, DelayedStream stream)> requests = new List<(Task task, DelayedStream stream)>(); for (int i = 0; i < maxActiveStreamsLimit; i++) { - HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, Configuration.Http.Http2RemoteEchoServer) { Version = HttpVersion20.Value }; + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, Configuration.Http.Http2SecureRemoteEchoServer) { Version = HttpVersion20.Value }; byte[] payloadBytes = Encoding.UTF8.GetBytes(payloadText); DelayedStream content = new DelayedStream(payloadBytes, delaySource.Task); request.Content = new StreamContent(content); requests.Add((client.SendAsync(request, HttpCompletionOption.ResponseContentRead), content)); } - HttpRequestMessage aboveLimitRequest = new HttpRequestMessage(HttpMethod.Post, Configuration.Http.Http2RemoteEchoServer) { Version = HttpVersion20.Value }; + HttpRequestMessage aboveLimitRequest = new HttpRequestMessage(HttpMethod.Post, Configuration.Http.Http2SecureRemoteEchoServer) { Version = HttpVersion20.Value }; aboveLimitRequest.Content = new StringContent($"{payloadText}-{maxActiveStreamsLimit + 1}"); Task aboveLimitResponseTask = client.SendAsync(aboveLimitRequest, HttpCompletionOption.ResponseContentRead); diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Headers.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Headers.cs index eb57adbbfc635..18934ae4d48f2 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Headers.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Headers.cs @@ -343,11 +343,11 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => }); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Theory] [InlineData(false)] [InlineData(true)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task SendAsync_GetWithValidHostHeader_Success(bool withPort) { if (UseVersion == HttpVersion.Version30) @@ -355,6 +355,11 @@ public async Task SendAsync_GetWithValidHostHeader_Success(bool withPort) // External servers do not support HTTP3 currently. return; } + if (PlatformDetection.IsBrowser && withPort) + { + // we already have custom port with the local echo server + return; + } var m = new HttpRequestMessage(HttpMethod.Get, Configuration.Http.SecureRemoteEchoServer) { Version = UseVersion }; m.Headers.Host = withPort ? Configuration.Http.SecureHost + ":443" : Configuration.Http.SecureHost; @@ -372,8 +377,9 @@ public async Task SendAsync_GetWithValidHostHeader_Success(bool withPort) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/53874", TestPlatforms.Browser)] public async Task SendAsync_GetWithInvalidHostHeader_ThrowsException() { if (LoopbackServerFactory.Version >= HttpVersion.Version20) diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs index fcc3f0514747d..7bd40e3fb657b 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs @@ -1213,10 +1213,10 @@ await HttpAgnosticLoopbackServer.CreateClientAndServerAsync( }); } + [Theory] [OuterLoop("Uses external servers")] [MemberData(nameof(VersionSelectionMemberData))] - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNotBrowser))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [SkipOnPlatform(TestPlatforms.Browser, "Version is ignored on Browser")] public async Task SendAsync_CorrectVersionSelected_ExternalServer(Version requestVersion, HttpVersionPolicy versionPolicy, Version serverVersion, bool useSsl, object expectedResult) { RemoteServer remoteServer = null; @@ -1226,7 +1226,7 @@ public async Task SendAsync_CorrectVersionSelected_ExternalServer(Version reques } if (serverVersion == HttpVersion.Version20) { - remoteServer = useSsl ? RemoteHttp2Server : null; + remoteServer = useSsl ? RemoteSecureHttp2Server : null; } // No remote server that could serve the requested version. if (remoteServer == null) diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj index a5ae70bbb2feb..beb883c378448 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj @@ -12,7 +12,22 @@ WasmTestOnBrowser $(TestArchiveRoot)browseronly/ $(TestArchiveTestsRoot)$(OSPlatformConfig)/ + + + <_TestEchoMiddleware Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(OS)' == 'Windows_NT'">%HELIX_CORRELATION_PAYLOAD%/xharness/TestEchoMiddleware + <_TestEchoMiddleware Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(OS)' != 'Windows_NT'">$HELIX_CORRELATION_PAYLOAD/xharness/TestEchoMiddleware + <_TestEchoMiddleware Condition="'$(ContinuousIntegrationBuild)' != 'true'">$(ArtifactsDir)bin/NetCoreServer/$(NetCoreAppCurrent)-$(Configuration) + + $(WasmXHarnessArgs) --web-server-use-cors --web-server-use-https + $(WasmXHarnessArgs) --set-web-server-http-env=DOTNET_TEST_WEBSOCKETHOST,DOTNET_TEST_HTTPHOST,DOTNET_TEST_HTTP2HOST + $(WasmXHarnessArgs) --set-web-server-https-env=DOTNET_TEST_SECUREWEBSOCKETHOST,DOTNET_TEST_SECUREHTTPHOST,DOTNET_TEST_HTTP2SECUREHOST + $(WasmXHarnessArgs) --web-server-middleware=$(_TestEchoMiddleware)/NetCoreServer.dll,GenericHandler + + + + + diff --git a/src/libraries/System.Net.WebSockets.Client/tests/CancelTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/CancelTest.cs index 8c74513e0a0c8..b16c54cf6103e 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/CancelTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/CancelTest.cs @@ -13,7 +13,7 @@ public class CancelTest : ClientWebSocketTestBase { public CancelTest(ITestOutputHelper output) : base(output) { } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ConnectAsync_Cancel_ThrowsCancellationException(Uri server) { @@ -29,7 +29,7 @@ public async Task ConnectAsync_Cancel_ThrowsCancellationException(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendAsync_Cancel_Success(Uri server) { @@ -44,7 +44,7 @@ await TestCancellation((cws) => }, server); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] [ActiveIssue("https://github.com/dotnet/runtime/issues/19217")] public async Task ReceiveAsync_Cancel_Success(Uri server) @@ -67,7 +67,7 @@ await cws.SendAsync( }, server); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_Cancel_Success(Uri server) { @@ -89,7 +89,7 @@ await cws.SendAsync( }, server); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_Cancel_Success(Uri server) { @@ -112,7 +112,7 @@ await cws.SendAsync( }, server); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ReceiveAsync_CancelThenReceive_ThrowsOperationCanceledException(Uri server) { @@ -128,7 +128,7 @@ public async Task ReceiveAsync_CancelThenReceive_ThrowsOperationCanceledExceptio } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ReceiveAsync_ReceiveThenCancel_ThrowsOperationCanceledException(Uri server) { @@ -144,7 +144,7 @@ public async Task ReceiveAsync_ReceiveThenCancel_ThrowsOperationCanceledExceptio } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ReceiveAsync_AfterCancellationDoReceiveAsync_ThrowsWebSocketException(Uri server) { diff --git a/src/libraries/System.Net.WebSockets.Client/tests/CloseTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/CloseTest.cs index bee31155b396f..40fb64b183f98 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/CloseTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/CloseTest.cs @@ -18,7 +18,7 @@ public class CloseTest : ClientWebSocketTestBase public CloseTest(ITestOutputHelper output) : base(output) { } [ActiveIssue("https://github.com/dotnet/runtime/issues/28957")] - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServersAndBoolean))] public async Task CloseAsync_ServerInitiatedClose_Success(Uri server, bool useCloseOutputAsync) { @@ -65,7 +65,7 @@ await cws.SendAsync( } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_ClientInitiatedClose_Success(Uri server) { @@ -87,7 +87,7 @@ public async Task CloseAsync_ClientInitiatedClose_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_CloseDescriptionIsMaxLength_Success(Uri server) { @@ -101,7 +101,7 @@ public async Task CloseAsync_CloseDescriptionIsMaxLength_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_CloseDescriptionIsMaxLengthPlusOne_ThrowsArgumentException(Uri server) { @@ -126,7 +126,7 @@ public async Task CloseAsync_CloseDescriptionIsMaxLengthPlusOne_ThrowsArgumentEx } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_CloseDescriptionHasUnicode_Success(Uri server) { @@ -145,7 +145,7 @@ public async Task CloseAsync_CloseDescriptionHasUnicode_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_CloseDescriptionIsNull_Success(Uri server) { @@ -161,7 +161,7 @@ public async Task CloseAsync_CloseDescriptionIsNull_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_ExpectedStates(Uri server) { @@ -180,7 +180,7 @@ public async Task CloseOutputAsync_ExpectedStates(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_CloseOutputAsync_Throws(Uri server) { @@ -205,7 +205,7 @@ await Assert.ThrowsAnyAsync(async () => } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_ClientInitiated_CanReceive_CanClose(Uri server) { @@ -245,7 +245,7 @@ public async Task CloseOutputAsync_ClientInitiated_CanReceive_CanClose(Uri serve } [ActiveIssue("https://github.com/dotnet/runtime/issues/28957")] - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_ServerInitiated_CanSend(Uri server) { @@ -292,7 +292,7 @@ await cws.SendAsync( } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_CloseDescriptionIsNull_Success(Uri server) { @@ -308,7 +308,7 @@ public async Task CloseOutputAsync_CloseDescriptionIsNull_Success(Uri server) } [ActiveIssue("https://github.com/dotnet/runtime/issues/22000", TargetFrameworkMonikers.Netcoreapp)] - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_DuringConcurrentReceiveAsync_ExpectedStates(Uri server) { @@ -345,7 +345,7 @@ public async Task CloseOutputAsync_DuringConcurrentReceiveAsync_ExpectedStates(U } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_DuringConcurrentReceiveAsync_ExpectedStates(Uri server) { diff --git a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs index 1f3f37f1a3710..b52da3f983dd5 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs @@ -17,7 +17,7 @@ public class ConnectTest : ClientWebSocketTestBase public ConnectTest(ITestOutputHelper output) : base(output) { } [ActiveIssue("https://github.com/dotnet/runtime/issues/1895")] - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(UnavailableWebSocketServers))] public async Task ConnectAsync_NotWebSocketServer_ThrowsWebSocketExceptionWithMessage(Uri server, string exceptionMessage, WebSocketError errorCode) { @@ -42,21 +42,21 @@ public async Task ConnectAsync_NotWebSocketServer_ThrowsWebSocketExceptionWithMe } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task EchoBinaryMessage_Success(Uri server) { await WebSocketHelper.TestEcho(server, WebSocketMessageType.Binary, TimeOutMilliseconds, _output); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task EchoTextMessage_Success(Uri server) { await WebSocketHelper.TestEcho(server, WebSocketMessageType.Text, TimeOutMilliseconds, _output); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoHeadersServers))] [SkipOnPlatform(TestPlatforms.Browser, "CustomHeaders not supported on browser")] public async Task ConnectAsync_AddCustomHeaders_Success(Uri server) @@ -118,7 +118,7 @@ await LoopbackServer.CreateClientAndServerAsync(async uri => }), new LoopbackServer.Options { WebSocketEndpoint = true }); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoHeadersServers))] [SkipOnPlatform(TestPlatforms.Browser, "Cookies not supported on browser")] public async Task ConnectAsync_CookieHeaders_Success(Uri server) @@ -168,7 +168,7 @@ public async Task ConnectAsync_CookieHeaders_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] [ActiveIssue("https://github.com/dotnet/runtime/issues/45583", TestPlatforms.Browser)] public async Task ConnectAsync_PassNoSubProtocol_ServerRequires_ThrowsWebSocketException(Uri server) @@ -194,7 +194,7 @@ public async Task ConnectAsync_PassNoSubProtocol_ServerRequires_ThrowsWebSocketE } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ConnectAsync_PassMultipleSubProtocols_ServerRequires_ConnectionUsesAgreedSubProtocol(Uri server) { @@ -235,7 +235,7 @@ await LoopbackServer.CreateClientAndServerAsync(async uri => }), new LoopbackServer.Options { WebSocketEndpoint = true }); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] [ActiveIssue("https://github.com/dotnet/runtime/issues/42852", TestPlatforms.Browser)] public async Task ConnectAndCloseAsync_UseProxyServer_ExpectedClosedState(Uri server) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs index 5d36a8c6c32bd..0a28f7419e3ff 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs @@ -49,7 +49,7 @@ public abstract class SendReceiveTest : ClientWebSocketTestBase public SendReceiveTest(ITestOutputHelper output) : base(output) { } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendReceive_PartialMessageDueToSmallReceiveBuffer_Success(Uri server) { @@ -86,7 +86,7 @@ public async Task SendReceive_PartialMessageDueToSmallReceiveBuffer_Success(Uri } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] [SkipOnPlatform(TestPlatforms.Browser, "JS Websocket does not support see issue https://github.com/dotnet/runtime/issues/46983")] public async Task SendReceive_PartialMessageBeforeCompleteMessageArrives_Success(Uri server) @@ -128,7 +128,7 @@ public async Task SendReceive_PartialMessageBeforeCompleteMessageArrives_Success } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendAsync_SendCloseMessageType_ThrowsArgumentExceptionWithMessage(Uri server) { @@ -156,7 +156,7 @@ public async Task SendAsync_SendCloseMessageType_ThrowsArgumentExceptionWithMess } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendAsync_MultipleOutstandingSendOperations_Throws(Uri server) { @@ -215,7 +215,7 @@ public async Task SendAsync_MultipleOutstandingSendOperations_Throws(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ReceiveAsync_MultipleOutstandingReceiveOperations_Throws(Uri server) { @@ -279,7 +279,7 @@ await SendAsync( } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendAsync_SendZeroLengthPayloadAsEndOfMessage_Success(Uri server) { @@ -318,7 +318,7 @@ await SendAsync( } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendReceive_VaryingLengthBuffers_Success(Uri server) { @@ -358,7 +358,7 @@ public async Task SendReceive_VaryingLengthBuffers_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendReceive_Concurrent_Success(Uri server) { @@ -387,7 +387,7 @@ public async Task SendReceive_Concurrent_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalFact(nameof(WebSocketsSupported))] [ActiveIssue("https://github.com/dotnet/runtime/issues/42852", TestPlatforms.Browser)] public async Task SendReceive_ConnectionClosedPrematurely_ReceiveAsyncFailsAndWebSocketStateUpdated() @@ -457,7 +457,7 @@ await LoopbackServer.CreateServerAsync(async (server, url) => }, options); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", PlatformDetection.LocalEchoServerIsNotAvailable)] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ZeroByteReceive_CompletesWhenDataAvailable(Uri server) { diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index 3da2d56665aeb..2f20602dc797d 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -5,10 +5,26 @@ $(DefineConstants);NETSTANDARD + WasmTestOnBrowser WasmTestOnBrowser $(TestArchiveRoot)browseronly/ $(TestArchiveTestsRoot)$(OSPlatformConfig)/ + + + <_TestEchoMiddleware Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(OS)' == 'Windows_NT'">%HELIX_CORRELATION_PAYLOAD%/xharness/TestEchoMiddleware + <_TestEchoMiddleware Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(OS)' != 'Windows_NT'">$HELIX_CORRELATION_PAYLOAD/xharness/TestEchoMiddleware + <_TestEchoMiddleware Condition="'$(ContinuousIntegrationBuild)' != 'true'">$(ArtifactsDir)bin/NetCoreServer/$(NetCoreAppCurrent)-$(Configuration) + + $(WasmXHarnessArgs) --web-server-use-cors --web-server-use-https + $(WasmXHarnessArgs) --set-web-server-http-env=DOTNET_TEST_WEBSOCKETHOST,DOTNET_TEST_HTTPHOST,DOTNET_TEST_HTTP2HOST + $(WasmXHarnessArgs) --set-web-server-https-env=DOTNET_TEST_SECUREWEBSOCKETHOST,DOTNET_TEST_SECUREHTTPHOST,DOTNET_TEST_HTTP2SECUREHOST + $(WasmXHarnessArgs) --web-server-middleware=$(_TestEchoMiddleware)/NetCoreServer.dll,GenericHandler + + + + + diff --git a/src/libraries/sendtohelixhelp.proj b/src/libraries/sendtohelixhelp.proj index 9a156b1f2a389..9192f51b4f022 100644 --- a/src/libraries/sendtohelixhelp.proj +++ b/src/libraries/sendtohelixhelp.proj @@ -293,6 +293,7 @@ https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/$(ChromiumRevision)/chromedriver_linux64.zip $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'mono', 'wasm', 'emsdk')) $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'mono', 'wasm', 'build')) + $([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'bin', 'NetCoreServer', '$(NetCoreAppCurrent)-$(Configuration)')) @@ -325,6 +326,10 @@ + + + +