Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsavara committed Aug 1, 2024
1 parent 0e8db73 commit 9051935
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/libraries/System.Net.Http/src/System.Net.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'wasi'">
<Reference Include="System.Threading.Thread" />
<Compile Include="System\Net\Http\WasiHttpHandler\WasiHttpHandler.cs" />
<Compile Include="System\Net\Http\WasiHttpHandler\WasiHttp.cs" />
<Compile Include="System\Net\Http\WasiHttpHandler\WasiHttpWorld.wit.imports.wasi.clocks.v0_2_0.MonotonicClockInterop.cs" />
Expand Down Expand Up @@ -502,6 +501,10 @@
<Reference Include="Microsoft.Win32.Registry" Condition="'$(TargetPlatformIdentifier)' == 'windows'" />
</ItemGroup>

<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'wasi'">
<Reference Include="System.Threading.Thread" />
</ItemGroup>

<ItemGroup Condition="'$(TargetPlatformIdentifier)' != '' and '$(TargetPlatformIdentifier)' != 'windows' and '$(TargetPlatformIdentifier)' != 'browser'">
<Reference Include="System.Diagnostics.StackTrace" />
<Reference Include="System.Security.Cryptography" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
using Xunit;

[assembly: SkipOnCoreClr("System.Net.Tests are flaky and/or long running: https:/dotnet/runtime/issues/131", ~RuntimeConfiguration.Release)]
[assembly: ActiveIssue("https:/dotnet/runtime/issues/131", ~(TestPlatforms.Android | TestPlatforms.Browser), TargetFrameworkMonikers.Any, TestRuntimes.Mono)] // System.Net.Tests are flaky and/or long running
[assembly: ActiveIssue("https:/dotnet/runtime/issues/131", ~(TestPlatforms.Android | TestPlatforms.Browser | TestPlatforms.Wasi), TargetFrameworkMonikers.Any, TestRuntimes.Mono)] // System.Net.Tests are flaky and/or long running

Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "User-Agent is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
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";
Expand Down Expand Up @@ -139,6 +140,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
[InlineData("\u05D1\u05F1")]
[InlineData("jp\u30A5")]
[SkipOnPlatform(TestPlatforms.Browser, "Browser is relaxed about validating HTTP headers")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_InvalidCharactersInHeader_Throw(string value)
{
await LoopbackServerFactory.CreateClientAndServerAsync(async uri =>
Expand Down Expand Up @@ -388,6 +390,7 @@ public async Task SendAsync_GetWithValidHostHeader_Success(bool withPort)
[OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))]
[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_GetWithInvalidHostHeader_ThrowsException()
{
if (LoopbackServerFactory.Version >= HttpVersion.Version20)
Expand All @@ -408,6 +411,7 @@ public async Task SendAsync_GetWithInvalidHostHeader_ThrowsException()

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Browser is relaxed about validating HTTP headers")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_WithZeroLengthHeaderName_Throws()
{
await LoopbackServerFactory.CreateClientAndServerAsync(
Expand Down Expand Up @@ -452,6 +456,7 @@ private static readonly (string Name, Encoding ValueEncoding, string Separator,

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Socket is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_CustomRequestEncodingSelector_CanSendNonAsciiHeaderValues()
{
await LoopbackServerFactory.CreateClientAndServerAsync(
Expand Down Expand Up @@ -507,6 +512,7 @@ await LoopbackServerFactory.CreateClientAndServerAsync(

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Socket is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_CustomResponseEncodingSelector_CanReceiveNonAsciiHeaderValues()
{
await LoopbackServerFactory.CreateClientAndServerAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ await server.AcceptConnectionAsync(async connection =>

[Collection(nameof(HttpClientMiniStress))]
[SkipOnPlatform(TestPlatforms.Browser, "System.Net.Security is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public abstract class HttpClientMiniStress : HttpClientHandlerTestBase
{
public HttpClientMiniStress(ITestOutputHelper output) : base(output) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public async Task GetContentAsync_ErrorStatusCode_ExpectedExceptionThrown(bool w

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Socket is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task GetContentAsync_WhenCannotConnect_ExceptionContainsHostInfo()
{
const string Host = "localhost:1234";
Expand Down Expand Up @@ -692,6 +693,7 @@ public void Dispose_UseAfterDispose_Throws()
[InlineData(false)]
[InlineData(true)]
[SkipOnPlatform(TestPlatforms.Browser, "System.Net.Sockets is not supported on this platform")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public void CancelAllPending_AllPendingOperationsCanceled(bool withInfiniteTimeout)
{
using (var client = new HttpClient(new CustomResponseHandler((r, c) => WhenCanceled<HttpResponseMessage>(c))))
Expand All @@ -710,6 +712,7 @@ public void CancelAllPending_AllPendingOperationsCanceled(bool withInfiniteTimeo
[InlineData(HttpCompletionOption.ResponseContentRead)]
[InlineData(HttpCompletionOption.ResponseHeadersRead)]
[SkipOnPlatform(TestPlatforms.Browser, "System.Net.Sockets is not supported on this platform")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public void Timeout_TooShort_AllPendingOperationsCanceled(HttpCompletionOption completionOption)
{
using (var client = new HttpClient(new CustomResponseHandler((r, c) => WhenCanceled<HttpResponseMessage>(c))))
Expand Down Expand Up @@ -747,6 +750,7 @@ public async Task Timeout_CallerCanceledTokenAfterTimeout_TimeoutIsNotDetected(H
[InlineData(HttpCompletionOption.ResponseContentRead)]
[InlineData(HttpCompletionOption.ResponseHeadersRead)]
[SkipOnPlatform(TestPlatforms.Browser, "System.Net.Sockets is not supported on this platform")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public void Timeout_CallerCanceledTokenBeforeTimeout_TimeoutIsNotDetected(HttpCompletionOption completionOption)
{
using (var client = new HttpClient(new CustomResponseHandler((r, c) => WhenCanceled<HttpResponseMessage>(c))))
Expand Down Expand Up @@ -943,6 +947,7 @@ public void Send_SingleThread_Succeeds(HttpCompletionOption completionOption)
[InlineData(HttpCompletionOption.ResponseHeadersRead)]
[SkipOnPlatform(TestPlatforms.Browser, "Synchronous Send is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Android, "Synchronous Send is not supported on Android")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task Send_SingleThread_Loopback_Succeeds(HttpCompletionOption completionOption)
{
string content = "Test content";
Expand Down Expand Up @@ -998,6 +1003,7 @@ await server.AcceptConnectionAsync(async connection =>
[OuterLoop]
[SkipOnPlatform(TestPlatforms.Browser, "Synchronous Send is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Android, "Synchronous Send is not supported on Android")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task Send_CancelledRequestContent_Throws()
{
CancellationTokenSource cts = new CancellationTokenSource();
Expand Down Expand Up @@ -1087,6 +1093,7 @@ await server.AcceptConnectionAsync(async connection =>
[OuterLoop]
[SkipOnPlatform(TestPlatforms.Browser, "Synchronous Send is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Android, "Synchronous Send is not supported on Android")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task Send_CancelledResponseContent_Throws()
{
string content = "Test content";
Expand Down Expand Up @@ -1139,6 +1146,7 @@ await IgnoreExceptions(async () =>
[OuterLoop]
[SkipOnPlatform(TestPlatforms.Browser, "Synchronous Send is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Android, "Synchronous Send is not supported on Android")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task Send_TimeoutResponseContent_Throws()
{
const string Content = "Test content";
Expand Down Expand Up @@ -1197,6 +1205,7 @@ public static IEnumerable<object[]> VersionSelectionMemberData()
[Theory]
[MemberData(nameof(VersionSelectionMemberData))]
[SkipOnPlatform(TestPlatforms.Browser, "Version is ignored on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_CorrectVersionSelected_LoopbackServer(Version requestVersion, HttpVersionPolicy versionPolicy, Version serverVersion, bool useSsl, object expectedResult)
{
await HttpAgnosticLoopbackServer.CreateClientAndServerAsync(
Expand Down Expand Up @@ -1247,6 +1256,7 @@ await HttpAgnosticLoopbackServer.CreateClientAndServerAsync(
[OuterLoop("Uses external servers")]
[MemberData(nameof(VersionSelectionMemberData))]
[SkipOnPlatform(TestPlatforms.Browser, "Version is ignored on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task SendAsync_CorrectVersionSelected_ExternalServer(Version requestVersion, HttpVersionPolicy versionPolicy, Version serverVersion, bool useSsl, object expectedResult)
{
RemoteServer remoteServer = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ public async Task ReadAsStreamAsync_FirstGetFromUnbufferedContentThenGetFromBuff
}

[SkipOnPlatform(TestPlatforms.Browser, "Browser doesn't support Synchronous reads")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
[Theory]
[InlineData(true)]
[InlineData(false)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ public Task RequestDuration_ErrorStatus_ErrorTypeRecorded(int statusCode)

[Fact]
[SkipOnPlatform(TestPlatforms.Browser, "Browser is relaxed about validating HTTP headers")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task RequestDuration_ConnectionClosedWhileReceivingHeaders_Recorded()
{
using CancellationTokenSource cancelServerCts = new CancellationTokenSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ internal static async Task HandleAuthenticationRequestWithFakeServer(LoopbackSer
[InlineData(true)]
[InlineData(false)]
[SkipOnPlatform(TestPlatforms.Browser, "Credentials and HttpListener is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task DefaultHandler_FakeServer_Success(bool useNtlm)
{
await LoopbackServer.CreateClientAndServerAsync(
Expand All @@ -142,6 +143,7 @@ await server.AcceptConnectionAsync(async connection =>

[Fact]
[SkipOnPlatform(TestPlatforms.Browser | TestPlatforms.Windows, "DefaultCredentials are unsupported for NTLM on Unix / Managed implementation")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task DefaultHandler_FakeServer_DefaultCredentials()
{
await LoopbackServer.CreateClientAndServerAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static IEnumerable<object[]> ZeroByteRead_IssuesZeroByteReadOnUnderlyingS
[Theory]
[MemberData(nameof(ZeroByteRead_IssuesZeroByteReadOnUnderlyingStream_MemberData))]
[SkipOnPlatform(TestPlatforms.Browser, "ConnectCallback is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public async Task ZeroByteRead_IssuesZeroByteReadOnUnderlyingStream(StreamConformanceTests.ReadWriteMode readMode, bool useSsl)
{
(Stream httpConnection, Stream server) = ConnectedStreams.CreateBidirectional(4096, int.MaxValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,24 +313,28 @@ public SocketsHttpHandler_HttpClientEKUTest(ITestOutputHelper output) : base(out
#endif

[SkipOnPlatform(TestPlatforms.Browser, "AutomaticDecompression not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandler_HttpClientHandler_Decompression_Tests : HttpClientHandler_Decompression_Test
{
public SocketsHttpHandler_HttpClientHandler_Decompression_Tests(ITestOutputHelper output) : base(output) { }
}

[SkipOnPlatform(TestPlatforms.Browser, "Certificates are not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandler_HttpClientHandler_DangerousAcceptAllCertificatesValidator_Test : HttpClientHandler_DangerousAcceptAllCertificatesValidator_Test
{
public SocketsHttpHandler_HttpClientHandler_DangerousAcceptAllCertificatesValidator_Test(ITestOutputHelper output) : base(output) { }
}

[SkipOnPlatform(TestPlatforms.Browser, "Certificates are not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandler_HttpClientHandler_ClientCertificates_Test : HttpClientHandler_ClientCertificates_Test
{
public SocketsHttpHandler_HttpClientHandler_ClientCertificates_Test(ITestOutputHelper output) : base(output) { }
}

[SkipOnPlatform(TestPlatforms.Browser, "Proxy is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandler_HttpClientHandler_DefaultProxyCredentials_Test : HttpClientHandler_DefaultProxyCredentials_Test
{
public SocketsHttpHandler_HttpClientHandler_DefaultProxyCredentials_Test(ITestOutputHelper output) : base(output) { }
Expand All @@ -348,6 +352,7 @@ public SocketsHttpHandler_HttpClientHandler_Finalization_Http2_Test(ITestOutputH
}

[SkipOnPlatform(TestPlatforms.Browser, "MaxConnectionsPerServer not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandler_HttpClientHandler_MaxConnectionsPerServer_Test : HttpClientHandler_MaxConnectionsPerServer_Test
{
public SocketsHttpHandler_HttpClientHandler_MaxConnectionsPerServer_Test(ITestOutputHelper output) : base(output) { }
Expand Down Expand Up @@ -412,12 +417,14 @@ await server.AcceptConnectionAsync(async connection =>
}

[SkipOnPlatform(TestPlatforms.Browser, "Certificates are not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandler_HttpClientHandler_ServerCertificates_Test : HttpClientHandler_ServerCertificates_Test
{
public SocketsHttpHandler_HttpClientHandler_ServerCertificates_Test(ITestOutputHelper output) : base(output) { }
}

[SkipOnPlatform(TestPlatforms.Browser, "ResponseDrainTimeout is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandler_HttpClientHandler_ResponseDrain_Test : HttpClientHandler_ResponseDrain_Test
{
protected override void SetResponseDrainTimeout(HttpClientHandler handler, TimeSpan time)
Expand Down Expand Up @@ -730,6 +737,7 @@ public SocketsHttpHandler_HttpClientHandler_SslProtocols_Test(ITestOutputHelper
}

[SkipOnPlatform(TestPlatforms.Browser, "UseProxy not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandler_HttpClientHandler_Proxy_Test : HttpClientHandler_Proxy_Test
{
public SocketsHttpHandler_HttpClientHandler_Proxy_Test(ITestOutputHelper output) : base(output) { }
Expand Down Expand Up @@ -1299,12 +1307,14 @@ public SocketsHttpHandlerTest_RequestRetry(ITestOutputHelper output) : base(outp
}

[SkipOnPlatform(TestPlatforms.Browser, "UseCookies is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandlerTest_Cookies : HttpClientHandlerTest_Cookies
{
public SocketsHttpHandlerTest_Cookies(ITestOutputHelper output) : base(output) { }
}

[SkipOnPlatform(TestPlatforms.Browser, "UseCookies is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandlerTest_Cookies_Http11 : HttpClientHandlerTest_Cookies_Http11
{
public SocketsHttpHandlerTest_Cookies_Http11(ITestOutputHelper output) : base(output) { }
Expand Down Expand Up @@ -1719,6 +1729,7 @@ public SocketsHttpHandler_HttpClientHandler_MaxResponseHeadersLength_Http3(ITest
}

[SkipOnPlatform(TestPlatforms.Browser, "Socket is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandler_HttpClientHandler_Authentication_Test : HttpClientHandler_Authentication_Test
{
public SocketsHttpHandler_HttpClientHandler_Authentication_Test(ITestOutputHelper output) : base(output) { }
Expand Down Expand Up @@ -1851,6 +1862,7 @@ public SocketsHttpHandler_Connect_Test(ITestOutputHelper output) : base(output)
}

[SkipOnPlatform(TestPlatforms.Browser, "Socket is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandler_HttpClientHandler_ConnectionPooling_Test : HttpClientHandlerTestBase
{
public SocketsHttpHandler_HttpClientHandler_ConnectionPooling_Test(ITestOutputHelper output) : base(output) { }
Expand Down Expand Up @@ -2602,6 +2614,7 @@ await Assert.ThrowsAnyAsync<Exception>(() =>
}

[SkipOnPlatform(TestPlatforms.Browser, "Headers.Location are not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandlerTest_LocationHeader
{
private static readonly byte[] s_redirectResponseBefore = Encoding.ASCII.GetBytes(
Expand Down Expand Up @@ -3599,6 +3612,7 @@ public override int ReadByte() =>
}

[SkipOnPlatform(TestPlatforms.Browser, "Socket is not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocketsHttpHandlerTest_ConnectCallback_Http11 : SocketsHttpHandlerTest_ConnectCallback
{
public SocketsHttpHandlerTest_ConnectCallback_Http11(ITestOutputHelper output) : base(output) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public async Task TestExceptionalAsync(string scheme, string host, bool useAuth,


[SkipOnPlatform(TestPlatforms.Browser, "UseProxy not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocksProxyTest_Http1_Async : SocksProxyTest
{
public SocksProxyTest_Http1_Async(ITestOutputHelper helper) : base(helper) { }
Expand All @@ -123,6 +124,7 @@ public SocksProxyTest_Http1_Async(ITestOutputHelper helper) : base(helper) { }

[SkipOnPlatform(TestPlatforms.Browser, "UseProxy not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Android, "The sync Send method is not supported on mobile platforms")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocksProxyTest_Http1_Sync : SocksProxyTest
{
public SocksProxyTest_Http1_Sync(ITestOutputHelper helper) : base(helper) { }
Expand All @@ -131,6 +133,7 @@ public SocksProxyTest_Http1_Sync(ITestOutputHelper helper) : base(helper) { }
}

[SkipOnPlatform(TestPlatforms.Browser, "UseProxy not supported on Browser")]
[SkipOnPlatform(TestPlatforms.Wasi, "TODO WASI")]
public sealed class SocksProxyTest_Http2 : SocksProxyTest
{
public SocksProxyTest_Http2(ITestOutputHelper helper) : base(helper) { }
Expand Down
Loading

0 comments on commit 9051935

Please sign in to comment.