diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index edeed52b946f1d..78e421042fd7be 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -153,6 +153,7 @@ MonoRuntimeHeaders="$(MicrosoftNetCoreAppRuntimePackNativeDir)include\mono-2.0" Assemblies="@(BundleAssemblies)" MainLibraryFileName="$(MainLibraryFileName)" + IncludeNetworkSecurityConfig="$(IncludeNetworkSecurityConfig)" EnvironmentVariables="@(_AndroidEnv)" ForceAOT="$(RunAOTCompilation)" ForceInterpreter="$(MonoForceInterpreter)" diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs index ebd154b3a0a027..cf9af001342177 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.AcceptAllCerts.cs @@ -46,7 +46,6 @@ public void SingletonReturnsTrue() #pragma warning restore SYSLIB0039 [InlineData(SslProtocols.None, false)] [InlineData(SslProtocols.None, true)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SetDelegate_ConnectionSucceeds(SslProtocols acceptedProtocol, bool requestOnlyThisProtocol) { #pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete @@ -55,11 +54,9 @@ public async Task SetDelegate_ConnectionSucceeds(SslProtocols acceptedProtocol, requestOnlyThisProtocol |= PlatformDetection.IsOSX && acceptedProtocol == SslProtocols.Tls; #pragma warning restore SYSLIB0039 - using (HttpClientHandler handler = CreateHttpClientHandler()) + using (HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true)) using (HttpClient client = CreateHttpClient(handler)) { - handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; - if (requestOnlyThisProtocol) { handler.SslProtocols = acceptedProtocol; @@ -99,13 +96,12 @@ await TestHelper.WhenAllCompletedOrAnyFailed( [OuterLoop] [ConditionalTheory(nameof(ClientSupportsDHECipherSuites))] [MemberData(nameof(InvalidCertificateServers))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] + [SkipOnPlatform(TestPlatforms.Android, "Android rejects the certificate, the custom validation callback in .NET cannot override OS behavior in the current implementation")] public async Task InvalidCertificateServers_CertificateValidationDisabled_Succeeds(string url) { - using (HttpClientHandler handler = CreateHttpClientHandler()) + using (HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true)) using (HttpClient client = CreateHttpClient(handler)) { - handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; (await client.GetAsync(url)).Dispose(); } } diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cancellation.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cancellation.cs index 9a5478868fad80..9382e875ed7958 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cancellation.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cancellation.cs @@ -29,7 +29,6 @@ public HttpClientHandler_Cancellation_Test(ITestOutputHelper output) : base(outp [InlineData(false, CancellationMode.Token)] [InlineData(true, CancellationMode.Token)] [ActiveIssue("https://github.com/dotnet/runtime/issues/36634", TestPlatforms.Browser)] // out of memory - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsync_CancelDuringRequestContentSend_TaskCanceledQuickly(bool chunkedTransfer, CancellationMode mode) { if (LoopbackServerFactory.Version >= HttpVersion20.Value && chunkedTransfer) @@ -88,7 +87,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => [Theory] [MemberData(nameof(OneBoolAndCancellationMode))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_CancelDuringResponseHeadersReceived_TaskCanceledQuickly(bool connectionClose, CancellationMode mode) { if (LoopbackServerFactory.Version >= HttpVersion20.Value && connectionClose) @@ -209,7 +207,6 @@ await ValidateClientCancellationAsync(async () => [Theory] [MemberData(nameof(ThreeBools))] [ActiveIssue("https://github.com/dotnet/runtime/issues/65429", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJS))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_CancelDuringResponseBodyReceived_Unbuffered_TaskCanceledQuickly(bool chunkedTransfer, bool connectionClose, bool readOrCopyToAsync) { if (LoopbackServerFactory.Version >= HttpVersion20.Value && (chunkedTransfer || connectionClose)) @@ -293,7 +290,6 @@ await ValidateClientCancellationAsync(async () => [InlineData(CancellationMode.CancelPendingRequests, true)] [InlineData(CancellationMode.DisposeHttpClient, true)] [SkipOnPlatform(TestPlatforms.Browser, "Browser doesn't have blocking synchronous Stream.ReadByte and so it waits for whole body")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_CancelPendingRequests_DoesntCancelReadAsyncOnResponseStream(CancellationMode mode, bool copyToAsync) { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ClientCertificates.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ClientCertificates.cs index e26fce26f79253..a6dd3bbe63291d 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ClientCertificates.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ClientCertificates.cs @@ -68,8 +68,7 @@ public void ClientCertificates_ClientCertificateOptionsAutomatic_ThrowsException private HttpClient CreateHttpClientWithCert(X509Certificate2 cert) { - HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); Assert.NotNull(cert); handler.ClientCertificates.Add(cert); Assert.True(handler.ClientCertificates.Contains(cert)); @@ -81,7 +80,6 @@ private HttpClient CreateHttpClientWithCert(X509Certificate2 cert) [InlineData(1, true)] [InlineData(2, true)] [InlineData(3, false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Manual_CertificateOnlySentWhenValid_Success(int certIndex, bool serverExpectsClientCertificate) { var options = new LoopbackServer.Options { UseSsl = true }; @@ -130,7 +128,6 @@ await TestHelper.WhenAllCompletedOrAnyFailed( [Theory] [InlineData(6, false)] [InlineData(3, true)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Manual_CertificateSentMatchesCertificateReceived_Success( int numberOfRequests, bool reuseClient) // validate behavior with and without connection pooling, which impacts client cert usage @@ -190,10 +187,9 @@ await LoopbackServer.CreateServerAsync(async (server, url) => [InlineData(ClientCertificateOption.Automatic)] public async Task AutomaticOrManual_DoesntFailRegardlessOfWhetherClientCertsAreAvailable(ClientCertificateOption mode) { - using (HttpClientHandler handler = CreateHttpClientHandler()) + using (HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true)) using (HttpClient client = CreateHttpClient(handler)) { - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; handler.ClientCertificateOptions = mode; await LoopbackServer.CreateServerAsync(async server => diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs index e0b2e5d338c703..b2f03bfbc930e5 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Cookies.cs @@ -44,7 +44,6 @@ private static CookieContainer CreateSingleCookieContainer(Uri uri, string cooki private static string GetCookieHeaderValue(string cookieName, string cookieValue) => $"{cookieName}={cookieValue}"; [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_DefaultCoookieContainer_NoCookieSent() { await LoopbackServerFactory.CreateClientAndServerAsync( @@ -65,7 +64,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync( [Theory] [MemberData(nameof(CookieNamesValuesAndUseCookies))] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_SetCookieContainer_CookieSent(string cookieName, string cookieValue, bool useCookies) { await LoopbackServerFactory.CreateClientAndServerAsync( @@ -96,7 +94,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync( [Fact] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_SetCookieContainerMultipleCookies_CookiesSent() { var cookies = new Cookie[] @@ -131,7 +128,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync( } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_AddCookieHeader_CookieHeaderSent() { await LoopbackServerFactory.CreateClientAndServerAsync( @@ -153,7 +149,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync( } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_AddMultipleCookieHeaders_CookiesSent() { await LoopbackServerFactory.CreateClientAndServerAsync( @@ -223,7 +218,6 @@ private string GetCookieValue(HttpRequestData request) [Fact] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_SetCookieContainerAndCookieHeader_BothCookiesSent() { await LoopbackServerFactory.CreateServerAsync(async (server, url) => @@ -252,7 +246,6 @@ await LoopbackServerFactory.CreateServerAsync(async (server, url) => [Fact] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_SetCookieContainerAndMultipleCookieHeaders_BothCookiesSent() { await LoopbackServerFactory.CreateServerAsync(async (server, url) => @@ -293,7 +286,6 @@ await LoopbackServerFactory.CreateServerAsync(async (server, url) => [Fact] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsyncWithRedirect_SetCookieContainer_CorrectCookiesSent() { if (UseVersion == HttpVersion30) @@ -341,7 +333,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async url => [Theory] [MemberData(nameof(CookieNamesValuesAndUseCookies))] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_ReceiveSetCookieHeader_CookieAdded(string cookieName, string cookieValue, bool useCookies) { await LoopbackServerFactory.CreateServerAsync(async (server, url) => @@ -374,7 +365,6 @@ await LoopbackServerFactory.CreateServerAsync(async (server, url) => [Fact] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_ReceiveMultipleSetCookieHeaders_CookieAdded() { await LoopbackServerFactory.CreateServerAsync(async (server, url) => @@ -415,7 +405,6 @@ await LoopbackServerFactory.CreateServerAsync(async (server, url) => // ConditionalFact: CookieContainer does not follow RFC6265 on .NET Framework, therefore the (WinHttpHandler) test is expected to fail [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNetFramework))] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_NoPathDefined_CookieAddedWithDefaultPath() { await LoopbackServerFactory.CreateServerAsync(async (server, serverUrl) => @@ -446,7 +435,6 @@ await LoopbackServerFactory.CreateServerAsync(async (server, serverUrl) => // ConditionalFact: CookieContainer does not follow RFC6265 on .NET Framework, therefore the (WinHttpHandler) test is expected to fail [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNetFramework))] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_CookiePathDoesNotMatchRequestPath_CookieAccepted() { await LoopbackServerFactory.CreateServerAsync(async (server, serverUrl) => @@ -479,7 +467,6 @@ await LoopbackServerFactory.CreateServerAsync(async (server, serverUrl) => // ConditionalFact: CookieContainer does not follow RFC6265 on .NET Framework, therefore the (WinHttpHandler) test is expected to fail [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNetFramework))] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_Redirect_CookiesArePreserved() { if (UseVersion == HttpVersion30) @@ -529,7 +516,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async serverUrl => [Fact] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_ReceiveSetCookieHeader_CookieUpdated() { const string newCookieValue = "789"; @@ -558,7 +544,6 @@ await LoopbackServerFactory.CreateServerAsync(async (server, url) => [Fact] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_ReceiveSetCookieHeader_CookieRemoved() { await LoopbackServerFactory.CreateServerAsync(async (server, url) => @@ -583,7 +568,6 @@ await LoopbackServerFactory.CreateServerAsync(async (server, url) => [Fact] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_ReceiveInvalidSetCookieHeader_ValidCookiesAdded() { await LoopbackServerFactory.CreateServerAsync(async (server, url) => @@ -619,7 +603,6 @@ await LoopbackServerFactory.CreateServerAsync(async (server, url) => [Fact] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsyncWithRedirect_ReceiveSetCookie_CookieSent() { if (UseVersion == HttpVersion30) @@ -680,7 +663,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async url => [Fact] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsyncWithBasicAuth_ReceiveSetCookie_CookieSent() { if (UseVersion == HttpVersion30) diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs index 201c1d8e54e86c..bedf1ffd70c029 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Proxy.cs @@ -220,10 +220,9 @@ public async Task AuthenticatedProxyTunnelRequest_PostAsyncWithCreds_Success(Net }; using (LoopbackProxyServer proxyServer = LoopbackProxyServer.Create(options)) - using (HttpClientHandler handler = CreateHttpClientHandler()) + using (HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true)) using (HttpClient client = CreateHttpClient(handler)) { - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; handler.Proxy = new WebProxy(proxyServer.Uri) { Credentials = ConstructCredentials(cred, proxyServer.Uri, BasicAuth, wrapCredsInCache) }; using (HttpResponseMessage response = await client.PostAsync(Configuration.Http.SecureRemoteEchoServer, new StringContent(content))) @@ -296,9 +295,8 @@ public async Task AuthenticatedProxyTunnelRequest_PostAsyncWithNoCreds_Throws() using (LoopbackProxyServer proxyServer = LoopbackProxyServer.Create(options)) { - HttpClientHandler handler = CreateHttpClientHandler(); + HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); handler.Proxy = new WebProxy(proxyServer.Uri); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; using (HttpClient client = CreateHttpClient(handler)) { HttpRequestException e = await Assert.ThrowsAnyAsync(async () => await client.PostAsync("https://nosuchhost.invalid", new StringContent(content))); @@ -322,7 +320,6 @@ public async Task Proxy_SslProxyUnsupported_Throws() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ProxyTunnelRequest_GetAsync_Success() { if (IsWinHttpHandler) @@ -334,9 +331,8 @@ public async Task ProxyTunnelRequest_GetAsync_Success() using (LoopbackProxyServer proxyServer = LoopbackProxyServer.Create()) { - HttpClientHandler handler = CreateHttpClientHandler(); + HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); handler.Proxy = new WebProxy(proxyServer.Uri); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; using (HttpClient client = CreateHttpClient(handler)) { var options = new LoopbackServer.Options { UseSsl = true }; @@ -359,7 +355,6 @@ await LoopbackServer.CreateServerAsync(async (server, uri) => } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ProxyTunnelRequest_MaxConnectionsSetButDoesNotApplyToProxyConnect_Success() { if (IsWinHttpHandler) @@ -371,9 +366,8 @@ public async Task ProxyTunnelRequest_MaxConnectionsSetButDoesNotApplyToProxyConn using (LoopbackProxyServer proxyServer = LoopbackProxyServer.Create()) { - HttpClientHandler handler = CreateHttpClientHandler(); + HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); handler.Proxy = new WebProxy(proxyServer.Uri); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; handler.MaxConnectionsPerServer = 1; using (HttpClient client = CreateHttpClient(handler)) { @@ -417,7 +411,6 @@ await server2.AcceptConnectionAsync(async connection2 => } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ProxyTunnelRequest_OriginServerSendsProxyAuthChallenge_NoProxyAuthPerformed() { if (IsWinHttpHandler) @@ -427,9 +420,8 @@ public async Task ProxyTunnelRequest_OriginServerSendsProxyAuthChallenge_NoProxy using (LoopbackProxyServer proxyServer = LoopbackProxyServer.Create()) { - HttpClientHandler handler = CreateHttpClientHandler(); + HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); handler.Proxy = new WebProxy(proxyServer.Uri) { Credentials = ConstructCredentials(new NetworkCredential("username", "password"), proxyServer.Uri, BasicAuth, true) }; - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; using (HttpClient client = CreateHttpClient(handler)) { var options = new LoopbackServer.Options { UseSsl = true }; @@ -652,11 +644,10 @@ public async Task ProxyTunnelRequest_PortSpecified_NotStrippedOffInUri(string ho await LoopbackServer.CreateClientAndServerAsync(async proxyUri => { - using (HttpClientHandler handler = CreateHttpClientHandler()) + using (HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true)) using (HttpClient client = CreateHttpClient(handler)) { handler.Proxy = new WebProxy(proxyUri); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; try { await client.GetAsync(addressUri); @@ -692,11 +683,10 @@ public async Task ProxyTunnelRequest_UserAgentHeaderAdded(bool addUserAgentHeade await LoopbackServer.CreateClientAndServerAsync(async proxyUri => { - using (HttpClientHandler handler = CreateHttpClientHandler()) + using (HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true)) using (var client = new HttpClient(handler)) { handler.Proxy = new WebProxy(proxyUri); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; if (addUserAgentHeader) { client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Mozilla", "5.0")); diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs index 28ebca017e65e5..90de3cdee7b934 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.ServerCertificates.cs @@ -32,7 +32,9 @@ public HttpClientHandler_ServerCertificates_Test(ITestOutputHelper output) : bas // This enables customizing ServerCertificateCustomValidationCallback in WinHttpHandler variants: protected bool AllowAllCertificates { get; set; } = true; - protected new HttpClientHandler CreateHttpClientHandler() => CreateHttpClientHandler(UseVersion, allowAllCertificates: AllowAllCertificates); + protected new HttpClientHandler CreateHttpClientHandler() => CreateHttpClientHandler( + useVersion: UseVersion, + allowAllCertificates: UseVersion >= HttpVersion20.Value && AllowAllCertificates); protected override HttpClient CreateHttpClient() => CreateHttpClient(CreateHttpClientHandler()); [Fact] @@ -282,7 +284,7 @@ private async Task UseCallback_BadCertificate_ExpectedPolicyErrors_Helper(string [OuterLoop("Uses external servers")] [Theory] [MemberData(nameof(CertificateValidationServersAndExpectedPolicies))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] + [SkipOnPlatform(TestPlatforms.Android, "Android rejects the certificate, the custom validation callback in .NET cannot override OS behavior in the current implementation")] public async Task UseCallback_BadCertificate_ExpectedPolicyErrors(string url, SslPolicyErrors expectedErrors) { const int SEC_E_BUFFER_TOO_SMALL = unchecked((int)0x80090321); @@ -306,7 +308,7 @@ public async Task UseCallback_BadCertificate_ExpectedPolicyErrors(string url, Ss } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] + [SkipOnPlatform(TestPlatforms.Android, "Android rejects the certificate, the custom validation callback in .NET cannot override OS behavior in the current implementation")] public async Task UseCallback_SelfSignedCertificate_ExpectedPolicyErrors() { using (HttpClientHandler handler = CreateHttpClientHandler()) @@ -396,15 +398,13 @@ public void HttpClientUsesSslCertEnvironmentVariables() RemoteExecutor.Invoke(async (useVersionString, allowAllCertificatesString) => { const string Url = "https://www.microsoft.com"; + var version = Version.Parse(useVersionString); + using HttpClientHandler handler = CreateHttpClientHandler( + useVersion: version, + allowAllCertificates: version >= HttpVersion20.Value && bool.Parse(allowAllCertificatesString)); + using HttpClient client = CreateHttpClient(handler, useVersionString); - HttpClientHandler handler = CreateHttpClientHandler( - Version.Parse(useVersionString), - allowAllCertificates: bool.Parse(allowAllCertificatesString)); - - using (HttpClient client = CreateHttpClient(handler, useVersionString)) - { - await Assert.ThrowsAsync(() => client.GetAsync(Url)); - } + await Assert.ThrowsAsync(() => client.GetAsync(Url)); }, UseVersion.ToString(), AllowAllCertificates.ToString(), new RemoteInvokeOptions { StartInfo = psi }).Dispose(); } } diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.SslProtocols.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.SslProtocols.cs index 238794dbe23522..b7301d29f92793 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.SslProtocols.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.SslProtocols.cs @@ -64,10 +64,9 @@ public void SetGetProtocols_Roundtrips(SslProtocols protocols) [Fact] public async Task SetProtocols_AfterRequest_ThrowsException() { - using (HttpClientHandler handler = CreateHttpClientHandler()) + using (HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true)) using (HttpClient client = CreateHttpClient(handler)) { - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; await LoopbackServer.CreateServerAsync(async (server, url) => { await TestHelper.WhenAllCompletedOrAnyFailed( @@ -101,7 +100,6 @@ public static IEnumerable GetAsync_AllowedSSLVersion_Succeeds_MemberDa [Theory] [MemberData(nameof(GetAsync_AllowedSSLVersion_Succeeds_MemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_AllowedSSLVersion_Succeeds(SslProtocols acceptedProtocol, bool requestOnlyThisProtocol) { int count = 0; @@ -243,14 +241,11 @@ public async Task GetAsync_UnsupportedSSLVersion_Throws(SslProtocols sslProtocol } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_NoSpecifiedProtocol_DefaultsToTls12() { - using (HttpClientHandler handler = CreateHttpClientHandler()) + using (HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true)) using (HttpClient client = CreateHttpClient(handler)) { - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; - var options = new LoopbackServer.Options { UseSsl = true, SslProtocols = SslProtocols.Tls12 }; await LoopbackServer.CreateServerAsync(async (server, url) => { @@ -292,11 +287,10 @@ public async Task GetAsync_AllowedClientSslVersionDiffersFromServer_ThrowsExcept return; } - using (HttpClientHandler handler = CreateHttpClientHandler()) + using (HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true)) using (HttpClient client = CreateHttpClient(handler)) { handler.SslProtocols = allowedClientProtocols; - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; var options = new LoopbackServer.Options { UseSsl = true, SslProtocols = acceptedServerProtocols }; await LoopbackServer.CreateServerAsync(async (server, url) => diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.cs index 1592265729f804..daa55476615b3a 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.cs @@ -151,9 +151,9 @@ public void Properties_AddItemToDictionary_ItemPresent() } } - [Fact] + [ConditionalFact] [SkipOnPlatform(TestPlatforms.Browser, "ServerCertificateCustomValidationCallback not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] + [SkipOnPlatform(TestPlatforms.Android, "IPv6 loopback with SSL doesn't work on Android")] public async Task GetAsync_IPv6LinkLocalAddressUri_Success() { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -166,9 +166,7 @@ public async Task GetAsync_IPv6LinkLocalAddressUri_Success() return; } - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; - + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); using HttpClient client = CreateHttpClient(handler); var options = new GenericLoopbackOptions { Address = TestHelper.GetIPv6LinkLocalAddress() }; @@ -186,9 +184,8 @@ await TestHelper.WhenAllCompletedOrAnyFailed( }, options: options); } - [Theory] + [ConditionalTheory] [MemberData(nameof(GetAsync_IPBasedUri_Success_MemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_IPBasedUri_Success(IPAddress address) { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -201,16 +198,16 @@ public async Task GetAsync_IPBasedUri_Success(IPAddress address) return; } - using HttpClientHandler handler = CreateHttpClientHandler(); - if (PlatformDetection.IsNotBrowser) - { - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; - } - + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); using HttpClient client = CreateHttpClient(handler); var options = new GenericLoopbackOptions { Address = address }; + if (PlatformDetection.IsAndroid && options.UseSsl && address == IPAddress.IPv6Loopback) + { + throw new SkipTestException("IPv6 loopback with SSL doesn't work on Android"); + } + await LoopbackServerFactory.CreateServerAsync(async (server, url) => { _output.WriteLine(url.ToString()); @@ -278,9 +275,8 @@ from useSsl in BoolValues where PlatformDetection.IsNotBrowser || !useSsl select new object[] { address, useSsl }; - [Theory] + [ConditionalTheory] [MemberData(nameof(SecureAndNonSecure_IPBasedUri_MemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_SecureAndNonSecureIPBasedUri_CorrectlyFormatted(IPAddress address, bool useSsl) { if (LoopbackServerFactory.Version >= HttpVersion20.Value) @@ -289,6 +285,11 @@ public async Task GetAsync_SecureAndNonSecureIPBasedUri_CorrectlyFormatted(IPAdd return; } + if (PlatformDetection.IsAndroid && useSsl && address == IPAddress.IPv6Loopback) + { + throw new SkipTestException("IPv6 loopback with SSL doesn't work on Android"); + } + var options = new LoopbackServer.Options { Address = address, UseSsl = useSsl }; bool connectionAccepted = false; string host = ""; @@ -327,7 +328,6 @@ await LoopbackServer.CreateClientAndServerAsync(async url => [InlineData("WWW-Authenticate", "CustomAuth")] [InlineData("", "")] // RFC7235 requires servers to send this header with 401 but some servers don't. [SkipOnPlatform(TestPlatforms.Browser, "Credentials is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_ServerNeedsNonStandardAuthAndSetCredential_StatusCodeUnauthorized(string authHeadrName, string authHeaderValue) { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -411,7 +411,6 @@ await LoopbackServer.CreateClientAndServerAsync(async uri => } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsync_ManyDifferentRequestHeaders_SentCorrectly() { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -991,7 +990,6 @@ await connection.WriteStringAsync( [InlineData(false, false)] [InlineData(null, false)] [ActiveIssue("https://github.com/dotnet/runtime/issues/65429", typeof(PlatformDetection), nameof(PlatformDetection.IsNodeJS))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ReadAsStreamAsync_HandlerProducesWellBehavedResponseStream(bool? chunked, bool enableWasmStreaming) { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -1204,7 +1202,6 @@ await server.AcceptConnectionAsync(async connection => } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ReadAsStreamAsync_EmptyResponseBody_HandlerProducesWellBehavedResponseStream() { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -1300,7 +1297,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/58812", TestPlatforms.Browser)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Dispose_DisposingHandlerCancelsActiveOperationsWithoutResponses() { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -1421,7 +1417,6 @@ public async Task GetAsync_UnicodeHostName_SuccessStatusCodeInResponse() [Fact] [SkipOnPlatform(TestPlatforms.Browser, "ExpectContinue not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_ExpectContinueTrue_NoContent_StillSendsHeader() { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -1474,7 +1469,6 @@ public static IEnumerable Interim1xxStatusCode() [Theory] [MemberData(nameof(Interim1xxStatusCode))] [SkipOnPlatform(TestPlatforms.Browser, "CookieContainer is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_1xxResponsesWithHeaders_InterimResponsesHeadersIgnored(HttpStatusCode responseStatusCode) { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -1550,7 +1544,6 @@ await server.AcceptConnectionAsync(async connection => [Theory] [MemberData(nameof(Interim1xxStatusCode))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_Unexpected1xxResponses_DropAllInterimResponses(HttpStatusCode responseStatusCode) { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -1602,7 +1595,6 @@ await server.AcceptConnectionAsync(async connection => [Fact] [SkipOnPlatform(TestPlatforms.Browser, "ExpectContinue not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_MultipleExpected100Responses_ReceivesCorrectResponse() { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -1653,7 +1645,6 @@ await server.AcceptConnectionAsync(async connection => [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/54160", TestPlatforms.Browser)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_Expect100Continue_RequestBodyFails_ThrowsContentException() { if (IsWinHttpHandler) @@ -1703,7 +1694,6 @@ await server.AcceptConnectionAsync(async connection => [Fact] [SkipOnPlatform(TestPlatforms.Browser, "ExpectContinue not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_No100ContinueReceived_RequestBodySentEventually() { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -1936,7 +1926,6 @@ await LoopbackServer.CreateServerAsync(async (server, url) => } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_RequestVersion20_HttpNotHttps_NoUpgradeRequest() { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) @@ -1972,7 +1961,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => #region Uri wire transmission encoding tests [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendRequest_UriPathHasReservedChars_ServerReceivedExpectedPath() { if (IsWinHttpHandler && UseVersion >= HttpVersion20.Value) diff --git a/src/libraries/Common/tests/System/Net/Http/TestHelper.cs b/src/libraries/Common/tests/System/Net/Http/TestHelper.cs index 98c19464db941a..93e49465b698bd 100644 --- a/src/libraries/Common/tests/System/Net/Http/TestHelper.cs +++ b/src/libraries/Common/tests/System/Net/Http/TestHelper.cs @@ -163,5 +163,23 @@ public static X509Certificate2 CreateServerSelfSignedCertificate(string name = " return cert; } } + +#if NETCOREAPP + public static SocketsHttpHandler CreateSocketsHttpHandler(bool allowAllCertificates = false) + { + var handler = new SocketsHttpHandler(); + + // Browser doesn't support ServerCertificateCustomValidationCallback + if (allowAllCertificates && PlatformDetection.IsNotBrowser) + { + // On Android, it is not enough to set the custom validation callback, the certificates also need to be trusted by the OS. + // See HttpClientHandlerTestBase.SocketsHttpHandler.cs:CreateHttpClientHandler for more details. + + handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; + } + + return handler; + } +#endif } } diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs index ddbfecb2b15dcd..81773638085d93 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/HttpClientHandlerTestBase.WinHttpHandler.cs @@ -16,7 +16,7 @@ protected static WinHttpClientHandler CreateHttpClientHandler(Version useVersion WinHttpClientHandler handler = new WinHttpClientHandler(useVersion); - if (useVersion >= HttpVersion20.Value && allowAllCertificates) + if (allowAllCertificates) { handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; } diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs index 99852e95bfeef2..7dacb64476d998 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs @@ -849,7 +849,6 @@ await GetFactoryForVersion(useVersion).CreateClientAndServerAsync( [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser))] [MemberData(nameof(UseSocketsHttpHandler_WithIdFormat_MemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_HeadersAreInjectedOnRedirects(bool useSocketsHttpHandler, ActivityIdFormat idFormat) { Activity parent = new Activity("parent"); @@ -934,7 +933,6 @@ public static IEnumerable SocketsHttpHandlerPropagators_WithIdFormat_M [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotBrowser))] [MemberData(nameof(SocketsHttpHandlerPropagators_WithIdFormat_MemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_CustomSocketsHttpHandlerPropagator_PropagatorIsUsed(DistributedContextPropagator propagator, ActivityIdFormat idFormat) { Activity parent = new Activity("parent"); @@ -944,8 +942,8 @@ public async Task SendAsync_CustomSocketsHttpHandlerPropagator_PropagatorIsUsed( await GetFactoryForVersion(UseVersion).CreateClientAndServerAsync( async uri => { - using var handler = new SocketsHttpHandler { ActivityHeadersPropagator = propagator }; - handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; + using var handler = CreateSocketsHttpHandler(allowAllCertificates: true); + handler.ActivityHeadersPropagator = propagator; using var client = new HttpClient(handler); var request = CreateRequest(HttpMethod.Get, uri, UseVersion, exactVersion: true); await client.SendAsync(TestAsync, request); @@ -1140,20 +1138,9 @@ private static void AssertHeadersAreInjected(HttpRequestData request, Activity p private static async Task<(HttpRequestMessage, HttpResponseMessage)> GetAsync(string useVersion, string testAsync, Uri uri, CancellationToken cancellationToken = default, bool useSocketsHttpHandler = false) { - HttpMessageHandler handler; - if (useSocketsHttpHandler) - { - var socketsHttpHandler = new SocketsHttpHandler(); - socketsHttpHandler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; - handler = socketsHttpHandler; - } - else - { - handler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates - }; - } + HttpMessageHandler handler = useSocketsHttpHandler + ? CreateSocketsHttpHandler(allowAllCertificates: true) + : CreateHttpClientHandler(allowAllCertificates: true); using var client = new HttpClient(handler); var request = CreateRequest(HttpMethod.Get, uri, Version.Parse(useVersion), exactVersion: true); diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HPackTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HPackTest.cs index b946c6d6fed43f..18e502f48281d0 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HPackTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HPackTest.cs @@ -32,7 +32,6 @@ public HPackTest(ITestOutputHelper output) : base(output) [Theory] [MemberData(nameof(HeaderEncodingTestData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task HPack_HeaderEncoding(string headerName, string expectedValue, byte[] expectedEncoding) { await Http2LoopbackServer.CreateClientAndServerAsync( diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Finalization.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Finalization.cs index 0678869ef8250f..49989acffb36cf 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Finalization.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Finalization.cs @@ -26,7 +26,6 @@ private static Task GetAndDropResponse(HttpClient client, Uri url) } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task IncompleteResponseStream_ResponseDropped_CancelsRequestToServer() { using (HttpClient client = CreateHttpClient()) 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 1973bdb361b3b9..6d92963c3e197b 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Headers.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Headers.cs @@ -24,7 +24,6 @@ public HttpClientHandlerTest_Headers(ITestOutputHelper output) : base(output) { private sealed class DerivedHttpHeaders : HttpHeaders { } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_RequestWithSimpleHeader_ResponseReferencesUnmodifiedRequestHeaders() { const string HeaderKey = "some-header-123", HeaderValue = "this is the expected header value"; @@ -49,7 +48,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => [Fact] [SkipOnPlatform(TestPlatforms.Browser, "User-Agent is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_UserAgent_CorrectlyWritten() { string userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.18 Safari/537.36"; @@ -73,7 +71,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_LargeHeaders_CorrectlyWritten() { if (UseVersion == HttpVersion.Version30) @@ -109,7 +106,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_DefaultHeaders_CorrectlyWritten() { const string Version = "2017-04-17"; @@ -171,7 +167,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => [InlineData("Accept-CharSet", "text/plain, text/json", false)] // invalid format for header but added with TryAddWithoutValidation [InlineData("Content-Location", "", false)] // invalid format for header but added with TryAddWithoutValidation [InlineData("Max-Forwards", "NotAnInteger", false)] // invalid format for header but added with TryAddWithoutValidation - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_SpecialHeaderKeyOrValue_Success(string key, string value, bool parsable) { if (PlatformDetection.IsBrowser && (key == "Content-Location" || key == "Date" || key == "Accept-CharSet")) @@ -217,7 +212,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => [Theory] [InlineData("Content-Security-Policy", 4618)] [InlineData("RandomCustomHeader", 12345)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_LargeHeader_Success(string headerName, int headerValueLength) { var rand = new Random(42); @@ -242,7 +236,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_EmptyResponseHeader_Success() { IList headers = new HttpHeaderData[] { @@ -274,7 +267,6 @@ await server.AcceptConnectionAsync(async connection => } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_MissingExpires_ReturnNull() { await LoopbackServerFactory.CreateClientAndServerAsync(async uri => @@ -295,7 +287,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => [InlineData("Thu, 01 Dec 1994 16:00:00 GMT", true)] [InlineData("-1", false)] [InlineData("0", false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_Expires_Success(string value, bool isValid) { await LoopbackServerFactory.CreateClientAndServerAsync(async uri => @@ -334,7 +325,6 @@ public void HeadersAdd_CustomExpires_Success(string value, bool isValid) [Theory] [InlineData("Accept-Encoding", "identity,gzip")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_RequestHeaderInResponse_Success(string name, string value) { await LoopbackServerFactory.CreateClientAndServerAsync(async uri => @@ -413,7 +403,6 @@ public async Task SendAsync_GetWithInvalidHostHeader_ThrowsException() [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/54160", TestPlatforms.Browser)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_WithZeroLengthHeaderName_Throws() { await LoopbackServerFactory.CreateClientAndServerAsync( @@ -457,7 +446,6 @@ private static readonly (string Name, Encoding ValueEncoding, string Separator, [Fact] [SkipOnPlatform(TestPlatforms.Browser, "Socket is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_CustomRequestEncodingSelector_CanSendNonAsciiHeaderValues() { await LoopbackServerFactory.CreateClientAndServerAsync( @@ -513,7 +501,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync( [Fact] [SkipOnPlatform(TestPlatforms.Browser, "Socket is not supported on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_CustomResponseEncodingSelector_CanReceiveNonAsciiHeaderValues() { await LoopbackServerFactory.CreateClientAndServerAsync( diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs index dfe7f2e386c43a..61700200dd1602 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs @@ -63,7 +63,6 @@ private async Task AssertHttpProtocolException(Task task, ProtocolErrors errorCo } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_ClientPreface_Sent() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -78,7 +77,6 @@ public async Task Http2_ClientPreface_Sent() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_InitialSettings_SentAndAcked() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -111,7 +109,6 @@ public async Task Http2_InitialSettings_SentAndAcked() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_DataSentBeforeServerPreface_ProtocolError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -130,7 +127,6 @@ public async Task Http2_DataSentBeforeServerPreface_ProtocolError() } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_StreamResetByServerBeforePrefix_RequestFailsWithGoawayProtocolError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -162,7 +158,6 @@ public async Task Http2_StreamResetByServerBeforePrefix_RequestFailsWithGoawayPr } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_NoResponseBody_Success() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -183,7 +178,6 @@ public async Task Http2_NoResponseBody_Success() } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_ZeroLengthResponseBody_Success() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -242,7 +236,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async uri => } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_ServerSendsValidSettingsValues_Success() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -278,7 +271,6 @@ public async Task Http2_ServerSendsValidSettingsValues_Success() [InlineData(SettingId.MaxFrameSize, 16383)] [InlineData(SettingId.MaxFrameSize, 162777216)] [InlineData(SettingId.InitialWindowSize, 0x80000000)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_ServerSendsInvalidSettingsValue_Error(SettingId settingId, uint value) { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -296,7 +288,6 @@ public async Task Http2_ServerSendsInvalidSettingsValue_Error(SettingId settingI } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_StreamResetByServerBeforeHeadersSent_RequestFails() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -316,7 +307,6 @@ public async Task Http2_StreamResetByServerBeforeHeadersSent_RequestFails() } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_StreamResetByServerAfterHeadersSent_RequestFails() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -339,7 +329,6 @@ public async Task Http2_StreamResetByServerAfterHeadersSent_RequestFails() } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_StreamResetByServerAfterPartialBodySent_RequestFails() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -364,7 +353,6 @@ public async Task Http2_StreamResetByServerAfterPartialBodySent_RequestFails() } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_StreamRefused_RequestIsRetried() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -400,7 +388,6 @@ public async Task GetAsync_StreamRefused_RequestIsRetried() } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsync_StreamRefused_RequestIsRetried() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -441,7 +428,6 @@ public async Task PostAsync_StreamRefused_RequestIsRetried() [OuterLoop("Uses delays")] [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_SettingsFrameNotSentOnNewConnection_ClientApplies100StreamLimit() { const int DefaultMaxConcurrentStreams = 100; @@ -493,7 +479,6 @@ public async Task GetAsync_SettingsFrameNotSentOnNewConnection_ClientApplies100S [OuterLoop("Uses delays")] [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_ServerDelaysSendingSettingsThenSetsLowerMaxConcurrentStreamsLimitThenIncreaseIt_ClientAppliesEachLimitChangeProperly() { const int DefaultMaxConcurrentStreams = 100; @@ -554,7 +539,6 @@ public async Task GetAsync_ServerDelaysSendingSettingsThenSetsLowerMaxConcurrent [OuterLoop("Uses delays")] [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GetAsync_ServerSendSettingsWithoutMaxConcurrentStreams_ClientAppliesInfiniteLimit() { const int DefaultMaxConcurrentStreams = 100; @@ -616,7 +600,6 @@ public async Task GetAsync_ServerSendSettingsWithoutMaxConcurrentStreams_ClientA // "If a DATA frame is received whose stream identifier field is 0x0, the recipient MUST // respond with a connection error (Section 5.4.1) of type PROTOCOL_ERROR." [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task DataFrame_NoStream_ConnectionError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -643,7 +626,6 @@ public async Task DataFrame_NoStream_ConnectionError() // "Receiving any frame other than HEADERS or PRIORITY on a stream in this state MUST // be treated as a connection error (Section 5.4.1) of type PROTOCOL_ERROR." [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task DataFrame_IdleStream_ConnectionError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -670,7 +652,6 @@ public async Task DataFrame_IdleStream_ConnectionError() // headers from the server on an idle stream. We fall back to treating this as a connection // level error, as we do for other unexpected frames on idle streams. [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task HeadersFrame_IdleStream_ConnectionError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -738,7 +719,6 @@ private static Frame MakeSimpleDataFrame(int streamId, bool endStream = false) = 0, streamId); [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ResponseStreamFrames_ContinuationBeforeHeaders_ConnectionError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -759,7 +739,6 @@ public async Task ResponseStreamFrames_ContinuationBeforeHeaders_ConnectionError } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ResponseStreamFrames_DataBeforeHeaders_ConnectionError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -780,7 +759,6 @@ public async Task ResponseStreamFrames_DataBeforeHeaders_ConnectionError() } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ResponseStreamFrames_HeadersAfterHeadersWithoutEndHeaders_ConnectionError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -802,7 +780,6 @@ public async Task ResponseStreamFrames_HeadersAfterHeadersWithoutEndHeaders_Conn } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ResponseStreamFrames_HeadersAfterHeadersAndContinuationWithoutEndHeaders_ConnectionError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -825,7 +802,6 @@ public async Task ResponseStreamFrames_HeadersAfterHeadersAndContinuationWithout } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ResponseStreamFrames_DataAfterHeadersWithoutEndHeaders_ConnectionError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -847,7 +823,6 @@ public async Task ResponseStreamFrames_DataAfterHeadersWithoutEndHeaders_Connect } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ResponseStreamFrames_DataAfterHeadersAndContinuationWithoutEndHeaders_ConnectionError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -873,7 +848,6 @@ public async Task ResponseStreamFrames_DataAfterHeadersAndContinuationWithoutEnd // "An endpoint MUST treat a GOAWAY frame with a stream identifier other than 0x0 as a // connection error (Section 5.4.1) of type PROTOCOL_ERROR." [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GoAwayFrame_NonzeroStream_ConnectionError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -897,7 +871,6 @@ public async Task GoAwayFrame_NonzeroStream_ConnectionError() } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GoAwayFrame_NewRequest_NewConnection() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -929,7 +902,6 @@ public async Task GoAwayFrame_NewRequest_NewConnection() } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GoAwayFrame_ServerDisconnect_AbortStreams() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -957,7 +929,6 @@ await Assert.ThrowsAnyAsync(() => } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GoAwayFrame_RequestWithBody_ServerDisconnect_AbortStreamsAndThrowIOException() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -990,7 +961,6 @@ public async Task GoAwayFrame_RequestWithBody_ServerDisconnect_AbortStreamsAndTh } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GoAwayFrame_UnprocessedStreamFirstRequestFinishedFirst_RequestRestarted() { // This test case is similar to GoAwayFrame_UnprocessedStreamFirstRequestWaitsUntilSecondFinishes_RequestRestarted @@ -1036,7 +1006,6 @@ public async Task GoAwayFrame_UnprocessedStreamFirstRequestFinishedFirst_Request } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GoAwayFrame_UnprocessedStreamFirstRequestWaitsUntilSecondFinishes_RequestRestarted() { using (await Watchdog.CreateAsync()) @@ -1079,7 +1048,6 @@ public async Task GoAwayFrame_UnprocessedStreamFirstRequestWaitsUntilSecondFinis } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GoAwayFrame_RequestInFlight_Finished() { await Http2LoopbackServer.CreateClientAndServerAsync(async uri => @@ -1125,7 +1093,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async uri => } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task DataFrame_TooLong_ConnectionError() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -1148,7 +1115,6 @@ public async Task DataFrame_TooLong_ConnectionError() [ConditionalTheory(nameof(SupportsAlpn))] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task CompletedResponse_FrameReceived_Ignored(bool sendDataFrame) { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -1182,7 +1148,6 @@ public async Task CompletedResponse_FrameReceived_Ignored(bool sendDataFrame) [ConditionalTheory(nameof(SupportsAlpn))] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task EmptyResponse_FrameReceived_Ignored(bool sendDataFrame) { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -1211,7 +1176,6 @@ public async Task EmptyResponse_FrameReceived_Ignored(bool sendDataFrame) } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task CompletedResponse_WindowUpdateFrameReceived_Success() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -1282,7 +1246,6 @@ public static IEnumerable ValidAndInvalidProtocolErrorsAndBool() [ConditionalTheory(nameof(SupportsAlpn))] [MemberData(nameof(ValidAndInvalidProtocolErrorsAndBool))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ResetResponseStream_FrameReceived_Ignored(ProtocolErrors error, bool dataFrame) { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -1340,7 +1303,6 @@ await new[] } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GoAwayFrame_NoPendingStreams_ConnectionClosed() { using (await Watchdog.CreateAsync()) @@ -1362,7 +1324,6 @@ public async Task GoAwayFrame_NoPendingStreams_ConnectionClosed() } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GoAwayFrame_AllPendingStreamsValid_RequestsSucceedAndConnectionClosed() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -1427,7 +1388,6 @@ public async Task GoAwayFrame_AllPendingStreamsValid_RequestsSucceedAndConnectio } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task GoAwayFrame_AbortAllPendingStreams_StreamFailWithExpectedException() { using (await Watchdog.CreateAsync()) @@ -1536,7 +1496,6 @@ private static async Task ReadToEndOfStream(Http2LoopbackConnection connect [OuterLoop("Uses Task.Delay")] [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_FlowControl_ClientDoesNotExceedWindows() { const int ContentSize = 100_000; @@ -1629,7 +1588,6 @@ public async Task Http2_FlowControl_ClientDoesNotExceedWindows() [OuterLoop("Uses Task.Delay")] [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_InitialWindowSize_ClientDoesNotExceedWindows() { const int ContentSize = DefaultInitialWindowSize + 1000; @@ -1749,7 +1707,6 @@ public async Task Http2_InitialWindowSize_ClientDoesNotExceedWindows() [InlineData(DefaultInitialWindowSize + 32 * 1024)] [InlineData(DefaultInitialWindowSize + 64 * 1024)] [InlineData(DefaultInitialWindowSize + 96 * 1024)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_SendOverStreamWindowSizeWithoutExplicitFlush_ClientSendsUpToFullWindowSize(int contentSize) { var content = new ByteArrayContent(new byte[contentSize]); @@ -1803,7 +1760,6 @@ public async Task Http2_SendOverStreamWindowSizeWithoutExplicitFlush_ClientSends [InlineData(DefaultInitialWindowSize + 32 * 1024)] [InlineData(DefaultInitialWindowSize + 64 * 1024)] [InlineData(DefaultInitialWindowSize + 96 * 1024)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_SendOverConnectionWindowSizeWithoutExplicitFlush_ClientSendsUpToFullWindowSize(int contentSize) { var content = new ByteArrayContent(new byte[contentSize]); @@ -1852,7 +1808,6 @@ public async Task Http2_SendOverConnectionWindowSizeWithoutExplicitFlush_ClientS [OuterLoop("Uses Task.Delay")] [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_MaxConcurrentStreams_LimitEnforced() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -1921,7 +1876,6 @@ public async Task Http2_MaxConcurrentStreams_LimitEnforced() [OuterLoop("Uses Task.Delay")] [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_WaitingForStream_Cancellation() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -1971,7 +1925,6 @@ public async Task Http2_WaitingForStream_Cancellation() } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_WaitingOnWindowCredit_Cancellation() { // The goal of this test is to get the client into the state where it has sent the headers, @@ -1979,8 +1932,7 @@ public async Task Http2_WaitingOnWindowCredit_Cancellation() // to ensure the request is cancelled as expected. const int ContentSize = DefaultInitialWindowSize + 1; - HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var content = new ByteAtATimeContent(ContentSize); @@ -2019,7 +1971,6 @@ public async Task Http2_WaitingOnWindowCredit_Cancellation() } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_PendingSend_Cancellation() { // The goal of this test is to get the client into the state where it is sending content, @@ -2058,7 +2009,6 @@ public async Task Http2_PendingSend_Cancellation() [OuterLoop("Uses Task.Delay")] [InlineData(false)] [InlineData(true)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_PendingSend_SendsReset(bool waitForData) { var cts = new CancellationTokenSource(); @@ -2128,7 +2078,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async url => [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_PendingReceive_SendsReset(bool doRead) { var cts = new CancellationTokenSource(); @@ -2198,7 +2147,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async url => } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2Connection_Should_Wrap_HttpContent_InvalidOperationException() { // test for https://github.com/dotnet/runtime/issues/30187 @@ -2226,7 +2174,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async url => } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2Connection_Should_Not_Wrap_HttpContent_CustomException() { // Assert existing HttpConnection behaviour in which custom HttpContent exception types are surfaced as-is @@ -2259,7 +2206,6 @@ private class CustomException : Exception { } [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncExpect100Continue_SendRequest_Ok(bool send100Continue) { await Http2LoopbackServer.CreateClientAndServerAsync(async url => @@ -2295,17 +2241,15 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async url => } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncExpect100Continue_NonSuccessResponse_RequestBodyNotSent() { string responseContent = "no no!"; await Http2LoopbackServer.CreateClientAndServerAsync(async url => { - using (var handler = new SocketsHttpHandler()) + using (var handler = CreateSocketsHttpHandler(allowAllCertificates: true)) using (HttpClient client = CreateHttpClient(handler)) { - handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; // Increase default Expect: 100-continue timeout to ensure that we don't accidentally fire the timer and send the request body. handler.Expect100ContinueTimeout = TimeSpan.FromSeconds(300); @@ -2427,7 +2371,6 @@ private async Task SendAndReceiveRequestEOFAsync(DuplexContent duplexContent, St } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncDuplex_ClientSendsEndStream_Success() { byte[] contentBytes = "Hello world"u8.ToArray(); @@ -2488,7 +2431,6 @@ public async Task PostAsyncDuplex_ClientSendsEndStream_Success() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncDuplex_ServerSendsEndStream_Success() { byte[] contentBytes = "Hello world"u8.ToArray(); @@ -2576,9 +2518,7 @@ public async Task ConnectAsync_ReadWriteWebSocketStream() StreamingHttpContent requestContent = new StreamingHttpContent(); - using var handler = new SocketsHttpHandler(); - handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; - + using var handler = CreateSocketsHttpHandler(allowAllCertificates: true); using HttpClient client = new HttpClient(handler); HttpRequestMessage request = new(HttpMethod.Connect, server.Address); @@ -2613,7 +2553,6 @@ public async Task ConnectAsync_ReadWriteWebSocketStream() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncDuplex_RequestContentException_ResetsStream() { byte[] contentBytes = "Hello world"u8.ToArray(); @@ -2671,7 +2610,6 @@ public async Task PostAsyncDuplex_RequestContentException_ResetsStream() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncDuplex_RequestContentExceptionAfterResponseEndReceivedButBeforeConsumed_ResetsStreamAndThrowsOnResponseStreamRead() { byte[] contentBytes = "Hello world"u8.ToArray(); @@ -2736,7 +2674,6 @@ public async Task PostAsyncDuplex_RequestContentExceptionAfterResponseEndReceive [OuterLoop("Uses Task.Delay")] [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncDuplex_CancelledBeforeResponseHeadersReceived_ResetsStream() { byte[] contentBytes = "Hello world"u8.ToArray(); @@ -2793,7 +2730,6 @@ public async Task PostAsyncDuplex_CancelledBeforeResponseHeadersReceived_ResetsS } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncDuplex_ServerResetsStream_Throws() { byte[] contentBytes = "Hello world"u8.ToArray(); @@ -2855,7 +2791,6 @@ public async Task PostAsyncDuplex_ServerResetsStream_Throws() [OuterLoop("Uses Task.Delay")] [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncDuplex_DisposeResponseBodyBeforeEnd_ResetsStreamAndThrowsOnRequestStreamWriteAndResponseStreamRead() { byte[] contentBytes = "Hello world"u8.ToArray(); @@ -2923,7 +2858,6 @@ public async Task PostAsyncDuplex_DisposeResponseBodyBeforeEnd_ResetsStreamAndTh [OuterLoop("Uses Task.Delay")] [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncDuplex_DisposeResponseBodyAfterEndReceivedButBeforeConsumed_ResetsStreamAndThrowsOnRequestStreamWriteAndResponseStreamRead() { byte[] contentBytes = "Hello world"u8.ToArray(); @@ -2997,7 +2931,6 @@ public async Task PostAsyncDuplex_DisposeResponseBodyAfterEndReceivedButBeforeCo [OuterLoop("Uses Task.Delay")] [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncDuplex_FinishRequestBodyAndDisposeResponseBodyAfterEndReceivedButBeforeConsumed_DoesNotResetStream() { byte[] contentBytes = "Hello world"u8.ToArray(); @@ -3063,7 +2996,6 @@ public async Task PostAsyncDuplex_FinishRequestBodyAndDisposeResponseBodyAfterEn } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncDuplex_ServerCompletesResponseBodyThenResetsStreamWithNoError_SuccessAndRequestBodyCancelled() { // Per section 8.1 of the RFC: @@ -3133,7 +3065,6 @@ public async Task PostAsyncDuplex_ServerCompletesResponseBodyThenResetsStreamWit } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PostAsyncNonDuplex_ServerCompletesResponseBodyThenResetsStreamWithNoError_SuccessAndRequestBodyCancelled() { // Per section 8.1 of the RFC: @@ -3186,7 +3117,6 @@ public async Task PostAsyncNonDuplex_ServerCompletesResponseBodyThenResetsStream [InlineData(true, HttpStatusCode.OK)] [InlineData(false, HttpStatusCode.OK)] [OuterLoop("Uses Task.Delay")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_ConcurentSendReceive_Ok(bool shouldWaitForRequestBody, HttpStatusCode responseCode) { string requestContent = new string('*', 300); @@ -3254,7 +3184,6 @@ public async Task SendAsync_ConcurentSendReceive_Ok(bool shouldWaitForRequestBod [Fact] [OuterLoop("Uses Task.Delay")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_ConcurentSendReceive_Fail() { TaskCompletionSource tsc = new TaskCompletionSource(); @@ -3327,7 +3256,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async url => [Fact] [OuterLoop("Waits for seconds for events that shouldn't happen")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_StreamContentRequestBody_WaitsForRequestBodyToComplete() { var waitToSendRequestBody = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); @@ -3377,12 +3305,9 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async url => } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_ProtocolMismatch_Throws() { - HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; - + HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); using (HttpClient client = CreateHttpClient()) { // Create HTTP/1.1 loopback server and advertise HTTP2 via ALPN. @@ -3414,7 +3339,6 @@ await server.AcceptConnectionAsync(async connection => // rfc7540 8.1.2.3. [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2GetAsync_MultipleStatusHeaders_Throws() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -3432,7 +3356,6 @@ public async Task Http2GetAsync_MultipleStatusHeaders_Throws() // rfc7540 8.1.2.3. [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2GetAsync_StatusHeaderNotFirst_Throws() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -3451,7 +3374,6 @@ public async Task Http2GetAsync_StatusHeaderNotFirst_Throws() // rfc7540 8.1.2.3. [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2GetAsync_TrailigPseudo_Throw() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -3474,7 +3396,6 @@ public async Task Http2GetAsync_TrailigPseudo_Throw() [InlineData(0)] [InlineData(1)] [InlineData(2)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2SendAsync_LargeHeaders_CorrectlyWritten(int continuationCount) { // Intentionally larger than 2x16K in total because that's the limit that will trigger a CONTINUATION frame in HTTP2. @@ -3518,7 +3439,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async uri => } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task InboundWindowSize_Exceeded_Throw() { var semaphore = new SemaphoreSlim(0); @@ -3596,7 +3516,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync( [Fact] [OuterLoop("Uses Task.Delay")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SocketSendQueueFull_RequestCanceled_ThrowsOperationCanceled() { TaskCompletionSource clientComplete = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); @@ -3638,7 +3557,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync( [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task MaxResponseHeadersLength_Exact_Success(bool huffmanEncode) { await Http2LoopbackServer.CreateClientAndServerAsync( @@ -3669,7 +3587,6 @@ await con.SendResponseHeadersAsync(streamId, isTrailingHeader: true, headers: ne [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task MaxResponseHeadersLength_Exceeded_Throws(bool huffmanEncode) { await Http2LoopbackServer.CreateClientAndServerAsync( @@ -3699,7 +3616,6 @@ await con.SendResponseHeadersAsync(streamId, isTrailingHeader: true, headers: ne } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task MaxResponseHeadersLength_Malicious_Throws() { await Http2LoopbackServer.CreateClientAndServerAsync( @@ -3727,7 +3643,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync( } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task DynamicTableSizeUpdate_Exceeds_Settings_Throws() { await Http2LoopbackServer.CreateClientAndServerAsync( @@ -3753,7 +3668,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync( } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task DynamicTable_Reuse_Concat() { await Http2LoopbackServer.CreateClientAndServerAsync( @@ -3784,7 +3698,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync( } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task DynamicTable_Resize_Success() { await Http2LoopbackServer.CreateClientAndServerAsync( @@ -3863,7 +3776,6 @@ await Http2LoopbackServer.CreateClientAndServerAsync( [Theory] [MemberData(nameof(DynamicTable_Data))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task DynamicTable_Receipt_Success(IEnumerable headers) { await Http2LoopbackServer.CreateClientAndServerAsync( diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.cs index 62aef6675f0cdf..a372c7d372dc1b 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTestBase.SocketsHttpHandler.cs @@ -34,14 +34,25 @@ protected static HttpClientHandler CreateHttpClientHandler(Version useVersion = HttpClientHandler handler = (PlatformDetection.SupportsAlpn && useVersion != HttpVersion.Version30) ? new HttpClientHandler() : new VersionHttpClientHandler(useVersion); - if (useVersion >= HttpVersion.Version20 && allowAllCertificates) + // Browser doesn't support ServerCertificateCustomValidationCallback + if (allowAllCertificates && PlatformDetection.IsNotBrowser) { + // On Android, it is not enough to set the custom validation callback, the certificates also need to be trusted by the OS. + // The public keys of our self-signed certificates that are used by the loopback server are part of the System.Net.TestData + // package and they can be included in a the Android test apk by adding the following property to the test's .csproj: + // + // true + // + handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; } return handler; } + protected static SocketsHttpHandler CreateSocketsHttpHandler(bool allowAllCertificates) + => TestHelper.CreateSocketsHttpHandler(allowAllCertificates); + protected Http3LoopbackServer CreateHttp3LoopbackServer(Http3Options options = default) { return new Http3LoopbackServer(options); diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.cs index 4149c97843b28c..de34a77496ff4e 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientMiniStressTest.cs @@ -95,14 +95,7 @@ public abstract class HttpClientMiniStress : HttpClientHandlerTestBase public HttpClientMiniStress(ITestOutputHelper output) : base(output) { } protected override HttpClient CreateHttpClient() => - CreateHttpClient( - new SocketsHttpHandler() - { - SslOptions = new SslClientAuthenticationOptions() - { - RemoteCertificateValidationCallback = delegate { return true; }, - } - }); + CreateHttpClient(CreateSocketsHttpHandler(allowAllCertificates: true)); [ConditionalTheory(typeof(TestEnvironment), nameof(TestEnvironment.IsStressModeEnabled))] [OuterLoop] diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs index b8ef6e6607f42f..fcc98b021ccac0 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs @@ -225,8 +225,7 @@ public async Task GetContentAsync_WhenCannotConnect_ExceptionContainsHostInfo() { const string Host = "localhost:1234"; - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.ConnectCallback = (context, token) => { @@ -1230,7 +1229,6 @@ public static IEnumerable VersionSelectionMemberData() [Theory] [MemberData(nameof(VersionSelectionMemberData))] [SkipOnPlatform(TestPlatforms.Browser, "Version is ignored on Browser")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task SendAsync_CorrectVersionSelected_LoopbackServer(Version requestVersion, HttpVersionPolicy versionPolicy, Version serverVersion, bool useSsl, object expectedResult) { await HttpAgnosticLoopbackServer.CreateClientAndServerAsync( @@ -1242,11 +1240,7 @@ await HttpAgnosticLoopbackServer.CreateClientAndServerAsync( VersionPolicy = versionPolicy }; - using HttpClientHandler handler = CreateHttpClientHandler(); - if (useSsl) - { - handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; - } + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: useSsl); using HttpClient client = CreateHttpClient(handler); client.Timeout = TimeSpan.FromSeconds(30); diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.cs index 4909e8ca0f5b1b..3b8bfd0d75a1b5 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamZeroByteReadTests.cs @@ -80,7 +80,6 @@ public static IEnumerable ZeroByteRead_IssuesZeroByteReadOnUnderlyingS [Theory] [MemberData(nameof(ZeroByteRead_IssuesZeroByteReadOnUnderlyingStream_MemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] [SkipOnPlatform(TestPlatforms.Browser, "ConnectCallback is not supported on Browser")] public async Task ZeroByteRead_IssuesZeroByteReadOnUnderlyingStream(StreamConformanceTests.ReadWriteMode readMode, bool useSsl) { @@ -97,11 +96,8 @@ public async Task ZeroByteRead_IssuesZeroByteReadOnUnderlyingStream(StreamConfor } }); - using var handler = new SocketsHttpHandler - { - ConnectCallback = delegate { return ValueTask.FromResult(httpConnection); } - }; - handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; + using var handler = TestHelper.CreateSocketsHttpHandler(allowAllCertificates: true); + handler.ConnectCallback = delegate { return ValueTask.FromResult(httpConnection); }; using var client = new HttpClient(handler); @@ -226,7 +222,6 @@ public ResponseStreamZeroByteReadTestBase(ITestOutputHelper output) : base(outpu [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ZeroByteRead_BlocksUntilDataIsAvailable(bool async) { var zeroByteReadIssued = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Cancellation.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Cancellation.cs index 96e3b53cdcb9f0..7a0315186a657d 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Cancellation.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Cancellation.cs @@ -110,7 +110,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ConnectionFailure_AfterInitialRequestCancelled_SecondRequestSucceedsOnNewConnection(bool useSsl) { if (UseVersion == HttpVersion.Version30) @@ -132,10 +131,9 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri => TaskCompletionSource tcsFirstConnectionInitiated = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); TaskCompletionSource tcsFirstRequestCanceled = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); - using (var handler = CreateHttpClientHandler()) + using (var handler = CreateHttpClientHandler(allowAllCertificates: true)) using (var client = CreateHttpClient(handler)) { - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; var socketsHandler = GetUnderlyingSocketsHttpHandler(handler); socketsHandler.ConnectCallback = async (context, token) => { @@ -264,7 +262,6 @@ public async Task RequestsCanceled_NoConnectionAttemptForCanceledRequests() [OuterLoop("Incurs significant delay")] [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Expect100Continue_WaitsExpectedPeriodOfTimeBeforeSendingContent() { await LoopbackServerFactory.CreateClientAndServerAsync(async uri => diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Http2FlowControl.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Http2FlowControl.cs index 4cee5beec976b4..4862c0a4ae52c5 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Http2FlowControl.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Http2FlowControl.cs @@ -30,7 +30,6 @@ public SocketsHttpHandler_Http2FlowControl_Test(ITestOutputHelper output) : base private static Http2Options NoAutoPingResponseHttp2Options => new Http2Options() { EnableTransparentPingResponse = false }; [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task InitialHttp2StreamWindowSize_SentInSettingsFrame() { const int WindowSize = 123456; @@ -50,7 +49,6 @@ public async Task InitialHttp2StreamWindowSize_SentInSettingsFrame() [Theory] [InlineData(0)] // Invalid PING payload [InlineData(1)] // Unexpected PING response - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public Task BadRttPingResponse_RequestShouldFail(int mode) { return Http2LoopbackServer.CreateClientAndServerAsync(async uri => @@ -86,7 +84,6 @@ public Task BadRttPingResponse_RequestShouldFail(int mode) [OuterLoop("Runs long")] [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task HighBandwidthDelayProduct_ClientStreamReceiveWindowWindowScalesUp() { int maxCredit = await TestClientWindowScalingAsync( @@ -100,8 +97,7 @@ public async Task HighBandwidthDelayProduct_ClientStreamReceiveWindowWindowScale } [OuterLoop("Runs long")] - [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] + [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] public void DisableDynamicWindowScaling_HighBandwidthDelayProduct_WindowRemainsConstant() { static async Task RunTest() @@ -121,8 +117,7 @@ static async Task RunTest() } [OuterLoop("Runs long")] - [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] + [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] public void MaxStreamWindowSize_WhenSet_WindowDoesNotScaleAboveMaximum() { const int MaxWindow = 654321; @@ -145,8 +140,7 @@ static async Task RunTest() } [OuterLoop("Runs long")] - [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] + [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] public void StreamWindowScaleThresholdMultiplier_HighValue_WindowScalesSlower() { static async Task RunTest() @@ -167,8 +161,7 @@ static async Task RunTest() } [OuterLoop("Runs long")] - [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] + [ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] public void StreamWindowScaleThresholdMultiplier_LowValue_WindowScalesFaster() { static async Task RunTest() diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Http2KeepAlivePing.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Http2KeepAlivePing.cs index b2af9384413eba..d735ad7d68f0c4 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Http2KeepAlivePing.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.Http2KeepAlivePing.cs @@ -40,18 +40,14 @@ public SocketsHttpHandler_Http2KeepAlivePing_Test(ITestOutputHelper output) : ba [OuterLoop("Runs long")] [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task KeepAlivePingDelay_Infinite_NoKeepAlivePingIsSent() { await Http2LoopbackServer.CreateClientAndServerAsync(async uri => { - SocketsHttpHandler handler = new SocketsHttpHandler() - { - KeepAlivePingTimeout = TimeSpan.FromSeconds(1), - KeepAlivePingPolicy = HttpKeepAlivePingPolicy.Always, - KeepAlivePingDelay = Timeout.InfiniteTimeSpan - }; - handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; + SocketsHttpHandler handler = CreateSocketsHttpHandler(allowAllCertificates: true); + handler.KeepAlivePingTimeout = TimeSpan.FromSeconds(1); + handler.KeepAlivePingPolicy = HttpKeepAlivePingPolicy.Always; + handler.KeepAlivePingDelay = Timeout.InfiniteTimeSpan; using HttpClient client = new HttpClient(handler); client.DefaultRequestVersion = HttpVersion.Version20; @@ -101,18 +97,14 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async uri => [Theory] [InlineData(HttpKeepAlivePingPolicy.Always)] [InlineData(HttpKeepAlivePingPolicy.WithActiveRequests)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task KeepAliveConfigured_KeepAlivePingsAreSentAccordingToPolicy(HttpKeepAlivePingPolicy policy) { await Http2LoopbackServer.CreateClientAndServerAsync(async uri => { - SocketsHttpHandler handler = new SocketsHttpHandler() - { - KeepAlivePingTimeout = TimeSpan.FromSeconds(10), - KeepAlivePingPolicy = policy, - KeepAlivePingDelay = TimeSpan.FromSeconds(1) - }; - handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; + SocketsHttpHandler handler = CreateSocketsHttpHandler(allowAllCertificates: true); + handler.KeepAlivePingTimeout = TimeSpan.FromSeconds(10); + handler.KeepAlivePingPolicy = policy; + handler.KeepAlivePingDelay = TimeSpan.FromSeconds(1); using HttpClient client = new HttpClient(handler); client.DefaultRequestVersion = HttpVersion.Version20; @@ -181,18 +173,14 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async uri => [OuterLoop("Runs long")] [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task KeepAliveConfigured_NoPingResponseDuringActiveStream_RequestShouldFail() { await Http2LoopbackServer.CreateClientAndServerAsync(async uri => { - SocketsHttpHandler handler = new SocketsHttpHandler() - { - KeepAlivePingTimeout = TimeSpan.FromSeconds(1.5), - KeepAlivePingPolicy = HttpKeepAlivePingPolicy.WithActiveRequests, - KeepAlivePingDelay = TimeSpan.FromSeconds(1) - }; - handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; + SocketsHttpHandler handler = CreateSocketsHttpHandler(allowAllCertificates: true); + handler.KeepAlivePingTimeout = TimeSpan.FromSeconds(1.5); + handler.KeepAlivePingPolicy = HttpKeepAlivePingPolicy.WithActiveRequests; + handler.KeepAlivePingDelay = TimeSpan.FromSeconds(1); using HttpClient client = new HttpClient(handler); client.DefaultRequestVersion = HttpVersion.Version20; @@ -232,18 +220,14 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async uri => [OuterLoop("Runs long")] [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task HttpKeepAlivePingPolicy_Always_NoPingResponseBetweenStreams_SecondRequestShouldFail() { await Http2LoopbackServer.CreateClientAndServerAsync(async uri => { - SocketsHttpHandler handler = new SocketsHttpHandler() - { - KeepAlivePingTimeout = TimeSpan.FromSeconds(1.5), - KeepAlivePingPolicy = HttpKeepAlivePingPolicy.Always, - KeepAlivePingDelay = TimeSpan.FromSeconds(1) - }; - handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; + SocketsHttpHandler handler = CreateSocketsHttpHandler(allowAllCertificates: true); + handler.KeepAlivePingTimeout = TimeSpan.FromSeconds(1.5); + handler.KeepAlivePingPolicy = HttpKeepAlivePingPolicy.Always; + handler.KeepAlivePingDelay = TimeSpan.FromSeconds(1); using HttpClient client = new HttpClient(handler); client.DefaultRequestVersion = HttpVersion.Version20; diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs index 21347f3901e5f9..ac9ba3c55f5b04 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.cs @@ -17,6 +17,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.DotNet.RemoteExecutor; +using Microsoft.DotNet.XUnitExtensions; using Xunit; using Xunit.Abstractions; @@ -890,7 +891,6 @@ public SocketsHttpHandler_Http2_TrailingHeaders_Test(ITestOutputHelper output) : protected override Version UseVersion => HttpVersion.Version20; [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2GetAsync_NoTrailingHeaders_EmptyCollection() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -919,7 +919,6 @@ public async Task Http2GetAsync_NoTrailingHeaders_EmptyCollection() [InlineData(false)] [InlineData(true)] [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2GetAsync_MissingTrailer_TrailingHeadersAccepted(bool responseHasContentLength) { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -956,7 +955,6 @@ public async Task Http2GetAsync_MissingTrailer_TrailingHeadersAccepted(bool resp } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2GetAsync_TrailerHeaders_TrailingPseudoHeadersThrow() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -981,7 +979,6 @@ public async Task Http2GetAsync_TrailerHeaders_TrailingPseudoHeadersThrow() [InlineData(false)] [InlineData(true)] [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2GetAsyncResponseHeadersReadOption_TrailingHeaders_Available(bool responseHasContentLength) { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -1033,7 +1030,6 @@ public async Task Http2GetAsyncResponseHeadersReadOption_TrailingHeaders_Availab } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2GetAsync_TrailerHeaders_TrailingHeaderNoBody() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -1058,7 +1054,6 @@ public async Task Http2GetAsync_TrailerHeaders_TrailingHeaderNoBody() } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2GetAsync_TrailingHeaders_NoData_EmptyResponseObserved() { using (Http2LoopbackServer server = Http2LoopbackServer.CreateServer()) @@ -1538,7 +1533,6 @@ await server.AcceptConnectionAsync(async connection2 => [Theory] [InlineData("PooledConnectionLifetime")] [InlineData("PooledConnectionIdleTimeout")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_SmallConnectionTimeout_SubsequentRequestUsesDifferentConnection(string timeoutPropertyName) { await Http2LoopbackServerFactory.CreateServerAsync(async (server, url) => @@ -1591,10 +1585,9 @@ public void ConnectionsPooledThenDisposed_NoUnobservedTaskExceptions(bool secure var releaseServer = new TaskCompletionSource(); await LoopbackServer.CreateClientAndServerAsync(async uri => { - using (var handler = new SocketsHttpHandler()) + using (var handler = CreateSocketsHttpHandler(allowAllCertificates: true)) using (HttpClient client = CreateHttpClient(handler, useVersionString)) { - handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; handler.PooledConnectionLifetime = TimeSpan.FromMilliseconds(1); var exceptions = new List(); @@ -1625,7 +1618,6 @@ await LoopbackServer.CreateClientAndServerAsync(async uri => [OuterLoop] [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public void HandlerDroppedWithoutDisposal_NotKeptAlive() { var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); @@ -2223,7 +2215,6 @@ public async Task Http2_MultipleConnectionsEnabled_ConnectionLimitNotReached_Con } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_MultipleConnectionsEnabled_ManyRequestsEnqueuedSimultaneously_SufficientConnectionsCreated() { // This is equal to Http2Connection.InitialMaxConcurrentStreams, which is the limit we impose before we have received the peer's initial SETTINGS frame. @@ -2317,9 +2308,13 @@ public async Task Http2_MultipleConnectionsEnabled_InfiniteRequestsCompletelyBlo } [ConditionalFact(nameof(SupportsAlpn))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_MultipleConnectionsEnabled_OpenAndCloseMultipleConnections_Success() { + if (PlatformDetection.IsAndroid && (PlatformDetection.IsX86Process || PlatformDetection.IsX64Process)) + { + throw new SkipTestException("Currently this test is failing on Android API 29 (used on Android-x64 and Android-x86 emulators)"); + } + const int MaxConcurrentStreams = 2; using Http2LoopbackServer server = Http2LoopbackServer.CreateServer(); using SocketsHttpHandler handler = CreateHandler(); @@ -2377,7 +2372,6 @@ public async Task Http2_MultipleConnectionsEnabled_OpenAndCloseMultipleConnectio [ConditionalFact(nameof(SupportsAlpn))] [OuterLoop("Incurs long delay")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task Http2_MultipleConnectionsEnabled_IdleConnectionTimeoutExpired_ConnectionRemovedAndNewCreated() { const int MaxConcurrentStreams = 2; @@ -2542,7 +2536,6 @@ public SocketsHttpHandlerTest_ConnectCallback(ITestOutputHelper output) : base(o [InlineData(false, true)] [InlineData(true, false)] [InlineData(true, true)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ConnectCallback_ContextHasCorrectProperties_Success(bool syncRequest, bool syncCallback) { if (syncRequest && UseVersion > HttpVersion.Version11) @@ -2564,8 +2557,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync( requestMessage.Version = UseVersion; requestMessage.VersionPolicy = HttpVersionPolicy.RequestVersionExact; - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.ConnectCallback = async (context, token) => { @@ -2602,7 +2594,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync( [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ConnectCallback_BindLocalAddress_Success(bool useSsl) { GenericLoopbackOptions options = new GenericLoopbackOptions() { UseSsl = useSsl }; @@ -2610,8 +2601,7 @@ public async Task ConnectCallback_BindLocalAddress_Success(bool useSsl) await LoopbackServerFactory.CreateClientAndServerAsync( async uri => { - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.ConnectCallback = async (context, token) => { @@ -2637,7 +2627,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync( [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ConnectCallback_UseMemoryBuffer_Success(bool useSsl) { (Stream clientStream, Stream serverStream) = ConnectedStreams.CreateBidirectional(); @@ -2657,8 +2646,7 @@ public async Task ConnectCallback_UseMemoryBuffer_Success(bool useSsl) Task clientTask = Task.Run(async () => { - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.ConnectCallback = (context, token) => new ValueTask(clientStream); @@ -2676,7 +2664,6 @@ public async Task ConnectCallback_UseMemoryBuffer_Success(bool useSsl) [ActiveIssue("https://github.com/dotnet/runtime/issues/44183", TestPlatforms.Windows)] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ConnectCallback_UseUnixDomainSocket_Success(bool useSsl) { GenericLoopbackOptions options = new GenericLoopbackOptions() { UseSsl = useSsl }; @@ -2687,8 +2674,7 @@ public async Task ConnectCallback_UseUnixDomainSocket_Success(bool useSsl) listenSocket.Bind(serverEP); listenSocket.Listen(); - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.ConnectCallback = async (context, token) => { @@ -2726,7 +2712,6 @@ public async Task ConnectCallback_UseUnixDomainSocket_Success(bool useSsl) [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ConnectCallback_ConnectionPrefix_Success(bool useSsl) { GenericLoopbackOptions options = new GenericLoopbackOptions() { UseSsl = useSsl }; @@ -2738,8 +2723,7 @@ public async Task ConnectCallback_ConnectionPrefix_Success(bool useSsl) listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, 0)); listenSocket.Listen(); - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: useSsl); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.ConnectCallback = async (context, token) => { @@ -2792,8 +2776,7 @@ public async Task ConnectCallback_StreamThrowsOnWrite_ExceptionAndStreamDisposed bool disposeCalled = false; - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: useSsl); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.ConnectCallback = (context, token) => { @@ -2819,8 +2802,7 @@ public async Task ConnectCallback_ExceptionDuringCallback_ThrowsHttpRequestExcep { Exception e = new Exception("hello!"); - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: useSsl); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.ConnectCallback = (context, token) => { @@ -2839,8 +2821,7 @@ public async Task ConnectCallback_ExceptionDuringCallback_ThrowsHttpRequestExcep [InlineData(false)] public async Task ConnectCallback_ReturnsNull_ThrowsHttpRequestException(bool useSsl) { - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: useSsl); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.ConnectCallback = (context, token) => { @@ -2856,15 +2837,13 @@ public async Task ConnectCallback_ReturnsNull_ThrowsHttpRequestException(bool us [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindows7))] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ConnectCallback_SslStream_OK(bool useSslStream) { await LoopbackServerFactory.CreateClientAndServerAsync( async uri => { string[] parts = uri.Authority.Split(':', 2); - HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; + HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.ConnectCallback = async (context, token) => { @@ -2905,7 +2884,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync( } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindows7))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ConnectCallback_DerivedSslStream_OK() { await LoopbackServerFactory.CreateClientAndServerAsync( @@ -2950,7 +2928,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync( } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ConnectCallback_NoAlpn_OK() { // Create HTTP 1.1 loopback. Http2 should downgrade @@ -3129,8 +3106,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync( requestMessage.Version = UseVersion; requestMessage.VersionPolicy = HttpVersionPolicy.RequestVersionExact; - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.PlaintextStreamFilter = async (context, token) => { @@ -3161,15 +3137,13 @@ await LoopbackServerFactory.CreateClientAndServerAsync( [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PlaintextStreamFilter_SimpleDelegatingStream_Success(bool useSsl) { GenericLoopbackOptions options = new GenericLoopbackOptions() { UseSsl = useSsl }; await LoopbackServerFactory.CreateClientAndServerAsync( async uri => { - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.PlaintextStreamFilter = (context, token) => { @@ -3205,7 +3179,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync( [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PlaintextStreamFilter_ConnectionPrefix_Success(bool useSsl) { byte[] RequestPrefix = "request prefix\r\n"u8.ToArray(); @@ -3217,8 +3190,7 @@ public async Task PlaintextStreamFilter_ConnectionPrefix_Success(bool useSsl) Task clientTask = Task.Run(async () => { - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.PlaintextStreamFilter = async (context, token) => { @@ -3286,7 +3258,6 @@ public async Task PlaintextStreamFilter_ConnectionPrefix_Success(bool useSsl) [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PlaintextStreamFilter_ExceptionDuringCallback_ThrowsHttpRequestExceptionWithInnerException(bool useSsl) { Exception e = new Exception("hello!"); @@ -3299,8 +3270,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync( requestMessage.Version = UseVersion; requestMessage.VersionPolicy = HttpVersionPolicy.RequestVersionExact; - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.PlaintextStreamFilter = (context, token) => { @@ -3328,7 +3298,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync( [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PlaintextStreamFilter_ReturnsNull_ThrowsHttpRequestException(bool useSsl) { GenericLoopbackOptions options = new GenericLoopbackOptions() { UseSsl = useSsl }; @@ -3339,8 +3308,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync( requestMessage.Version = UseVersion; requestMessage.VersionPolicy = HttpVersionPolicy.RequestVersionExact; - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.PlaintextStreamFilter = (context, token) => { @@ -3373,15 +3341,13 @@ public SocketsHttpHandlerTest_PlaintextStreamFilter_Http11(ITestOutputHelper out [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PlaintextStreamFilter_CustomStream_Success(bool useSsl) { GenericLoopbackOptions options = new GenericLoopbackOptions() { UseSsl = useSsl }; await LoopbackServerFactory.CreateClientAndServerAsync( async uri => { - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.PlaintextStreamFilter = (context, token) => { @@ -3421,7 +3387,6 @@ await LoopbackServerFactory.CreateClientAndServerAsync( [Theory] [InlineData(false)] [InlineData(true)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task PlaintextStreamFilter_Logging_Success(bool useSsl) { bool log = int.TryParse(Environment.GetEnvironmentVariable("DOTNET_TEST_SOCKETSHTTPHANDLERLOG"), out int value) && value == 1; @@ -3433,8 +3398,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync( string sendText = ""; string recvText = ""; - using HttpClientHandler handler = CreateHttpClientHandler(); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); var socketsHandler = (SocketsHttpHandler)GetUnderlyingSocketsHttpHandler(handler); socketsHandler.PlaintextStreamFilter = (context, token) => { @@ -3663,7 +3627,6 @@ public SocketsHttpHandler_RequestContentLengthMismatchTest(ITestOutputHelper out [InlineData(1, 0)] [InlineData(1, 2)] [InlineData(2, 1)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task ContentLength_DoesNotMatchRequestContentLength_Throws(int contentLength, int bytesSent) { await LoopbackServerFactory.CreateClientAndServerAsync(async uri => diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/SocksProxyTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/SocksProxyTest.cs index 67a6d5451d9d1c..b7e6995f999809 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/SocksProxyTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/SocksProxyTest.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Net.Test.Common; using System.Threading.Tasks; +using Microsoft.DotNet.XUnitExtensions; using Xunit; using Xunit.Abstractions; @@ -25,9 +26,8 @@ from useAuth in BoolValues from host in Hosts(scheme) select new object[] { scheme, useSsl, useAuth, host }; - [Theory] + [ConditionalTheory] [MemberData(nameof(TestLoopbackAsync_MemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Android)] public async Task TestLoopbackAsync(string scheme, bool useSsl, bool useAuth, string host) { if (useSsl && UseVersion == HttpVersion.Version20 && !PlatformDetection.SupportsAlpn) @@ -35,15 +35,19 @@ public async Task TestLoopbackAsync(string scheme, bool useSsl, bool useAuth, st return; } + if (PlatformDetection.IsAndroid && useSsl && host == "::1") + { + throw new SkipTestException("IPv6 loopback with SSL doesn't work on Android"); + } + await LoopbackServerFactory.CreateClientAndServerAsync( async uri => { await using var proxy = useAuth ? new LoopbackSocksServer("DOTNET", "424242") : new LoopbackSocksServer(); - using HttpClientHandler handler = CreateHttpClientHandler(); + using HttpClientHandler handler = CreateHttpClientHandler(allowAllCertificates: true); using HttpClient client = CreateHttpClient(handler); handler.Proxy = new WebProxy($"{scheme}://127.0.0.1:{proxy.Port}"); - handler.ServerCertificateCustomValidationCallback = TestHelper.AllowAllCertificates; if (useAuth) { 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 3f45782c7f14da..57b3d2065fce4d 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 @@ -7,6 +7,8 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX true true + + true diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/TelemetryTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/TelemetryTest.cs index f4458d3a276ced..38785e38f45591 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/TelemetryTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/TelemetryTest.cs @@ -626,12 +626,11 @@ await listener.RunWithCallbackAsync(e => events.Enqueue((e, e.ActivityId)), asyn await GetFactoryForVersion(version).CreateClientAndServerAsync( async uri => { - using HttpClientHandler handler = CreateHttpClientHandler(version); + using HttpClientHandler handler = CreateHttpClientHandler(version, allowAllCertificates: true); using HttpClient client = CreateHttpClient(handler, useVersionString); var socketsHttpHandler = GetUnderlyingSocketsHttpHandler(handler); socketsHttpHandler.MaxConnectionsPerServer = 1; - socketsHttpHandler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; // Dummy request to establish connection and ensure that the MaxConcurrentStreams setting has been acknowledged await client.GetStringAsync(uri); diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/StressClient.cs b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/StressClient.cs index 76176390615a01..624d19e3e64966 100644 --- a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/StressClient.cs +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/StressClient.cs @@ -54,14 +54,9 @@ HttpMessageHandler CreateHttpHandler() } else { - return new SocketsHttpHandler() - { - PooledConnectionLifetime = _config.ConnectionLifetime.GetValueOrDefault(Timeout.InfiniteTimeSpan), - SslOptions = new SslClientAuthenticationOptions - { - RemoteCertificateValidationCallback = delegate { return true; } - } - }; + SocketsHttpHandler handler = CreateSocketsHttpHandler(allowAllCertificates: true); + handler.PooledConnectionLifetime = _config.ConnectionLifetime.GetValueOrDefault(Timeout.InfiniteTimeSpan); + return handler; } } diff --git a/src/libraries/System.Net.Requests/tests/FileWebRequestTest.cs b/src/libraries/System.Net.Requests/tests/FileWebRequestTest.cs index 94e0303fd9cc86..0212efc57dd382 100644 --- a/src/libraries/System.Net.Requests/tests/FileWebRequestTest.cs +++ b/src/libraries/System.Net.Requests/tests/FileWebRequestTest.cs @@ -88,7 +88,6 @@ public abstract class FileWebRequestTestBase public abstract Task GetRequestStreamAsync(WebRequest request); [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public async Task ReadFile_ContainsExpectedContent() { string path = Path.GetTempFileName(); @@ -126,7 +125,6 @@ public async Task ReadFile_ContainsExpectedContent() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public async Task WriteFile_ContainsExpectedContent() { string path = Path.GetTempFileName(); @@ -153,7 +151,6 @@ public async Task WriteFile_ContainsExpectedContent() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public async Task WriteThenReadFile_WriteAccessResultsInNullResponseStream() { string path = Path.GetTempFileName(); @@ -186,7 +183,6 @@ public async Task WriteThenReadFile_WriteAccessResultsInNullResponseStream() protected virtual bool EnableConcurrentReadWriteTests => true; [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public async Task RequestAfterResponse_throws() { string path = Path.GetTempFileName(); diff --git a/src/libraries/System.Net.Requests/tests/HttpWebRequestTest.cs b/src/libraries/System.Net.Requests/tests/HttpWebRequestTest.cs index c54fe136cef073..397520164eb56b 100644 --- a/src/libraries/System.Net.Requests/tests/HttpWebRequestTest.cs +++ b/src/libraries/System.Net.Requests/tests/HttpWebRequestTest.cs @@ -326,7 +326,6 @@ public void AllowReadStreamBuffering_SetTrueThenGet_ExpectTrue(Uri remoteServer) [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public async Task ContentLength_Get_ExpectSameAsGetResponseStream(bool useSsl) { var options = new LoopbackServer.Options { UseSsl = useSsl }; @@ -1367,7 +1366,6 @@ await LoopbackServer.CreateClientAndServerAsync(async uri => [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public async Task GetResponseAsync_GetResponseStream_ContainsHost(bool useSsl) { var options = new LoopbackServer.Options { UseSsl = useSsl }; @@ -1414,7 +1412,6 @@ public void Range_Add_Success(Uri remoteServer) [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public async Task GetResponseAsync_PostRequestStream_ContainsData(bool useSsl) { var options = new LoopbackServer.Options { UseSsl = useSsl }; @@ -1460,7 +1457,6 @@ await LoopbackServer.CreateClientAndServerAsync(async uri => [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] [ActiveIssue("https://github.com/dotnet/runtime/issues/56798", TestPlatforms.tvOS)] public async Task GetResponseAsync_UseDefaultCredentials_ExpectSuccess(bool useSsl) { @@ -1501,7 +1497,6 @@ await LoopbackServer.CreateClientAndServerAsync(async uri => [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] [ActiveIssue("https://github.com/dotnet/runtime/issues/56798", TestPlatforms.tvOS)] public async Task HaveResponse_GetResponseAsync_ExpectTrue(bool useSsl) { @@ -1521,7 +1516,6 @@ await LoopbackServer.CreateClientAndServerAsync(async uri => [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public async Task Headers_GetResponseHeaders_ContainsExpectedValue(bool useSsl) { var options = new LoopbackServer.Options { UseSsl = useSsl }; @@ -1621,7 +1615,6 @@ public void RequestUri_CreateHttpThenGet_ExpectSameUri(Uri remoteServer) [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public async Task ResponseUri_GetResponseAsync_ExpectSameUri(bool useSsl) { var options = new LoopbackServer.Options { UseSsl = useSsl }; @@ -1645,7 +1638,6 @@ public void SupportsCookieContainer_GetDefault_ExpectTrue(Uri remoteServer) [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public async Task SimpleScenario_UseGETVerb_Success(bool useSsl) { var options = new LoopbackServer.Options { UseSsl = useSsl }; @@ -1662,7 +1654,6 @@ await LoopbackServer.CreateClientAndServerAsync(async uri => [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public async Task SimpleScenario_UsePOSTVerb_Success(bool useSsl) { var options = new LoopbackServer.Options { UseSsl = useSsl }; @@ -1685,7 +1676,6 @@ await LoopbackServer.CreateClientAndServerAsync(async uri => [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public async Task ContentType_AddHeaderWithNoContent_SendRequest_HeaderGetsSent(bool useSsl) { const string ContentType = "text/plain; charset=utf-8"; diff --git a/src/libraries/System.Net.Requests/tests/LoggingTest.cs b/src/libraries/System.Net.Requests/tests/LoggingTest.cs index 4a508a1f8b9cb6..892fb0b0399ac4 100644 --- a/src/libraries/System.Net.Requests/tests/LoggingTest.cs +++ b/src/libraries/System.Net.Requests/tests/LoggingTest.cs @@ -10,7 +10,6 @@ public class LoggingTest { [Fact] [SkipOnCoreClr("System.Net.Tests are flaky", ~RuntimeConfiguration.Release)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37087", TestPlatforms.Android)] public void EventSource_ExistsWithCorrectId() { Type esType = typeof(WebRequest).Assembly.GetType("System.Net.NetEventSource", throwOnError: true, ignoreCase: false); diff --git a/src/libraries/System.Net.Requests/tests/System.Net.Requests.Tests.csproj b/src/libraries/System.Net.Requests/tests/System.Net.Requests.Tests.csproj index f8ee055fa994e2..868d3582b442a1 100644 --- a/src/libraries/System.Net.Requests/tests/System.Net.Requests.Tests.csproj +++ b/src/libraries/System.Net.Requests/tests/System.Net.Requests.Tests.csproj @@ -7,6 +7,8 @@ true $(NoWarn);SYSLIB0014 + + true diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/CertificateValidationClientServer.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/CertificateValidationClientServer.cs index 06fc46b1f087c6..494bcf86fc226b 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/CertificateValidationClientServer.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/CertificateValidationClientServer.cs @@ -108,7 +108,6 @@ await TestConfiguration.WhenAllOrAnyFailedWithTimeout( [Theory] [InlineData(false)] [InlineData(true)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task CertificateValidationClientServer_EndToEnd_Ok(bool useClientSelectionCallback) { IPEndPoint endPoint = new IPEndPoint(IPAddress.Loopback, 0); diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/CertificateValidationRemoteServer.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/CertificateValidationRemoteServer.cs index 148dad9c29d7f2..4d32189528778c 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/CertificateValidationRemoteServer.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/CertificateValidationRemoteServer.cs @@ -94,7 +94,7 @@ public async Task DefaultConnect_EndToEnd_Ok(string host) [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] + [SkipOnPlatform(TestPlatforms.Android, "The invalid certificate is rejected by Android and the .NET validation code isn't reached")] public Task ConnectWithRevocation_WithCallback(bool checkRevocation) { X509RevocationMode mode = checkRevocation ? X509RevocationMode.Online : X509RevocationMode.NoCheck; diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/ClientAsyncAuthenticateTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/ClientAsyncAuthenticateTest.cs index 8bd61c714c3a56..73c102d51e953a 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/ClientAsyncAuthenticateTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/ClientAsyncAuthenticateTest.cs @@ -22,14 +22,12 @@ public ClientAsyncAuthenticateTest(ITestOutputHelper output) } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ClientAsyncAuthenticate_ServerRequireEncryption_ConnectWithEncryption() { await ClientAsyncSslHelper(EncryptionPolicy.RequireEncryption); } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ClientAsyncAuthenticate_ConnectionInfoInCallback_DoesNotThrow() { await ClientAsyncSslHelper(EncryptionPolicy.RequireEncryption, SslProtocols.Tls12, SslProtocolSupport.DefaultSslProtocols, AllowAnyServerCertificateAndVerifyConnectionInfo); @@ -51,7 +49,6 @@ await Assert.ThrowsAsync( [Theory] [ClassData(typeof(SslProtocolSupport.SupportedSslProtocolsTestData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ClientAsyncAuthenticate_EachSupportedProtocol_Success(SslProtocols protocol) { await ClientAsyncSslHelper(protocol, protocol); @@ -70,7 +67,6 @@ public async Task ClientAsyncAuthenticate_MismatchProtocols_Fails( } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ClientAsyncAuthenticate_AllServerAllClient_Success() { await ClientAsyncSslHelper( @@ -80,7 +76,6 @@ await ClientAsyncSslHelper( [Theory] [ClassData(typeof(SslProtocolSupport.SupportedSslProtocolsTestData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ClientAsyncAuthenticate_AllServerVsIndividualClientSupportedProtocols_Success( SslProtocols clientProtocol) { @@ -89,7 +84,6 @@ public async Task ClientAsyncAuthenticate_AllServerVsIndividualClientSupportedPr [Theory] [ClassData(typeof(SslProtocolSupport.SupportedSslProtocolsTestData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ClientAsyncAuthenticate_IndividualServerVsAllClientSupportedProtocols_Success( SslProtocols serverProtocol) { diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/ClientDefaultEncryptionTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/ClientDefaultEncryptionTest.cs index 9c0cb1446f33c4..6059ec3477184a 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/ClientDefaultEncryptionTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/ClientDefaultEncryptionTest.cs @@ -21,7 +21,6 @@ public ClientDefaultEncryptionTest(ITestOutputHelper output) } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ClientDefaultEncryption_ServerRequireEncryption_ConnectWithEncryption() { (NetworkStream clientStream, NetworkStream serverStream) = TestHelper.GetConnectedTcpStreams(); @@ -44,7 +43,6 @@ await TestConfiguration.WhenAllOrAnyFailedWithTimeout( } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ClientDefaultEncryption_ServerAllowNoEncryption_ConnectWithEncryption() { (NetworkStream clientStream, NetworkStream serverStream) = TestHelper.GetConnectedTcpStreams(); diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/ServerAllowNoEncryptionTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/ServerAllowNoEncryptionTest.cs index d8111a762ad3f6..dea9fbe963f9b1 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/ServerAllowNoEncryptionTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/ServerAllowNoEncryptionTest.cs @@ -20,7 +20,6 @@ public ServerAllowNoEncryptionTest(ITestOutputHelper output) } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ServerAllowNoEncryption_ClientRequireEncryption_ConnectWithEncryption() { (NetworkStream clientStream, NetworkStream serverStream) = TestHelper.GetConnectedTcpStreams(); @@ -45,7 +44,6 @@ await TestConfiguration.WhenAllOrAnyFailedWithTimeout( } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ServerAllowNoEncryption_ClientAllowNoEncryption_ConnectWithEncryption() { (NetworkStream clientStream, NetworkStream serverStream) = TestHelper.GetConnectedTcpStreams(); diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/ServerAsyncAuthenticateTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/ServerAsyncAuthenticateTest.cs index 2bd9da2c24c061..3ba7978bde1eb5 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/ServerAsyncAuthenticateTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/ServerAsyncAuthenticateTest.cs @@ -38,19 +38,17 @@ public void Dispose() [Theory] [ClassData(typeof(SslProtocolSupport.SupportedSslProtocolsTestData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ServerAsyncAuthenticate_EachSupportedProtocol_Success(SslProtocols protocol) { await ServerAsyncSslHelper(protocol, protocol); } [Theory] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] [MemberData(nameof(ProtocolMismatchData))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ServerAsyncAuthenticate_MismatchProtocols_Fails( SslProtocols clientProtocol, - SslProtocols serverProtocol, - Type expectedException) + SslProtocols serverProtocol) { Exception e = await Record.ExceptionAsync( () => @@ -62,12 +60,11 @@ public async Task ServerAsyncAuthenticate_MismatchProtocols_Fails( }); Assert.NotNull(e); - Assert.IsAssignableFrom(expectedException, e); + Assert.IsType(e); } [Theory] [ClassData(typeof(SslProtocolSupport.SupportedSslProtocolsTestData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ServerAsyncAuthenticate_AllClientVsIndividualServerSupportedProtocols_Success( SslProtocols serverProtocol) { @@ -75,7 +72,6 @@ public async Task ServerAsyncAuthenticate_AllClientVsIndividualServerSupportedPr } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ServerAsyncAuthenticate_SimpleSniOptions_Success() { var state = new object(); @@ -104,7 +100,6 @@ public async Task ServerAsyncAuthenticate_SimpleSniOptions_Success() [Theory] [MemberData(nameof(SupportedProtocolData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ServerAsyncAuthenticate_SniSetVersion_Success(SslProtocols version) { var serverOptions = new SslServerAuthenticationOptions() { ServerCertificate = _serverCertificate, EnabledSslProtocols = version }; @@ -146,7 +141,6 @@ private async Task OptionsTask(SslServerAuthenti } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ServerAsyncAuthenticate_AsyncOptions_Success() { var state = new object(); @@ -203,7 +197,6 @@ public async Task ServerAsyncAuthenticate_FailingOptionCallback_Throws(bool useA } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ServerAsyncAuthenticate_VerificationDelegate_Success() { bool validationCallbackCalled = false; @@ -236,7 +229,6 @@ public async Task ServerAsyncAuthenticate_VerificationDelegate_Success() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ServerAsyncAuthenticate_ConstructorVerificationDelegate_Success() { bool validationCallbackCalled = false; @@ -344,7 +336,7 @@ public static IEnumerable ProtocolMismatchData() if (clientProtocol != serverProtocol) { - yield return new object[] { clientProtocol, serverProtocol, typeof(AuthenticationException) }; + yield return new object[] { clientProtocol, serverProtocol }; } } } diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/ServerRequireEncryptionTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/ServerRequireEncryptionTest.cs index faed579afb5d30..992cafcc581f1e 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/ServerRequireEncryptionTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/ServerRequireEncryptionTest.cs @@ -21,7 +21,6 @@ public ServerRequireEncryptionTest(ITestOutputHelper output) } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ServerRequireEncryption_ClientRequireEncryption_ConnectWithEncryption() { (NetworkStream clientStream, NetworkStream serverStream) = TestHelper.GetConnectedTcpStreams(); @@ -44,7 +43,6 @@ await TestConfiguration.WhenAllOrAnyFailedWithTimeout( } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ServerRequireEncryption_ClientAllowNoEncryption_ConnectWithEncryption() { (NetworkStream clientStream, NetworkStream serverStream) = TestHelper.GetConnectedTcpStreams(); diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslAuthenticationOptionsTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslAuthenticationOptionsTest.cs index 1dfff2f06b6c37..0029de46bfc3b2 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslAuthenticationOptionsTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslAuthenticationOptionsTest.cs @@ -19,7 +19,6 @@ public abstract class SslClientAuthenticationOptionsTestBase protected abstract bool TestAuthenticateAsync { get; } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ClientOptions_ServerOptions_NotMutatedDuringAuthentication() { using (X509Certificate2 clientCert = Configuration.Certificates.GetClientCertificate()) @@ -122,7 +121,6 @@ public async Task ClientOptions_ServerOptions_NotMutatedDuringAuthentication() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ClientOptions_TargetHostNull_OK() { (SslStream client, SslStream server) = TestHelper.GetConnectedSslStreams(); diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamAlpnTests.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamAlpnTests.cs index b242a5c5d6b9d4..8b0e9ab6165ffb 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamAlpnTests.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamAlpnTests.cs @@ -104,7 +104,6 @@ public async Task SslStream_StreamToStream_DuplicateOptions_Throws() [Theory] [MemberData(nameof(Alpn_TestData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task SslStream_StreamToStream_Alpn_Success(List clientProtocols, List serverProtocols, SslApplicationProtocol expected) { (Stream clientStream, Stream serverStream) = TestHelper.GetConnectedStreams(); diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamConformanceTests.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamConformanceTests.cs index 1e12db5ab299fa..6b47328446b7a8 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamConformanceTests.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamConformanceTests.cs @@ -49,7 +49,6 @@ await new[] } } - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public sealed class SslStreamMemoryConformanceTests : SslStreamConformanceTests { protected override Task CreateConnectedStreamsAsync() => @@ -65,7 +64,6 @@ protected override Task CreateConnectedStreamsAsync() => } [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.SupportsTls11))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public sealed class SslStreamTls11NetworkConformanceTests : SslStreamDefaultNetworkConformanceTests { #pragma warning disable SYSLIB0039 // TLS 1.0 and 1.1 are obsolete @@ -74,14 +72,12 @@ public sealed class SslStreamTls11NetworkConformanceTests : SslStreamDefaultNetw } [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.SupportsTls12))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public sealed class SslStreamTls12NetworkConformanceTests : SslStreamDefaultNetworkConformanceTests { protected override SslProtocols GetSslProtocols() => SslProtocols.Tls12; } [ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.SupportsTls13))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public sealed class SslStreamTls13NetworkConformanceTests : SslStreamDefaultNetworkConformanceTests { protected override SslProtocols GetSslProtocols() => SslProtocols.Tls13; diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamMutualAuthenticationTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamMutualAuthenticationTest.cs index 50977429946e2d..2332a00e1779c2 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamMutualAuthenticationTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamMutualAuthenticationTest.cs @@ -34,7 +34,6 @@ public void Dispose() [InlineData(false, true)] [InlineData(true, false)] [InlineData(true, true)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task SslStream_RequireClientCert_IsMutuallyAuthenticated_ReturnsTrue(bool clientCertificateRequired, bool useClientSelectionCallback) { (Stream stream1, Stream stream2) = TestHelper.GetConnectedStreams(); diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNegotiatedCipherSuiteTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNegotiatedCipherSuiteTest.cs index a1d9eae6b89784..07c92297fda148 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNegotiatedCipherSuiteTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNegotiatedCipherSuiteTest.cs @@ -51,6 +51,10 @@ public class NegotiatedCipherSuiteTest private static Lazy s_cipherSuitePolicySupported = new Lazy(() => { + // see src/libraries/System.Net.Security/src/System/Net/Security/Pal.Android/SafeDeleteSslContext.cs:InitializeSslContext + if (PlatformDetection.IsAndroid) + return false; + try { new CipherSuitesPolicy(Array.Empty()); @@ -69,7 +73,6 @@ public void Tls13IsSupported_GetValue_ReturnsTrue() } [ConditionalFact(nameof(Tls13Supported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public void NegotiatedCipherSuite_SslProtocolIsTls13_ShouldBeTls13() { var p = new ConnectionParams() @@ -91,7 +94,6 @@ public void NegotiatedCipherSuite_SslProtocolIsTls13_ShouldBeTls13() [InlineData(SslProtocols.Tls11)] #pragma warning restore SYSLIB0039 [InlineData(SslProtocols.Tls12)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public void NegotiatedCipherSuite_SslProtocolIsLowerThanTls13_ShouldMatchTheProtocol(SslProtocols protocol) { var p = new ConnectionParams() @@ -156,7 +158,6 @@ public void CipherSuitesPolicy_NothingAllowed_Fails() } [ConditionalFact(nameof(CipherSuitesPolicyAndTls13Supported))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public void CipherSuitesPolicy_AllowOneOnOneSideTls13_Success() { bool hasSucceededAtLeastOnce = false; diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs index fde7825a84d97f..de14becd9524df 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamNetworkStreamTest.cs @@ -497,9 +497,9 @@ await TestConfiguration.WhenAllOrAnyFailedWithTimeout( } [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.SupportsTls13))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] [InlineData(true)] [InlineData(false)] + [SkipOnPlatform(TestPlatforms.Android, "SslStream Renegotiate is not supported in SslStream on Android")] public async Task SslStream_NegotiateClientCertificateAsyncTls13_Succeeds(bool sendClientCertificate) { bool negotiateClientCertificateCalled = false; @@ -753,7 +753,7 @@ await TestConfiguration.WhenAllOrAnyFailedWithTimeout( [Theory] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] + [SkipOnPlatform(TestPlatforms.Android, "Self-signed certificates are rejected by Android before the .NET validation is reached")] public async Task SslStream_UntrustedCaWithCustomTrust_OK(bool usePartialChain) { int split = Random.Shared.Next(0, certificates.serverChain.Count - 1); @@ -807,7 +807,7 @@ public async Task SslStream_UntrustedCaWithCustomTrust_OK(bool usePartialChain) [PlatformSpecific(TestPlatforms.AnyUnix)] [InlineData(true)] [InlineData(false)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] + [SkipOnPlatform(TestPlatforms.Android, "Self-signed certificates are rejected by Android before the .NET validation is reached")] public async Task SslStream_UntrustedCaWithCustomCallback_Throws(bool customCallback) { string errorMessage; @@ -854,7 +854,7 @@ public async Task SslStream_UntrustedCaWithCustomCallback_Throws(bool customCall } [ConditionalFact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] + [SkipOnPlatform(TestPlatforms.Android, "Self-signed certificates are rejected by Android before the .NET validation is reached")] public async Task SslStream_ClientCertificate_SendsChain() { List streams = new List(); @@ -938,7 +938,6 @@ public async Task SslStream_ClientCertificate_SendsChain() [InlineData(16384 * 100, 4096, 1024, true)] [InlineData(16384 * 100, 1024 * 20, 1024, true)] [InlineData(16384, 3, 3, true)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task SslStream_RandomSizeWrites_OK(int bufferSize, int readBufferSize, int writeBufferSize, bool useAsync) { byte[] dataToCopy = RandomNumberGenerator.GetBytes(bufferSize); diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSniTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSniTest.cs index 944ab95699cce6..9d4aa07ff92991 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSniTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSniTest.cs @@ -18,7 +18,7 @@ public class SslStreamSniTest { [Theory] [MemberData(nameof(HostNameData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] + [SkipOnPlatform(TestPlatforms.Android, "Host name is not sent on Android")] public async Task SslStream_ClientSendsSNIServerReceives_Ok(string hostName) { using X509Certificate serverCert = Configuration.Certificates.GetSelfSignedServerCertificate(); @@ -96,7 +96,7 @@ public async Task SslStream_ServerCallbackAndLocalCertificateSelectionSet_Throws [Theory] [MemberData(nameof(HostNameData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] + [SkipOnPlatform(TestPlatforms.Android, "TODO: this test would work with GetServerCertificate(). Is there something wrong with the PEMs?")] public async Task SslStream_ServerCallbackNotSet_UsesLocalCertificateSelection(string hostName) { using X509Certificate serverCert = Configuration.Certificates.GetSelfSignedServerCertificate(); diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamStreamToStreamTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamStreamToStreamTest.cs index c19510340a3c11..8704cfb77ec671 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamStreamToStreamTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamStreamToStreamTest.cs @@ -70,7 +70,6 @@ public static IEnumerable SslStream_StreamToStream_Authentication_Succ [ConditionalTheory] [MemberData(nameof(SslStream_StreamToStream_Authentication_Success_MemberData))] [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "X509 certificate store is not supported on iOS or tvOS.")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task SslStream_StreamToStream_Authentication_Success(X509Certificate serverCert = null, X509Certificate clientCert = null) { (Stream stream1, Stream stream2) = TestHelper.GetConnectedStreams(); @@ -87,7 +86,6 @@ public async Task SslStream_StreamToStream_Authentication_Success(X509Certificat } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task SslStream_StreamToStream_Authentication_IncorrectServerName_Fail() { (Stream stream1, Stream stream2) = TestHelper.GetConnectedStreams(); @@ -131,7 +129,6 @@ await TestConfiguration.WhenAllOrAnyFailedWithTimeout(client.AuthenticateAsClien [Fact] [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "X509 certificate store is not supported on iOS or tvOS.")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task Read_CorrectlyUnlocksAfterFailure() { (Stream stream1, Stream stream2) = TestHelper.GetConnectedStreams(); @@ -160,7 +157,6 @@ public async Task Read_CorrectlyUnlocksAfterFailure() [Fact] [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "X509 certificate store is not supported on iOS or tvOS.")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task Write_CorrectlyUnlocksAfterFailure() { (Stream stream1, Stream stream2) = TestHelper.GetConnectedStreams(); @@ -185,7 +181,6 @@ public async Task Write_CorrectlyUnlocksAfterFailure() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task Read_InvokedSynchronously() { (Stream stream1, Stream stream2) = TestHelper.GetConnectedStreams(); @@ -211,7 +206,6 @@ public async Task Read_InvokedSynchronously() [Fact] [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.tvOS, "X509 certificate store is not supported on iOS or tvOS.")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task Write_InvokedSynchronously() { (Stream stream1, Stream stream2) = TestHelper.GetConnectedStreams(); @@ -236,7 +230,6 @@ public async Task Write_InvokedSynchronously() [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task SslStream_StreamToStream_Dispose_Throws() { if (this is SslStreamStreamToStreamTest_SyncBase) @@ -289,7 +282,6 @@ public async Task SslStream_StreamToStream_Dispose_Throws() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task SslStream_StreamToStream_EOFDuringFrameRead_ThrowsIOException() { (Stream clientStream, Stream serverStream) = TestHelper.GetConnectedStreams(); diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSystemDefaultsTest.cs b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSystemDefaultsTest.cs index d7c90164c45ef7..51b28f5b26f60c 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSystemDefaultsTest.cs +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/SslStreamSystemDefaultsTest.cs @@ -76,7 +76,6 @@ public static IEnumerable OneOrBothUseDefaulData() [ConditionalTheory] [MemberData(nameof(OneOrBothUseDefaulData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/68206", TestPlatforms.Android)] public async Task ClientAndServer_OneOrBothUseDefault_Ok(SslProtocols? clientProtocols, SslProtocols? serverProtocols) { using (X509Certificate2 serverCertificate = Configuration.Certificates.GetServerCertificate()) diff --git a/src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj b/src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj index 2797de562e9025..36f81014ccf92b 100644 --- a/src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj +++ b/src/libraries/System.Net.Security/tests/FunctionalTests/System.Net.Security.Tests.csproj @@ -5,6 +5,8 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS true true + + true diff --git a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.Http2.cs b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.Http2.cs index 23d260c87e2ffe..241063ab891b20 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.Http2.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.Http2.cs @@ -11,6 +11,8 @@ using Xunit; using Xunit.Abstractions; +using static System.Net.Http.Functional.Tests.TestHelper; + namespace System.Net.WebSockets.Client.Tests { public class ConnectTest_Http2 : ClientWebSocketTestBase @@ -18,7 +20,7 @@ public class ConnectTest_Http2 : ClientWebSocketTestBase public ConnectTest_Http2(ITestOutputHelper output) : base(output) { } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Browser)] + [SkipOnPlatform(TestPlatforms.Browser, "Self-signed certificates are not supported on browser")] public async Task ConnectAsync_VersionNotSupported_Throws() { await Http2LoopbackServer.CreateClientAndServerAsync(async uri => @@ -28,8 +30,7 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async uri => { clientSocket.Options.HttpVersion = HttpVersion.Version20; clientSocket.Options.HttpVersionPolicy = Http.HttpVersionPolicy.RequestVersionExact; - using var handler = new SocketsHttpHandler(); - handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; + using var handler = CreateSocketsHttpHandler(allowAllCertificates: true); Task t = clientSocket.ConnectAsync(uri, new HttpMessageInvoker(handler), cts.Token); var ex = await Assert.ThrowsAnyAsync(() => t); Assert.IsType(ex.InnerException); @@ -44,7 +45,7 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async uri => } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/69870", TestPlatforms.Browser)] + [SkipOnPlatform(TestPlatforms.Browser, "Self-signed certificates are not supported on browser")] public async Task ConnectAsync_VersionSupported_Success() { await Http2LoopbackServer.CreateClientAndServerAsync(async uri => @@ -54,8 +55,7 @@ await Http2LoopbackServer.CreateClientAndServerAsync(async uri => { cws.Options.HttpVersion = HttpVersion.Version20; cws.Options.HttpVersionPolicy = Http.HttpVersionPolicy.RequestVersionExact; - using var handler = new SocketsHttpHandler(); - handler.SslOptions.RemoteCertificateValidationCallback = delegate { return true; }; + using var handler = CreateSocketsHttpHandler(allowAllCertificates: true); await cws.ConnectAsync(uri, new HttpMessageInvoker(handler), cts.Token); } }, 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 56c8ad1f7f194b..8615693825d14a 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,6 +5,8 @@ $(DefineConstants);NETSTANDARD false + + true diff --git a/src/tasks/AndroidAppBuilder/AndroidAppBuilder.cs b/src/tasks/AndroidAppBuilder/AndroidAppBuilder.cs index b2ae7276fe90b9..66eef2cd542c82 100644 --- a/src/tasks/AndroidAppBuilder/AndroidAppBuilder.cs +++ b/src/tasks/AndroidAppBuilder/AndroidAppBuilder.cs @@ -80,6 +80,8 @@ public class AndroidAppBuilderTask : Task /// public string? NativeMainSource { get; set; } + public bool IncludeNetworkSecurityConfig { get; set; } + public string? KeyStorePath { get; set; } public bool ForceInterpreter { get; set; } @@ -105,6 +107,7 @@ public override bool Execute() apkBuilder.BuildToolsVersion = BuildToolsVersion; apkBuilder.StripDebugSymbols = StripDebugSymbols; apkBuilder.NativeMainSource = NativeMainSource; + apkBuilder.IncludeNetworkSecurityConfig = IncludeNetworkSecurityConfig; apkBuilder.KeyStorePath = KeyStorePath; apkBuilder.ForceInterpreter = ForceInterpreter; apkBuilder.ForceAOT = ForceAOT; diff --git a/src/tasks/AndroidAppBuilder/ApkBuilder.cs b/src/tasks/AndroidAppBuilder/ApkBuilder.cs index 9ed098ac55a61e..11333b29e39dfa 100644 --- a/src/tasks/AndroidAppBuilder/ApkBuilder.cs +++ b/src/tasks/AndroidAppBuilder/ApkBuilder.cs @@ -24,6 +24,7 @@ public class ApkBuilder public string OutputDir { get; set; } = ""!; public bool StripDebugSymbols { get; set; } public string? NativeMainSource { get; set; } + public bool IncludeNetworkSecurityConfig { get; set; } public string? KeyStorePath { get; set; } public bool ForceInterpreter { get; set; } public bool ForceAOT { get; set; } @@ -57,6 +58,12 @@ public ApkBuilder(TaskLoggingHelper logger) throw new ArgumentException($"MainLibraryFileName='{mainLibraryFileName}' was not found in AppDir='{AppDir}'"); } + var networkSecurityConfigFilePath = Path.Combine(AppDir, "res", "xml", "network_security_config.xml"); + if (IncludeNetworkSecurityConfig && !File.Exists(networkSecurityConfigFilePath)) + { + throw new ArgumentException($"IncludeNetworkSecurityConfig is set but the file '{networkSecurityConfigFilePath}' was not found"); + } + if (string.IsNullOrEmpty(abi)) { throw new ArgumentException("abi should not be empty (e.g. x86, x86_64, armeabi-v7a or arm64-v8a"); @@ -172,6 +179,7 @@ public ApkBuilder(TaskLoggingHelper logger) Directory.CreateDirectory(Path.Combine(OutputDir, "obj")); Directory.CreateDirectory(Path.Combine(OutputDir, "assets-tozip")); Directory.CreateDirectory(Path.Combine(OutputDir, "assets")); + Directory.CreateDirectory(Path.Combine(OutputDir, "res")); var extensionsToIgnore = new List { ".so", ".a", ".gz" }; if (StripDebugSymbols) @@ -183,6 +191,7 @@ public ApkBuilder(TaskLoggingHelper logger) // Copy sourceDir to OutputDir/assets-tozip (ignore native files) // these files then will be zipped and copied to apk/assets/assets.zip var assetsToZipDirectory = Path.Combine(OutputDir, "assets-tozip"); + Utils.DirectoryCopy(AppDir, assetsToZipDirectory, file => { string fileName = Path.GetFileName(file); @@ -199,9 +208,20 @@ public ApkBuilder(TaskLoggingHelper logger) // aapt complains on such files return false; } + if (file.Contains("/res/")) + { + // exclude everything in the `res` folder + return false; + } return true; }); + // copy the res directory as is + if (Directory.Exists(Path.Combine(AppDir, "res"))) + { + Utils.DirectoryCopy(Path.Combine(AppDir, "res"), Path.Combine(OutputDir, "res")); + } + // add AOT .so libraries foreach (var aotlib in aotLibraryFiles) { @@ -373,6 +393,11 @@ public ApkBuilder(TaskLoggingHelper logger) if (!string.IsNullOrEmpty(NativeMainSource)) File.Copy(NativeMainSource, javaActivityPath, true); + string networkSecurityConfigAttribute = + IncludeNetworkSecurityConfig + ? "a:networkSecurityConfig=\"@xml/network_security_config\"" + : string.Empty; + string envVariables = ""; foreach (ITaskItem item in EnvironmentVariables) { @@ -390,6 +415,7 @@ public ApkBuilder(TaskLoggingHelper logger) File.WriteAllText(Path.Combine(OutputDir, "AndroidManifest.xml"), Utils.GetEmbeddedResource("AndroidManifest.xml") .Replace("%PackageName%", packageId) + .Replace("%NetworkSecurityConfig%", networkSecurityConfigAttribute) .Replace("%MinSdkLevel%", MinApiLevel)); string javaCompilerArgs = $"-d obj -classpath src -bootclasspath {androidJar} -source 1.8 -target 1.8 "; @@ -414,7 +440,8 @@ public ApkBuilder(TaskLoggingHelper logger) string debugModeArg = StripDebugSymbols ? string.Empty : "--debug-mode"; string apkFile = Path.Combine(OutputDir, "bin", $"{ProjectName}.unaligned.apk"); - Utils.RunProcess(logger, aapt, $"package -f -m -F {apkFile} -A assets -M AndroidManifest.xml -I {androidJar} {debugModeArg}", workingDir: OutputDir); + string resources = IncludeNetworkSecurityConfig ? "-S res" : string.Empty; + Utils.RunProcess(logger, aapt, $"package -f -m -F {apkFile} -A assets {resources} -M AndroidManifest.xml -I {androidJar} {debugModeArg}", workingDir: OutputDir); var dynamicLibs = new List(); dynamicLibs.Add(Path.Combine(OutputDir, "monodroid", "libmonodroid.so")); diff --git a/src/tasks/AndroidAppBuilder/Templates/AndroidManifest.xml b/src/tasks/AndroidAppBuilder/Templates/AndroidManifest.xml index 9d28b5efbdf3c8..befd2e446a650e 100644 --- a/src/tasks/AndroidAppBuilder/Templates/AndroidManifest.xml +++ b/src/tasks/AndroidAppBuilder/Templates/AndroidManifest.xml @@ -7,7 +7,8 @@ - diff --git a/src/tests/build.proj b/src/tests/build.proj index 063e3059c4385e..e83ee2129ed1ac 100644 --- a/src/tests/build.proj +++ b/src/tests/build.proj @@ -247,6 +247,7 @@ RuntimeIdentifier="$(RuntimeIdentifier)" ProjectName="$(Category)" MonoRuntimeHeaders="$(MicrosoftNetCoreAppRuntimePackDir)/native/include/mono-2.0" + IncludeNetworkSecurityConfig="$(IncludeNetworkSecurityConfig)" RuntimeComponents="$(RuntimeComponents)" DiagnosticPorts="$(DiagnosticPorts)" StripDebugSymbols="$(StripDebugSymbols)"