Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix some System.Net tests #71385

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
45bedb1
Implement IncludeNetworkSecurityConfig
simonrozsival Jun 27, 2022
575bed7
Use IncludeNetworkSecurityConfig
simonrozsival Jun 27, 2022
5e6b3fa
Fix tests
simonrozsival Jun 28, 2022
93b5648
Merge branch 'main' of https://github.com/dotnet/runtime into fix-sys…
simonrozsival Jun 28, 2022
89296f6
Remove active issue attributes
simonrozsival Jun 28, 2022
f7ca23a
Rename certificate file
simonrozsival Jun 28, 2022
ff09605
Revert unnecessary changes
simonrozsival Jun 28, 2022
039d051
TMP: re-throw caught exception to reveal more information in logs
simonrozsival Jul 1, 2022
98db19b
Revert "TMP: re-throw caught exception to reveal more information in …
simonrozsival Jul 1, 2022
a1616c3
Merge branch 'main' of https://github.com/dotnet/runtime into fix-sys…
simonrozsival Jul 1, 2022
a4c25b4
TMP: add and update res folders until they are merged into runtime-as…
simonrozsival Jul 4, 2022
4acb16b
Fix System.Net.Requests tests
simonrozsival Jul 4, 2022
3dad204
Re-enable System.Net.Http functional tests
simonrozsival Jul 4, 2022
b1806a1
Try fixing failing test
simonrozsival Jul 7, 2022
a440d13
Merge branch 'main' of https://github.com/dotnet/runtime into fix-sys…
simonrozsival Jul 7, 2022
7f2e0e3
Skip failing test
simonrozsival Jul 7, 2022
c2615af
Add missing using
simonrozsival Jul 7, 2022
ae5b34f
Merge branch 'main' of https://github.com/dotnet/runtime into fix-sys…
simonrozsival Jul 8, 2022
a895adb
Remove temporary test data
simonrozsival Jul 11, 2022
26f9ed4
Merge branch 'main' of https://github.com/dotnet/runtime into fix-sys…
simonrozsival Jul 12, 2022
cf0ae39
Relax exception type assertion for Android
simonrozsival Jul 12, 2022
3498036
Merge branch 'main' of https://github.com/dotnet/runtime into fix-sys…
simonrozsival Jul 12, 2022
b73c45c
Code cleanup
simonrozsival Jul 13, 2022
390e63a
Merge branch 'main' of https://github.com/dotnet/runtime into fix-sys…
simonrozsival Jul 13, 2022
0802f46
Fix test failures in System.Net.WebSockets.Client.Tests
simonrozsival Jul 15, 2022
669b238
Merge branch 'main' of https://github.com/dotnet/runtime into fix-sys…
simonrozsival Jul 15, 2022
beef031
Remove active issue attribute
simonrozsival Jul 15, 2022
8b3e7fa
Remove most explicit usages of the server certificate custom validati…
simonrozsival Jul 15, 2022
901ad2f
Fix several tests
simonrozsival Jul 16, 2022
0388450
Remove weird condition
simonrozsival Jul 16, 2022
4ae8433
Code clean-up
simonrozsival Jul 18, 2022
50d3210
Remove unrelated active issue attributes
simonrozsival Jul 18, 2022
6d0d981
Turn ActiveIssue attributes into permanent SkipOnPlatform
simonrozsival Jul 18, 2022
43ad035
Update explanation for SkipOnPlatform
simonrozsival Jul 18, 2022
38ee4df
Revert partial fix and keep active issue
simonrozsival Jul 18, 2022
03883b7
Keep active issue for android x64 and x86
simonrozsival Jul 18, 2022
4ee991e
Remove invalid attribute
simonrozsival Jul 18, 2022
74970c1
Fix test on Browser
simonrozsival Jul 18, 2022
caff00b
Allow all certificates by default
simonrozsival Jul 18, 2022
4f63248
Fix build
simonrozsival Jul 18, 2022
a200ac6
Fix http client handler factory on Browser
simonrozsival Jul 19, 2022
59f7e61
Skip failing test
simonrozsival Jul 19, 2022
35b9ed0
Fix net48 build
simonrozsival Jul 19, 2022
8db4b45
Revert unintentional change in WinHttpHandler tests
simonrozsival Jul 19, 2022
6ad3302
Merge branch 'main' of https://github.com/dotnet/runtime into fix-sys…
simonrozsival Jul 19, 2022
33d52f1
Avoid using unsupported property on Browser
simonrozsival Jul 19, 2022
8608d46
Remove unnecessary default value
simonrozsival Jul 19, 2022
c07330b
Avoid using unsupported property on Browser
simonrozsival Jul 19, 2022
825654a
Merge branch 'main' of https://github.com/dotnet/runtime into fix-sys…
simonrozsival Jul 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
MonoRuntimeHeaders="$(MicrosoftNetCoreAppRuntimePackNativeDir)include\mono-2.0"
Assemblies="@(BundleAssemblies)"
MainLibraryFileName="$(MainLibraryFileName)"
IncludeNetworkSecurityConfig="$(IncludeNetworkSecurityConfig)"
EnvironmentVariables="@(_AndroidEnv)"
ForceAOT="$(RunAOTCompilation)"
ForceInterpreter="$(MonoForceInterpreter)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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 };
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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[]
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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) =>
Expand Down Expand Up @@ -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) =>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) =>
Expand Down Expand Up @@ -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) =>
Expand Down Expand Up @@ -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) =>
Expand Down Expand Up @@ -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) =>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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) =>
Expand All @@ -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) =>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading